简体   繁体   中英

Xcode not copying resource to octests bundle

WTF? Xcode 4.6.2 is refusing to copy one of my resource files to the octest bundle.

These line, from the build log, work :

CpResource AppName/Resources/Domain.sqlite /Users/colin/Library/Developer/Xcode/DerivedData/AppName-WS-dbpjomrlampddifnmkfrqcashprt/Build/Products/Debug-iphonesimulator/AppName.app/Domain.sqlite
cd "/Users/colin/Documents/work/daring plan/AppName"
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks "/Users/colin/Documents/work/daring plan/AppName/AppName/Resources/Domain.sqlite" /Users/colin/Library/Developer/Xcode/DerivedData/AppName-WS-dbpjomrlampddifnmkfrqcawhprt/Build/Products/Debug-iphonesimulator/AppName.app

But these lines, from later in the same build log , silently result in nothing being copied:

CpResource AppName/Resources/Domain.sqlite /Users/colin/Library/Developer/Xcode/DerivedData/AppName-WS-dbpjomrlampddifnmkfrqcashprt/Build/Products/Debug-iphonesimulator/AppNameLogicTests.octest/Domain.sqlite
cd "/Users/colin/Documents/work/daring plan/AppName"
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks "/Users/colin/Documents/work/daring plan/AppName/AppName/Resources/Domain.sqlite" /Users/colin/Library/Developer/Xcode/DerivedData/AppName-WS-dbpjomrlampddifnmkfrqcawhprt/Build/Products/Debug-iphonesimulator/AppNameLogicTests.octest

These are both generated by what look to me to be identical Copy Bundle Resources configurations in the App and LogicTests targets. I've tried deleting and recreating the line for Domain.sqlite in the LogicTests target, but didn't help.

I have tried deleting both the app and octest bundles from Build/Products/Debug-iphonesimulator, and Xcode goes ahead and recreates them, but with Domain.sqlite missing from the octest bundle. WTF.

Okay, tracked it down. Xcode was copying the file just fine, but it was out of sync with my data model (I thought I'd rebuilt it, but been deceived). And I am using a 3rd-party library called MagicalRecord to manage the core data stack, and apparently in a recent version it added a property called shouldDeleteStoreOnModelMismatch. When I look back farther in my build log, there it is:

-[NSPersistentStoreCoordinator(MagicalRecord) MR_addSqliteStoreNamed:withOptions:](0x17e24f0) Removed incompatible model version: Domain.sqlite

Moral of the story: when you're distributing a pre-built sqlite file with your app, you want

[MagicalRecord setShouldDeleteStoreOnModelMismatch:false];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM