0

I want to change my bundle ID (just make it lowercase) because the bundle ID I set up in App Store Connect is all lowercase, but my old bundle ID in Xcode had an uppercase letter. Changing it in Xcode is straightforward, but when I run the app on my device, it installs a duplicate app instead of replacing the old version (because the bundle IDs have different capitalization). I'm using Core Data for my data persistence, and since I've been testing the app on my own device for a while and adding data through that, I would really like to keep the data I have but migrate it to the app with the new bundle ID.

All the related questions I've found so far are concerned with only changing the bundle ID, but not with maintaining the existing data. Is there a good way to do this?

Andrew
  • 904
  • 5
  • 17
  • You should be able to just copy the data file from one app's storage to the other's. Nothing to do with the bundle ID, really. – Caleb Sep 16 '21 at 16:38
  • @Caleb I'm not sure I understand. To clarify, I'm using the same .xcdatamodel file, so setting up the Core Data model is not my issue. But I've been using my app in development and I've been adding data to it (data which is only available on my installation of my app, as it is user-specific data); this is the data that I want to be available (only to me) in my app installation with the new bundle ID. If you're saying to copy the database file from my phone and paste it into the database for the app with the updated bundle ID, can you expound on where I would find those files? Thanks! – Andrew Sep 16 '21 at 17:42
  • I'm saying copy the database file (not the data model) from the *sandbox* of the old app (not the app itself) to the sandbox of the new app. If you want your data to be distributed to all users as part of the new app, then you could include it in the app's resources and have your app install it on first run, or something, but I don't think that's what you were asking for. – Caleb Sep 16 '21 at 22:04
  • @Caleb Yeah copying the actual data is what I needed to do, I just didn't know how to do it. I followed Tom's answer and it worked great. Thanks for the help! – Andrew Sep 17 '21 at 02:30

1 Answers1

2

If you change the bundle ID, then it's a different app, as far as iOS is concerned. You have two different apps that happen to have similar bundle IDs, but they can't access each other's data any more than any two random apps can do that.

If you have not released your app, meaning it's still in development, you can copy data out of the old version and then upload it to the new version. You would use almost exactly the steps in this answer except that in your case you wouldn't delete the app until you were sure the copy was working normally. With these steps you basically copy the data from one version to your Mac, then copy it from the Mac to the other one.

If you have already shipped your app, it's more complicated. One way would be to update the app using the old ID but enable app groups. Have the update copy its data into the shared app group folder. Then enable app groups with the new ID and have it use the same shared folder. Another approach would be to have both versions sync data via some online service-- CloudKit, or Firebase, for example-- so that when the app gets the new ID it will get the new data by syncing it in.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170