Bundle Identifier Changed Core Data Lost

389 views Asked by At

I changed a project from Objective-C to Swift and created a whole new project when I did this. I have an app in the AppStore and wanted to send an update instead of releasing a new app.

I understand that my Bundle Identifier needs to be the same when updating an app. When preparing the app for release, I changed my Bundle Identifier to match my app in the AppStore - since I started with a new project - and in the process my Core Data file seems to be missing. If I change my Bundle Identifier how do I keep access to Core Data?

1

There are 1 answers

2
jonthornham On BEST ANSWER

This took me a while to figure out but here is how I fixed the issue.

  1. Change your product name under Build Settings -> Packaging -> Product Name to the desired product name. This will change you Bundle Identifier to the desired name.

enter image description here

enter image description here

  1. Clean your project by selecting Product -> Clean.

  2. Select your CoreData model in the project navigator and then select the "Data Model Inspector" in the Inspector tab. Change the project name under class to the new class name. I got stuck here since I did not know Spaces, dashes, . are all replaced by underscores. You can see that my Product Name is FLO-Cycling and the CoreData class is FLO_Cycling.

enter image description here

enter image description here

  1. If you have imported the Swift bridging header file anywhere make sure to update it.

enter image description here

I hope this can help someone.

Take care,

Jon