wjaakq
Last Updated: February 25, 2016
·
1.934K
· ptgoetz
423abccbed514c8464e12ae1479003a9

Enable Core Data Auto Migration in Sandbox

Core Data Automatic Migration for NSPersistentDocument requires saving in place, which won't work in a sandbox-enabled app (even with Read/Write for user selected files).

The solution is to add the following temporary entitlements:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>
    <string>/Volumes/</string>
    <key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>
    <string>/</string>
</dict>
</plist>

This allows the user to open and seamlessly migrate core data documents anywhere on the system (including mounted volumes).

After getting auto-migration working, log a bug with apple to encourage them to provide a better solution for working with Core Data in sandboxed apps:

https://bugreport.apple.com

1 Response
Add your response

5153
63cd65c79f0d13139c94215a1ea9de51

If you have more complex requirements, you might find the following helpful: http://www.codeotaku.com/journal/2012-06/sandboxing-core-data-and-migrations/index

over 1 year ago ·
Awesome Job

5b77d27c 0964 11e7 8e03 af0281f543eb
Operations Engineer
·
Amsterdam, Rotterdam, or remote
·
Full Time