Search code examples
xcodemacoscocoasandbox

Migration to sandbox not happening


I am sandboxing an existing application, and for some reasons the migration does not seem to work, although I am following exactly what is specified in the documentation. In summary, here is what I am doing:

  1. I have removed the existing container (in ~/Library/Containers/com.mycompany.myapp);
  2. I have created the container-migration.plist in the Resources group;
  3. I want to migrate a single file, in ~/Application Support: I have tried to specify the file, and the enclosing folder, neither worked. Here is the migration plist that I am using (I have just changed the application name), with the folder:

    <?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>Move</key>
            <array>
                <string>${ApplicationSupport}/myapp</string>
            </array>
        </dict>
    </plist>
    
  4. When I start the application, the new container is created, and a blank file is created but no migration is performed.

The file that I am trying to migrate is a CoreData SQLite store. The data model has not changed so there is no data migration involved, I am simply trying to move the CoreData store to the sandboxed container.

I guess I am missing something very obvious, as I can't find anything useful around, any help will be much appreciated.


Solution

  • Just after posting the question I noticed this error in the system log:

    13/11/2012 4:59:59.026 PM sandboxd[55845]: ([55835]) myapp(55835) deny file-read-data /Volumes/Mac_HD/Users/me/Library/Developer/Xcode/DerivedData/myapp-hfgnivbvxutfvcxjmyntrenofdsh/Build/Products/Debug no receipt verif
    

    I tried to copy the application to my Desktop before running it, and from there it works correctly. I do not understand why from the build folder the migration does not work, but this is sufficient to solve my problem.

    Hopefully this will avoid somebody else to waste their time.