magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Should use Bundle Identifier, not Bundle Name for store folder #1113

Open timothyrobb opened 8 years ago

timothyrobb commented 8 years ago

Currently, the library places the store files in the following location: <path to bundle>/Library/Application Support/<app name aka bundle name>/

According to Apple guidelines, all folders inside the Application Support directory should use the bundle identifier of your application, not the bundle name. For those that don't know/can't remember the difference, the bundle name is the name displayed on the homescreen when you app is installed. The bundle identifier is the unique identifier for your app, typically in reverse domain name format (com.example.app).

Link to guidelines: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW11

This recently messed us over when we rebranded the app. The identifier stayed the same—obviously—but the name changed. However as our test app still kept the same bundle name, the location of the DB didn't change for testing, but it did in production. We've had to pull our app down, and submitted an urgent patch release.

Note that if you change the bundle name, it expectedly can't locate the DB anymore and creates a new one.

tl;dr: The bundle name can change, the bundle id won't. Apple guidelines say to create folders in Application Support/ by the bundle id. MR should abide by these guidelines.

tonyarnold commented 8 years ago

Wow, when did this change? Historically (on OS X anyway) the recommendation was to use the application or company name (not the bundle ID).

I agree, this is definitely more future proof.

pedropalmero commented 8 years ago

It also has happened to us, that an app in production has changed its icon name and we have had to remove the app from the store until we fix it.