|
Post by gromiczek on Aug 24, 2022 15:18:49 GMT
Hi - I'm building my project to iOS and am wondering if there are some good ways to sanity check the presence and contents of the SQLite db and that SimpleSQL is working as expected? The game is working great and as expected in the editor, but once I build to iOS some elements that are based on data from the db are missing. I'm working my way through the list of reasons why this may be - one is that the db is either empty or missing. Do you have any good go-to debugging approaches for this scenario? Thanks!
edit 1: I'm using the 2020 LTS for this project
edit 2: I generate the database contents during development and then want to build the iOS app and include the already filled database. I'm concerned I may just be ending up with an empty database when I do the build. Do I need to do anything special with the filled database in the editor to make sure its included with the build? Thanks!
|
|
|
Post by echo17 on Aug 25, 2022 16:28:24 GMT
This FAQ might answer your questions: linkGenerally speaking, I usually have two databases in my project: one for static data (data that does not change at runtime) and one for dynamic data (data that changes at runtime). The static database can be set to "overwrite if exists" in the inspector, where the dynamic database will not have this option checked.
|
|
|
Post by gromiczek on Aug 25, 2022 17:26:42 GMT
Hi - thanks for the reply! My database is dynamic but doesn't start empty - so I have the box unchecked. The database contains information on a starting population of organisms that the player can breed to create more and different organisms, which are then also added to the database. However, when I build to iOS and run the program for the first time none of the organisms show up (though they do appear as expected in the editor), making me wonder if the database in the build is empty when it should be full of the starter population. Is there a way to check that the pre-populated database has been included with the build?
|
|
|
Post by echo17 on Aug 26, 2022 8:39:38 GMT
It sounds like you might have run the program once on iOS when the database was empty, causing it to copy over that empty database on the first run. Every run after that will have the empty database too since the database already exists in the working folder.
You could set the "Overwrite if exists" to true on the inspector, compile and run for iOS, then set the checkbox back to false so any run after that doesn't wipe out your dynamic data. Note that this will wipe out the dynamic data the one time you run it with overwrite on.
If you need to populate data in a dynamic database, then you'll need to use an upgrade path to avoid stomping on any data updated at runtime. The FAQ link above discusses some ways to do this.
|
|
|
Post by gromiczek on Sept 7, 2022 17:27:09 GMT
I still haven't sorted this out, but I have confirmed that indeed the table (and data) is missing when I run the program on iOS. I tried your suggestion with the check box but nothing changed. I wondered if it matters that I use a separate scene and scripts in the editor on my desktop to populate the database and then I use that populated database in the actual game (which is a different scene). Does this have any implications for how things will behave on iOS? I have noticed that if I check the overwrite box in the editor and run the program with the pre-populated database the whole table gets erased.
|
|
|
Post by echo17 on Sept 8, 2022 10:11:27 GMT
So to summarize the FAQ here: link: When your project first runs it will copy the template database from your compiled project to your device's working location. This is because the embedded template database is not writable inside the project. So on your desktop, your working database is located in a working location. Any updates you make to the database at runtime are made on the working database, not the one in your project. Once you deploy to another platform, like iOS, it will not see the working database from your computer, only the embedded template database of your project. In other words, your working database on your computer will not be shared by the working database on iOS. Have a look here for locations of your working database: linkNote that this is the same process that developing an app in XCode will utilize. Apple Apps developed this way will create a working copy of your database that is separate from the starting template database. There really is no way around this since you cannot update an embedded database. If you are wanting to make changes on one device (like your desktop) and see them on another (like iOS), then you will need to have some way to synch up the databases. I have personally used Dropbox to do this in my budgeting app iVelopes. A user makes a change, then the database is copied to Dropbox. If another user accesses the program on a different device, then the database is downloaded from Dropbox first. The synch checks are a bit more complicated than that, but that is the drift.
|
|