First i would apologize for the question as there are answers out there but as this is my first project i do not really understand the explanations how to do this.
I have an application that uses Core Data, which works on the simulator but not when i generate it on my device. The app starts but it seems like the Core Data is empty. I guess i need to move the DB into the device.
Would someone nice be able to, in a simple way, explain how I fix this?
PROBLEM SOLVED
I downloaded "iPhone Explorer" (http://www.macroplant.com/iphoneexplorer/) and manually removed the two instances of the DB on the actual device and re-run the app and all finally worked.
If you populate the sqlite generated by Core Data (found in the simulator folder) and want to add to the main bundle of your project to load on application startup, then please see the instructions on the following website:
http://iphonedevelopment.blogspot.com/2010/08/core-data-starting-data.html
This basically checks for the pre-populated DB. If not found, it creates one as normally done when on first launch of a application which uses Core Data.
Related
I have an xcode project that has 4 targets (2 apps, 1 iPhone and 1 iPad version for each). I have recently implemented Core Data Lightweight Migration.
I am currently only testing two of the apps, the iPhone versions, call them App A and App B. I am able to run the current app store version of App A on my iPhone, then install my new version of App A to test the Lightweight Migration. It works fine, no problem.
Then, I try the same thing with App B. I am able to install the current app store version of App B on my iPhone no problem. BUT, when I try in install the new version of app B on my iPhone, I get the following error (or a variant of it) EVERY time: "putpkt: write failed, broken pipe"
I am confused since the two current versions are in the same project and have the exact same settings for every configuration (debug, release, distribution). The is not ad-hoc distribution.
Every post I have read for this error on this forum, and anywhere, suggests things like removing the app, restarting the device, restarting xcode, etc. And sure, I can get it to work that way. BUT I cannot test my migration that way.. If I remove the old version of the app from the device nothing is getting migrated!
I am pulling my hair out over this. The two apps were originally in two different projects, and I added App B to the App A project as a new target - that is the only thing I can think of, as I feel like I have looked at everything. I would really appreciate some help to figure out this problem. I feel sick about sending out a database update that I cannot test - I can't take the chance of corrupting people's data, especially when I have not offered a backup option until this current version. Ugh.
EDIT: when I try to run App B on the device without updating, I often get the following error:
Error Starting Executable... Don't know how to run. Try "help target".
EDIT: I think I am having this trouble because I renamed the product name for app B. I think this changed the bundle and will not allow me to migrate data. I will try to change it back and post an update. It seems like merge bundles IS working well for app A in the meantime.
Making sure the new project and the original project had the same product name and the same data model name fixed this problem for me.
I've written an application that uses Core-Data. I'm wondering if, while the XCode simulator is running, there is a way to see the contents held via Core-Data (the various rows, attributes, etc). Would greatly appreciate any help, thank you.
Using SQLite as the persistent store I usually fire up Lita, navigate to the application directory, and refresh the tables/rerun queries as needed.
I had a problem in my simulator - when I want to edit the table in core data or create a new table the program which was using the database fails every time I start it. So I google the problem and I found the solution - every time I want to change something in my tables I have to manually delete my database. So it works fine but nowadays I get the license for testing it on real device, but I do not know how will it works on real device. I work for company and maybe the database will be expanding with some new tables, and I really do not know how to prevent it in real device. I admit it is a strange problem, but can you help me?
If your change your Core Data model during testing, you can easily delete your app from the simulator/device. In this case Xcode will install a new database on your simulator/device when you re-install the app and your app won't crash.
If the app has already been released in iTunes and you want to change the database, you have to implement data migration in your app.
Hope I understood your question right. Please ask if you have any more questions.
I apologize ahead of time for what I'm sure is a complete newbie lapse. Running my iPhone app on iPhone simulator - no problem. But I loaded the app on an iPhone device for the first time and it appears as if the SQLite database I'm using (NSManagedObjectContext) isn't connected or didn't upload. The app installs but with no data. How do I get it all to upload and work on the device?
I appreciate any help.
lq
The first rule with Core Data is that you should never ever touch the store directly. It should be considered a black box and only accessed via the the Core Data APIs. Accessing the database directly is unsupported and can lead to data corruption.
What you should do instead is create a trivial desktop application (or command line is you are just importing from another source) and enter the data there. Once the data is entered then copy the sqlite file to your mobile application and include it in the bundle. That way you are accessing the file from Core Data. Since Apple can and does change the structure of that file without notice your application will be future proof.
update
If you have created a database using Core Data you can then take that sqlite file and add it to your Xcode project for your iPhone application. Xcode will then copy it into the app bundle when it compiles the project.
Looking a little deeper I found a link that answers my own question. So anyone with the same question, this solved the issue for me:
http://ablogontech.wordpress.com/2009/07/13/using-a-pre-populated-sqlite-database-with-core-data-on-iphone-os-3-0/
I'm working on an iPhone app and about to release version 2. We'll be changing the core data model and I'd like to simulate the upgrade process in the simulator before releasing it to users and potentially causing data loss for them. There doesn't seem to be any real good doucumentation on how to do this in a sandbox before releasing it.
The process I've used in the past has been to wipe any working version from the Simulator, check out the previous version of my application from my repository, compile and install that, work with it for a bit, then compile and install the new version of the application. The installation of the new version should simulate the upgrade process, where you can test your data migration to your new model.
I also repeat this process on the device to make sure no problems are encountered there either.
there are some cases that cannot be simulated in Xcode. Look at this Apple page: https://developer.apple.com/library/ios/technotes/tn2285/_index.html
You have to create IPA file and simulate update via iTunes.
I agree with Brad's overall approach. To save a little time, I would just save the sample set of data that you create with the older version of your app. This way you won't have to keep recreating the sample data set if things don't go right. You will just simply copy the sample data set back into your app's directory in the Simulator.
Your app's directory is located at ~/Library/Application Support/iPhone Simulator/User/Applications/A GUID for your App on your development machine.