How to deploy App to Apple Store with repopulated database(SQLite)? - ios

I am developing my mobile app using react-native, and database goes with it, I am using SQLite storage.
The way I work with it:
create it using python script and copy it to path where virtual device takes.
Obviously I need somehow to bundle it within my app in order to run on real device?
I have 2 options in mind:
1. Keep state of app using AsyncStorage, where to store isDBCreated
variable, so we creat DB from json file that is shipped with the app
only once and then use it on consequent runs
2. Somehow bundle created DB
With 1 - I am confident and know how to do it
With 2 - don't know ( I have followed official documentation in order to bundle it on IOS, but without luck)
From your experience, what is the best way to bundle database?

Related

iOS UnitTests with preloaded sqlite3 DB

I am required to create iOS unit tests, where i need to push an sql .db into app location/sandbox/whatever (may be from testsuit's setUp() func) and run some CRUD operations from the testcases and later delete the db from tearDown() when tests done. How can i push a .db into app location for test, which will be used just like a db used inside app.
Another question, I need to run automated tests, so is there any command (like in Android we use adb, in Tize we use gdb) for iOS app to insert these database file in app location to run those testcases. If i am missing any point please help.
What is the standard way to test CRUD operations in a simulated db for iOS.
As far as my study, there is no adb/sdb like tool for iOS. Moreover there is an workaround for performing test on real database.
Steps
Keep the test-database into App/resource folder. You can skip this large test-database from your release build by following these technique.
Make a function in App side to replaceWithTestDatabase(), which basically replace your App database with App/resource/test-database. You can temporary copy current App db if you need.
If you want to access from AppTests (unit test), you can simply call Aapp/replaceWithTestDatabase as iOS Tests are hosted under main App.
If you want to access from AppUITests, you need to send extra launch argument from setUp() method to let App know that it should call replaceWithTestDatabase from app delegates. Here is a nice explanation how we can send arguments to main App from AppUITests.
Hope it helps.

How to prevent load of meteor.local (when building ios app with phonegap)

This is an extension of a question I asked here, which went unanswered. I am attempting to use the Meteor app on my iPad that I'm hosting on my own remote server. The issue is that when I run the following command, the app builds successfully:
sudo meteor run ios-device --mobile-server=XXXX:XXXX
The problem begins when I click the build button in Xcode to deploy the app to my device. It seems to build everything OK and even load the data from my remote server. But after a few seconds, it reverts back to a local database/build. When I check the Xcode log, it says "Finished load of http://meteor.local/" so it seems to be overwriting the remote data with new, local data. I'm not sure if I have something enabled that's causing Xcode to load a local database or if there's something that I have to turn off to prevent it from loading.
UPDATE:
I've resolved the issue using the suggestion from Jey DWork to apply the missing environment variables in the Meteor server startup.
The ones I added were:
Meteor.absoluteUrl.defaultOptions.rootUrl
process.env.ROOT_URL
process.env.MOBILE_ROOT_URL
process.env.MOBILE_DDP_URL
Without setting these, the ROOT_URL seemed to be getting overwritten after the initial load. As these environment variables do not seem to be documented, I'm still going to search and see if there is a different solution to this issue (as it seems strange that the app would have to re-load itself multiple times before it's usable). For now though, this is a temporary solution.
Have a look at this post :
I've understood my problem, maybe your problem is the same, all explanations here : stackoverflow.com/questions/34658956/
Your app for smartphone must be built with --server=http://IP:PORT parameters
And
Your app for server must be started with --mobile-server http://IP:PORT parameters

UIAutomation bringing iOS app to a consistent state

I writing JavaScript test for my iOS app. I am hoping of using Apples Profiler and UIAutomation.
1) I was wondering how can I reset the app every time I run the test. I would like to reset my app to a consistent state every time before I run a new test. Have separated my tests into few groups. Every test of the first group should start on the first screen containing a tableView and filters for sorting elements in that table should be set to a consistent state. Second group of tests should start on the Settings screen and some options/switches should be pressed in particular order for me to test the UI.
2) Also first time the app starts there is a tutorial. How can I make the app think it is freshly installed and test the tutorial feature.
Thanks for the answers
How can I make the app think it is freshly installed ?
As the iOS applications are sandboxed, the only way is to delete and re-install the app every time.
In the Illuminator framework that I wrote (which extends UIAutomation), we provide an automation bridge that allows us to send "reset" commands to the app, putting it into a known state before each test is run. This makes the testing very repeatable, even if some tests fail.
Additionally, the command line scripts can recover the test run even if the app crashes.

More efficient way to view changes on a mobile device without pushing rails app to heroku?

Probably a dumb question:
Right now, to see changes made in development, I run rails s and see the changes on the local version of my site. To see how changes look on my phone, I currently commit to Git (no matter how small the changes) and then push to heroku. This takes some time and results in lots of commits and deployments for minor changes (i.e. CSS stuff).
What is a more efficient way to test changes for rails web apps on mobile?
NOTE: I am aware I can shrink my browser but it never fails I get different outcomes on my phone.
Any help is appreciated.
RELATED: how do i run a development rails app / website on an ipod
You can also use Nitrous.io which is a cloud development environment. I like it because not only can I view my work on mobile, but since it's a hosted URL, I can share it with others while my server is running.
1) connect your phone to the same network that your local server is running on and point it to http://[your server's ip]:3000
2) use the XCode iOS Simulator and/or the Android Emulator
you can also use ngrok
https://ngrok.com/
which gives you a way to make an external tunnel to the outside world (for free) so you can use it outside of your local network

How to delete application data on install and reinstall

How to delete application data on install/reinstall application, so I can have a clean working environment on every reinstall ?
I mean how to detect that this application has been reinstalled so I can clean the whole persistent store.
Thanks.
In the 5.0 APIs there is a new class called CodeModuleListener which you could use to monitor when your modules are being uninstalled. Prior to 5.0 though, there are no hooks. However, here are a few ideas to think about and/or try:
Use the CodeModuleManager methods getModuleDownloadTimestamp() or getModuleTimestamp() (not sure which one would give the proper information) to look up the "install time" of the module, then store it in persistence. Then each time the app is started, read the value from the module again and compare it to the persisted value. If the module value is newer, then the app was reinstalled.
If you store a non-native class in the Persistent Store (i.e. a subclass of Hashtable), it will be removed from the persistent store when you uninstall the app (since without the app, the class is meaningless). So all you need to do is create a subclass of Hashtable and store that in your persistent store (with your actual data as keys), and it will be automatically removed from the store when the user uninstalls the app.
Maybe I'm misunderstanding, but shouldn't your uninstaller just delete the persistent store? Some uninstallers have a checkbox option that lets the user control whether or not their data is uninstalled as well, but it's definitely the uninstaller's job to get rid of it if necessary

Resources