суботу, 30 березня 2013 р.

dyld: Symbol not found: _NSURLIsExcludedFromBackupKey

Получил такую ошибку при попытки запуска проекта на iOS 5.0 Simulator.
Погуглив, выяснилось в основном такая проблема возникает у тех, кто реально использует этот символ.
Предлагается следующее решение:

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
    const char* filePath = [[URL path] fileSystemRepresentation];
    const char* attrName = "com.apple.MobileBackup";
    if (&NSURLIsExcludedFromBackupKey == nil) {
        // iOS 5.0.1 and lower
        u_int8_t attrValue = 1;
        int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
        return result == 0;
    } else {
        // First try and remove the extended attribute if it is present
        int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
        if (result != -1) {
            // The attribute exists, we need to remove it
            int removeResult = removexattr(filePath, attrName, 0);
            if (removeResult == 0) {
                NSLog(@"Removed extended attribute on file %@", URL);
            }
        }
        
        // Set the new key
        return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
    }
}

Но в моем проекте он совершенно не использовался и в подключенных фреймворках тоже.
Решение как всегда неочевидное но очень простое — подключить CoreFoundation.framework и сделать его Optional.

Немає коментарів:

Дописати коментар

HyperComments for Blogger

comments powered by HyperComments