The check for availability seems to be working fine but I can’t seem to set the NSURLIsExcludedFromBackupKey key without getting this crash on launch:
dyld: Symbol not found: _NSURLIsExcludedFromBackupKey Referenced from:
/Users/sam/Library/Application Support/iPhone
Simulator/5.0/Applications/B0872A19-3230-481C-B5CE-D4BDE264FBDF/Transit.app/Transit
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Foundation
in /Users/sam/Library/Application Support/iPhone
Simulator/5.0/Applications/B0872A19-3230-481C-B5CE-D4BDE264FBDF/Transit.app/Transit
Here’s my method:
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
if (&NSURLIsExcludedFromBackupKey == nil)
return NO;
NSError *error;
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
return (error != nil);
}
Crash goes away if I comment out this line:
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
Do I have to weak-link Foundation?
EDIT: not sure if it makes a difference, but this method is put inside an NSFileManager category.
This seems to be a bug with the iPhone 5.0 Simulator. I tried running the code on a 5.0 device and no crash. Reported this bug as rdar://11017158.
EDIT: this has been fixed in Xcode 4.5 DP2 (not sure if it is in 4.4).