Core Data Versioning, always loading the previous version - ios

I have done lightweight versioning in my project, right now i have two versions and the current version is set to latest one(dataModel 2.xcdatamodel for example). I have followed every steps there in the apple document. But it's crashing every time because the old version is loading(found that after debugging, the new attributes are missing in the entity) after fresh installation.
If i switch back to old version and roll back to current version again then it's running fine. I have deleted the references and added it again but the result is same.
My source code is on git and its very annoying to do that extra effort every time. Please help me to solve this problem.
thanks :)

If you are 100% sure that the new version is loaded, it means that you created the new version, started the app, applied changes to the model, started the app again. To eliminate the possibility of it, just create the 3rd version based on the 2nd version and make it current active. Also make sure you have the automated lightweight migration implemented as per apple manual here
https://developer.apple.com/Library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html

I am not sure, i guess it is a git/svn problem. We had to work with different versions of Xcode from the very beginning of the project. Whenever we committed to the git, the git found a miss match of Xcode versions(for say i am working with Xcode 5.1 and my team mate working with Xcode 5.0.1, the project was initialised with Xcode 4.1) and set the current core data version to the very older one that is dataModel 1.xcdatamodel in my case. That's why the project was running fine in my side but when my team mate pulled my code from the git and tried to run in his side it crashed everytime because the version was set to older one by the git.
I got this from here. After following the instructions the problem is solved for now.
Thank you all. If you have any better solution please share.

Related

Steps to upgrade grails version from 3.0.x to 3.3.x

I am looking to upgrade my grails application(3.0.17) to version 3.3.11. Are there any steps that could be followed to upgrade it completely :
1. Should we create a new app (v3.3.11) from scratch and then move our existing app files to this new app(according to new project structure)?
2. Or we can make the upgrade changes in the existing app itself?
Please check out the official docs:
for upgrading to 3.2.x: https://docs.grails.org/3.2.0/guide/single.html#upgrading31x
for upgrading from 3.2.x to 3.3.x: https://docs.grails.org/3.3.0/guide/single.html#upgrading
Should we create a new app (v3.3.11) from scratch and then move our existing app files to this new app(according to new project
structure)?
Or we can make the upgrade changes in the existing app itself?
Either will work and if done correctly, both approaches will lead to the exact same code in the project after the upgrade. Having been involved in many many Grails upgrades over the last 13 or so years I can say that creating a new app is a big time saver for a number of reasons. Of course the "new" app code gets put in place of the old code and committed to source code control and from looking at source code history you really shouldn't be able to tell if all the files were written by hand or they were created by create-app and then potentially edited.
I hope that makes sense. Best of luck!

Is there a way to just apply changes in iOS simulator without rebuilding the whole app?

I'm asking because this is a feature of android studio and was wondering if xcode or an external thing had something similar?
Yes, there is:
https://apps.apple.com/app/injectioniii/id1380446739 or from here https://github.com/johnno1962/injectionforxcode Also, I think you can get it through Alcatraz too if you have it on your XCode
Also, another tip if you have not made any changes and just want to attach the debugger and run the app without building you can do: CMD+Control+R which will run the app instantly without building.
It's would be very useful feature for development, if the same would be possible with upcoming version.
But unfortunately, as of now, with current latest version of Xcode, it is not possible to apply source code changes without rebuilding an application.
Nice question, it deserves space in Apple Bug Reporter...

iOS Core Data auto lightweight migration sometimes fails

In the latest version of my app, I added 1 new column to an existing table. Nothing major, just a simple flag. I bumped the data model version and set it to be the active model and I've been using the automatic lightweight migration strategy successfully for the last several app updates.
A small minority of users have reported that after upgrading to the latest version of my app, they lose all their data and the app crashes any time it tries to write/read to/from CoreData. I cannot replicate the issue.
Why would auto migration work for most, but not all users?
Answer
In this specific instance, the issue ended up being that I had accidentally modified an xcdatamodel file that was several versions old without knowing it. When I released a new version of the app, there were a handful of users that had not updated for a very long time, and therefore the "most recent" version of the xcdatamodel they had was the same as the file that I accidentally changed. When migration tried to happen on their devices it choked because the version of the data model file that it wanted to base migration on had been modified.
To fix this, I had to identify what I changed in the old xcdatamodel file, undo the change, and release an app update. Once users affected by this updated to the newest version, migration worked.
Additional Information:
The only thing they all seem to have in common is they are all running iOS 6.1.3. I cannot replicate this myself. I have a device running iOS 6.1.3 but no matter how many times I do the upgrade from one version of my app to the next, it works. I've even tried skipping a couple versions and upgrading from an old one to the newest and it worked fine.
For what it's worth, I'm using the auto-migration strategy outlined in this post and it has been working fine for the last 8 or 10 app updates, including some major new things added to/removed from my CoreData model.

Does NuGet Update UI work at all?

It just baffles me that even though upddates show up in the Manage NuGet Packages UI for a solution, clicking the update button results in a process that looks like it should work and then fails at the end for no apparent reason. I always have to fall back to uninstalling by hand, removing the project references for the library, and manually deleting the reference from the project file. (Why remove does not do this I have no idea.)
My Setup:
VS2012RC - maybe this works in VS2012RTM?
NuGet v2.1 - the latest as far as I know
F# - I've only been working in F# lately, maybe the problem is specific to F#?
FSharpx.Core - this is the library I update all the time, but I have experienced it with others
At first the messages look like it is working (upgrading from 1.6.78 to 1.6.83)
Added file 'FSharpx.Core.1.6.83.nupkg' to folder 'FSharpx.Core.1.6.83'.
etc.
Successfully installed 'FSharpx.Core 1.6.83'.
'FSharpx.Core 1.6.83' already installed.
Looking for updates for 'FSharpx.Core'...
Updating 'FSharpx.Core' from version '1.6.78' to '1.6.83' in project 'DS_Benchmark'.
'packages.config' already exists. Skipping...
Successfully removed 'FSharpx.Core 1.6.78' from DS_Benchmark.
'packages.config' already exists. Skipping...
Maybe skipping 'packages.config' is the problem, since the version should be updated in that file.
Then the messages start looking bad. Just installed files start getting removed.
Removed file 'FreebaseTypeProvider.htm' to folder 'C:\Users\Jack\Documents\GitHub\DS_Benchmark\packages\FSharpx.Core.1.6.83\...
etc.
Successfully uninstalled 'FSharpx.Core 1.6.83'.
(As an aside, could NuGet please use the correct preposition for "remove" in their message?)
It's a bug in NuGet 2.1, or else a change to the F# project system in VS 2012 that breaks NuGet.
http://nuget.codeplex.com/discussions/395351
They've acknowledged the problem, and pledge to have it fixed in NuGet 2.2. In the meantime, you can help by voting for the bug, and also this other NuGet/F#/VS2012 bug.

Base SDK Missing

I get the "BASE SDK Missing" when re-opeing projects. (I got the latest build of xcode, and latest SDK installed.)
It seems to be happening when I quit a project, (not exiting xcode), and re-open the project after a while. I have tried both, with and without my iPhone plugged in. I have tried to fix the problem like described here, but it does not help for me. - It just makes it even worse! (unrecognizable SDK)
The only way I have managed to get it back to normal, is to do a manual re-boot of my mac, plugged in my phone, waited until it has checked my iPhone, and then, opened xcode. Time consuming and annoying!
Why does it happen and what is the trick to fix this?
Your recent upgrade of Xcode likely removed the earlier SDK that your project was set to use. There are a couple of solutions for the problem. The most simple solution is to always select the "Latest" SDK in your project's settings and not select a specific option. You may be uncomfortable with the idea and want to run your app on an older device but it's important you understand that all of the newer SDKs can generate code that works on older versions of iOS. There's a separate hard to remember option for setting the deploy target. (It took me a while to learn how/why to use this but it's well worth it.)
The second option is to actually find a version of the SDK that your project is set to and attempt to reinstall it. I suggest going this route only if necessary as it's not guaranteed to work in each case. Older SDKs may or may not work in later versions of Xcode (Eg. SDK 3.0 might not work in Xcode 4.3.2) due to major changes in the toolchains. Tools like gcc/gdb are deprecated in favor of llvm/lldb. Still, you may have a valid reason for using an older SDK. You may have to fix a bug that is present only when using the older toolchain or you may need to reproduce a problem that only happens with builds generated from your build server. In many of these cases it might be easier to upgrade where the problem occurs (Eg. upgrade the tools on the build server) or downgrade your dev environment. (Install an older version of Xcode.)
The reasoning behind the frustration is that Apple highly encourages rapid adoption of it's latest tools and technologies. It creates a better product as the dev community is forced to stay current and competitive while the users are forced to maintain upgrades to ensure apps continue to work. This is in contrast with the traditional model of backward compatibility allowing developers to support revision -n of a product/platform. It is also great for business since rapid adoption of the latest often encourages purchase of newer hardware and products to get the best experience. The rapid adoption ensures the more robust software along with bug fixes, enhancements make it to the majority of consumers overall increasing their penetration in the market.
You have to set your target and project's base SDK to "Latest" and not an explicit option. If you choose one explicitly it seems to break if you update xcode versions.

Resources