Can't save changes in Realm DB file - ios

I work in iOS app and I use Realm for local DB. I've installed Realm via cocoapods and added my model classes. Everything is fine but when I opened the default.realm file from the simulator Documents directory in Realm browser app, I was unable to edit records or do any changes. I'm able only to add records but I can't edit fields, once I put the value in fields and navigate between classes, all changes I made disappear.
Update:
I see in cocoapods, the RealmSwift installed is version (0.98.3) and the Realm browser which is the latest from App Store is version Version 0.97.0 (62). Would that be the problem?

If you double-click on a field, that should make the cell editable and you can change it's values. It might be necessary to hit 'Return' after you've made those changes for the value change to stick.
There's a new version of the Browser on its GitHub page now: https://github.com/realm/realm-browser-osx/releases/tag/0.98.3
If you're still having issues with that version and the instructions I provided above, please let me know here!

Related

Can't Open Realm Studio After Update - Realm file is currently open in another process - Mac & Realm Swift

I have no idea how to fix this.
Realm Studio notified me of an update last night. I didn't think anything of it and updated. Since then I can not open any Realm Files inside of Realm Studio.
Realm file is currently open in another process which cannot share access with this process. All processes sharing a single file must be the same architecture.
I thought it was an issue with Realm also needing to be updated. So I updated RealmSwift from 4.4.0 to 4.4.1. That didn't work.
I found this and gave it a try: (It didn't work)
Realm browser is not opening because of another process
So I deleted the entire Core Simulator Folder and reinstalled it. That also didn't work.
I'm out of ideas on how to fix this.
Note: Realm still seems to work in the simulator. I just can't open the file into Realm Studio.
Deleting RealmStudio and redownloading and installing fixed the issue.

Replace core data model in new version of app without having previous source code

Hi I struck at core data migration issue. I have developed a app which is new version of an existing app in Appstore. But i don't have source code of previous version and don't know exactly that whether core data was used in old version or not. So how to update my app (which has core data) to Appstore without any crashes. Any quick solution please?
Since you mention in a comment that you want to ignore the old data, you don't need to do any kind of migration. Model migration is about updating existing data to work with a newer data model. The only danger would be if the old app used Core Data and your new app attempts to use a persistent store file with the same file name. Then your app would attempt to load the old data, since it would find that file with the correct name.
The easiest way to test this is:
Install the existing app (from the app store)
Use this app until you're sure it's saving some data
Install the new version from Xcode. Since it's an upgrade, it will overwrite the app store copy.
By then you'll know exactly what happens when upgrading. If you get a Core Data related crash, change your Core Data setup to use a different filename. Then delete the app from your iOS device and repeat the test from above.

The model used to open the store is incompatible with the one used to create the store Xcode 7.1

I created a core data model that was working fine until I added a new entity to the model, my code is fine I think... because Xcode can't detect any errors, but as soon as I run my app on the simulator the compiler gives me an error saying
reason=The model used to open the store is incompatible with the one used to create the store
I don't quite understand what this error means. I did search for references regarding this error but the one I found is outdated it was from Xcode 3.2, I'm currently running Xcode 7.1.1, interestingly enough there's no check mark on none of the replies. Despite that I still tried to use some of those methods and nothing has worked.
Things I tried
Resetting iOS Simulator -> Reset Contents and Settings...
Deleted the [Simulator App Folder]/Document/*.sqlite and ran the project
Have you had the same problem? If so can you help me troubleshoot it? Thanks.
That error means that you changed the model so that it doesn't match the one you were using when you created the app's data. It's the classic sign of changing a data model and not either doing model migration or deleting the app from the phone/simulator (and it's been pretty much the same as long as Core Data has existed, so old information is not irrelevant). Deleting the app from the simulator would normally be all that's needed to run the app again. If it's not working, then you're somehow leaving old data in place.
The best way to delete an app from the simulator is usually the same as you'd delete an app on a real device-- click and hold until the app icon starts moving, then click the "x" on its icon to delete it.
If deleting the app doesn't help, you're using old data some other way. Maybe you have some pre-loaded data built into the app that was configured using an old version of the model?
My favorite solution is to open the sqlite database with a third party app, then open the Z_MetaData table and delete the row found in there.
Works like a charm every time.
It may affect your 'migration' if you do migrations.
We do not, so not an issue.

How to fix crash when modifying Core Data with a new version of an app in iOS

I am struggling with an issue related to Core Data.
In my app, I use Core Data for storing and retrieving the values. In my latest version, I added some attributes to entities from the old version. I updated the app from the App Store, and when I click on the page where we need to display the contents from Core Data, it is crashing.
If the old version of the app is removed and the new one is downloaded, then it doesn't crash.
My requirement is any alternative there is to fix without having to remove the old version of the app (merging the old version with the new version).
Any suggestions on how to fix this issue?
Thanks in advance.
Did you setup versioning of core data? IF so, in your Xcode project navigator, your .xcdatamodeld should be drop down with multiple .xcdatamodeld underneath it. And then in attribute inspector with the parent .xcdatamodeld selected you pick your current version.
If the changes are minor, this will take care of it's self when you load new app version ontop of older version.
If the changes are major, you need to setup handling for this in your app delegate to tell the app how to move data between the two versions.
You have to migrate the Core Data store from the old Version to the new one.
This tutorial show's how this works: http://www.raywenderlich.com/27657/how-to-perform-a-lightweight-core-data-migration

iOS app behaviour after installing new version from app store

I have an iOS app installed in iPhone from app store, now if I have an updated version 1.1 for the same app at app store and I'm getting some sort of informative alert from the older version 1.0 (New version is available...).
If I click on alertview's ok button, it redirects me to the new app link in browser. I download my new version then.
Please provide answers of following questions :
Will it replace old version?
Will it replace sqlite and image folder on the document path? (Both version is having same named sqlite file, say abc.sqlite1.0 and same folder name, say imagesToBeCopied)
Will it append the sqlite entitie rows with new rows for same entity?
How can I install version 1.0 again from app store? Is it possible to get it anyhow?
Please provide your valuable answers on it, which can help me out to reach to some solution.
Thanks.
1.Will it replace old version?
Yes, the app bundle will be replaced by the new one
2.Will it replace sqlite and image folder on the document path? (Both version is having same named sqlite file, say abc.sqlite1.0 and same folder name, say imagesToBeCopied)
No, the documents directory is not affected by the update process. If you have procedures in your code that update the documents directory, they will still run, but without any changes it would be no different to a normal launch of your app - e.g. if you check for and copy if needed, something from the bundle to the documents directory, this will only happen if the target file doesn't already exist.
3.Will it append the sqlite entitie rows with new rows for same entity?
This is not related to the update process. If you want to modify the data as part of the update, you will write this specifically in first launch code for your new version.
4.How can I install version 1.0 again from app store? Is it possible to get it anyhow?
No, the updated version replaces the old one on the app store.
To the best of my knowledge...
Yes, the new version of the app will replace the old version.
Yes it will replace your sqlite file, assuming your paths did not change across versions. If you want to handle this sort of case it is your responsibility to include logic in the newer version of the app to check for the existence of the sqlite file and overwrite or modify it accordingly.
No, all modifications to the sqlite file need to be done manually by the new version (see #2).
As of now, not possible to do this through the app store. Only one version of any app can be placed for "sale" at a time. You would have to do this through other means (testflightapp.com for instance [for adhocs for devs]).

Resources