Apache Cordova
  1. Apache Cordova
  2. CB-989

dyld: Symbol not found: _NSURLIsExcludedFromBackupKey

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.0
    • Fix Version/s: 2.0.0
    • Component/s: iOS
    • Labels:
      None
    • Environment:

      iOS 4.2.1, iOS 4.3, iOS 5

      Description

      Just upgraded to Cordova 1.9. When trying to run my app on iOS 4.3 & iOS 5, the application hangs with the following error:

      dyld: Symbol not found: _NSURLIsExcludedFromBackupKey

      It happens both on the simulator and an actual device running iOS 4.2.1.

      In iOS 5.1, it's working fine - both on a simulator and on an actual device.

      I suppose it's related to: https://issues.apache.org/jira/browse/CB-471

        Issue Links

          Activity

          Hide
          Shazron Abdullah added a comment -
          Show
          Shazron Abdullah added a comment - Thanks - this seems to be the exact problem with fix: http://stackoverflow.com/questions/9620651/use-nsurlisexcludedfrombackupkey-without-crashing-on-ios-5-0
          Hide
          Shazron Abdullah added a comment -

          Fix:

          if (&NSURLIsExcludedFromBackupKey) {
              // The const is available
          }
          
          Show
          Shazron Abdullah added a comment - Fix: if (&NSURLIsExcludedFromBackupKey) { // The const is available }
          Hide
          Avidan Chen added a comment -

          Thanks for commenting so fast. Where do I put the fix?

          Will it get fixed in 2.0 or will you release 1.9.1?

          Show
          Avidan Chen added a comment - Thanks for commenting so fast. Where do I put the fix? Will it get fixed in 2.0 or will you release 1.9.1?
          Hide
          Shazron Abdullah added a comment -

          Not sure. A chunk of the team is away this whole week, and 2.0 is slated for release July 20 for PhoneGap Day, so it looks like a 2.0 release. The commit will be in probably tomorrow though.

          Show
          Shazron Abdullah added a comment - Not sure. A chunk of the team is away this whole week, and 2.0 is slated for release July 20 for PhoneGap Day, so it looks like a 2.0 release. The commit will be in probably tomorrow though.
          Hide
          Frank added a comment -

          Looking forward to get this commit; I got Xcode 4.2 (Snow Leopard) cant afford Lion, so not 5.1 for me :/ and this "NSURLIsExcludedFromBackupKey" is only present in iOS 5.1

          Show
          Frank added a comment - Looking forward to get this commit; I got Xcode 4.2 (Snow Leopard) cant afford Lion, so not 5.1 for me :/ and this "NSURLIsExcludedFromBackupKey" is only present in iOS 5.1
          Hide
          Shazron Abdullah added a comment -

          I'm afraid I can't test my fix as all my machines have 5.1 SDK on them. I can run on 4.x devices and simulators of course. Will have to let you guys test it out. Based on the fix I proposed.

          Show
          Shazron Abdullah added a comment - I'm afraid I can't test my fix as all my machines have 5.1 SDK on them. I can run on 4.x devices and simulators of course. Will have to let you guys test it out. Based on the fix I proposed.
          Hide
          Shazron Abdullah added a comment -

          Actually that will still fail because it checks all constants during runtime - the correct fix is to add:

          extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
          
          Show
          Shazron Abdullah added a comment - Actually that will still fail because it checks all constants during runtime - the correct fix is to add: extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
          Hide
          Shazron Abdullah added a comment -

          Fix commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/5cf71629

          Workaround if you are compiling from source: add the line from the commit in the same location

          Show
          Shazron Abdullah added a comment - Fix commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/5cf71629 Workaround if you are compiling from source: add the line from the commit in the same location
          Hide
          paul apfrod added a comment -

          the fix didn't work for me. I stopped getting the error by changing:

          ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue]] forKey: NSURLIsExcludedFromBackupKey error:&error];

          to:

          ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue]] forKey: @"NSURLIsExcludedFromBackupKey" error:&error];

          but I don't know how to verify if the attribute is now set correctly.

          Show
          paul apfrod added a comment - the fix didn't work for me. I stopped getting the error by changing: ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue] ] forKey: NSURLIsExcludedFromBackupKey error:&error]; to: ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue] ] forKey: @"NSURLIsExcludedFromBackupKey" error:&error]; but I don't know how to verify if the attribute is now set correctly.
          Hide
          Shazron Abdullah added a comment -

          Drat. I can't definitely fix this until I get back from vacation next week and install a Snow Leopard system with iOS 5.0 SDK. Try @paul afrod's workaround for now - which is not ideal since it may break (unlikely, but who knows) in a future iOS version.

          Show
          Shazron Abdullah added a comment - Drat. I can't definitely fix this until I get back from vacation next week and install a Snow Leopard system with iOS 5.0 SDK. Try @paul afrod's workaround for now - which is not ideal since it may break (unlikely, but who knows) in a future iOS version.
          Hide
          Shazron Abdullah added a comment -

          Re-opening.

          Show
          Shazron Abdullah added a comment - Re-opening.
          Hide
          Andrew Grieve added a comment -

          Thought it worth mentioning that I can repro this error using XCode 4.3.2 and the 5.1 sdk by using the 4.3 simulator.

          Steps:
          -Run bin/create to create example project
          -Run it in 4.3 simulator (builds fine, but has the error on start-up).

          If I change the project by removing Cordova.framework, add in CordovaLib as a sub-project and link against its static library target, then I cannot reproduce the error. So, it seems that it has something to do with using the lipo'ed cordova lib instead of using the static library directly.

          Show
          Andrew Grieve added a comment - Thought it worth mentioning that I can repro this error using XCode 4.3.2 and the 5.1 sdk by using the 4.3 simulator. Steps: -Run bin/create to create example project -Run it in 4.3 simulator (builds fine, but has the error on start-up). If I change the project by removing Cordova.framework, add in CordovaLib as a sub-project and link against its static library target, then I cannot reproduce the error. So, it seems that it has something to do with using the lipo'ed cordova lib instead of using the static library directly.
          Hide
          Olivier Louvignes added a comment -

          Have anyone found the correct patch for this? Does Paul method works? A 1.9.1 (even private) would really be appreciated as all my cordova project relies on the framework binaries...

          Show
          Olivier Louvignes added a comment - Have anyone found the correct patch for this? Does Paul method works? A 1.9.1 (even private) would really be appreciated as all my cordova project relies on the framework binaries...
          Hide
          Olivier Louvignes added a comment - - edited

          I was not able to reproduce the bug on XCode 4.3.2 & 5.1sdk/4.3simulator compiling from source. Is this normal?
          (I'm using a template cordova project converted to build CordovaLib to test this, should I need some specific javascript code to make it crash? Like LocalStorage.setItem()...?)

          Show
          Olivier Louvignes added a comment - - edited I was not able to reproduce the bug on XCode 4.3.2 & 5.1sdk/4.3simulator compiling from source. Is this normal? (I'm using a template cordova project converted to build CordovaLib to test this, should I need some specific javascript code to make it crash? Like LocalStorage.setItem()...?)
          Hide
          Quinn C. Hoyer added a comment -

          Just want to verify that Cordova 1.9.0 is completely broken for all iOS versions except 5.1???

          Show
          Quinn C. Hoyer added a comment - Just want to verify that Cordova 1.9.0 is completely broken for all iOS versions except 5.1???
          Hide
          Frank added a comment -

          @Quinn You're correct. User PetyrVeliki at google groups offered a solution (https://groups.google.com/forum/?fromgroups#!topic/phonegap/1KePUPYywEk) it worked for me even thou I don't know if it is the right fix as Shazron mentioned. Still waiting for 1.9.1 or 2.0

          Show
          Frank added a comment - @Quinn You're correct. User PetyrVeliki at google groups offered a solution ( https://groups.google.com/forum/?fromgroups#!topic/phonegap/1KePUPYywEk ) it worked for me even thou I don't know if it is the right fix as Shazron mentioned. Still waiting for 1.9.1 or 2.0
          Hide
          Olivier Louvignes added a comment -

          There seems to be a more elegant/correct fix there : https://gist.github.com/1999985
          Only had the bug when using devices < 5.1 in release mode.

          Show
          Olivier Louvignes added a comment - There seems to be a more elegant/correct fix there : https://gist.github.com/1999985 Only had the bug when using devices < 5.1 in release mode.
          Hide
          Shazron Abdullah added a comment -

          @Olivier that will work if you compile using iOS 5.1 SDK with older targets. I mentioned in one of my previous comments this will not work if you compile with the iOS 5.01 SDK (Snow Leopard Xcode 4.2).

          I have a Snow Leopard system set up and will be testing, will let all of you know the results. Most likely it will be an iOS only tag for this fix.

          Show
          Shazron Abdullah added a comment - @Olivier that will work if you compile using iOS 5.1 SDK with older targets. I mentioned in one of my previous comments this will not work if you compile with the iOS 5.01 SDK (Snow Leopard Xcode 4.2). I have a Snow Leopard system set up and will be testing, will let all of you know the results. Most likely it will be an iOS only tag for this fix.
          Hide
          Shazron Abdullah added a comment -

          Well, bad news on SL. Adding that extern fixes compile time error, but at link time it still errors:
          Undefined symbols for architecture i386:
          "_NSURLIsExcludedFromBackupKey", referenced from:
          -[CDVFile setMetadata:withDict:] in libCordova.a(CDVFile.o)
          ld: symbol(s) not found for architecture i386

          We'll need to do a pre-processor macro to include the definition if it's not on iOS 5.1 or greater.

          Show
          Shazron Abdullah added a comment - Well, bad news on SL. Adding that extern fixes compile time error, but at link time it still errors: Undefined symbols for architecture i386: "_NSURLIsExcludedFromBackupKey", referenced from: - [CDVFile setMetadata:withDict:] in libCordova.a(CDVFile.o) ld: symbol(s) not found for architecture i386 We'll need to do a pre-processor macro to include the definition if it's not on iOS 5.1 or greater.
          Hide
          Shazron Abdullah added a comment -

          I've successfully tested this fix below on iOS 5.0 (using SL and Xcode 4.2) and iOS 5.1 (Xcode 4.3.3). Basically it adds the definition of the constant only if is compiled on iOS < 5.1 (even though it is unused. This is to satisfy the linker)

          extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
          
          #ifndef __IPHONE_5_1
              NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
          #endif
          
          
          Show
          Shazron Abdullah added a comment - I've successfully tested this fix below on iOS 5.0 (using SL and Xcode 4.2) and iOS 5.1 (Xcode 4.3.3). Basically it adds the definition of the constant only if is compiled on iOS < 5.1 (even though it is unused. This is to satisfy the linker) extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)); #ifndef __IPHONE_5_1 NSString * const NSURLIsExcludedFromBackupKey = @ "NSURLIsExcludedFromBackupKey" ; #endif
          Show
          Shazron Abdullah added a comment - Fix commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/a12f6c9c
          Hide
          Olivier Louvignes added a comment -

          After pulling your latest commit, I still got the error on an iPad1 5.0.1 device (only with & release archive -> export ad hoc -> drag & drop on device).

          Show
          Olivier Louvignes added a comment - After pulling your latest commit, I still got the error on an iPad1 5.0.1 device (only with & release archive -> export ad hoc -> drag & drop on device).
          Hide
          Olivier Louvignes added a comment -

          Tried this uncommented in my AppDelegate (aside your existing patch in CDVFile to make sure) :

          //extern NSString * const NSURLIsExcludedFromBackupKey _attribute_((weak_import));
          //#ifndef __IPHONE_5_1
          NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
          //#endif

          and it crashed until i commented out your patch.

          Show
          Olivier Louvignes added a comment - Tried this uncommented in my AppDelegate (aside your existing patch in CDVFile to make sure) : //extern NSString * const NSURLIsExcludedFromBackupKey _ attribute _((weak_import)); //#ifndef __IPHONE_5_1 NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey"; //#endif and it crashed until i commented out your patch.
          Hide
          Shazron Abdullah added a comment -

          I don't have an iOS 5.01 device. I can only test on a Simulator 5.0 and it didn't crash when I ran the unit tests and called setMetadata on it. Try taking out the extern line only and re-test if you can.

          Show
          Shazron Abdullah added a comment - I don't have an iOS 5.01 device. I can only test on a Simulator 5.0 and it didn't crash when I ran the unit tests and called setMetadata on it. Try taking out the extern line only and re-test if you can.
          Hide
          Olivier Louvignes added a comment -

          Same error with :

          //extern NSString * const NSURLIsExcludedFromBackupKey _attribute_((weak_import));
          #ifndef __IPHONE_5_1
          NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
          #endif

          in my AppDelegate.m

          Looks like __IPHONE_5_1 is defined on this device...! Anything else I could try?

          – Crash :

          Incident Identifier: BE27EBC6-BEF6-4BA5-A911-1006E4EE50F4
          CrashReporter Key: 27779d947ecf4392cc7e1c208f8c6f871a377abf
          Hardware Model: iPad1,1
          Process: Beelink [1265]
          Path: /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink
          Identifier: Beelink
          Version: ??? (???)
          Code Type: ARM (Native)
          Parent Process: launchd [1]

          Date/Time: 2012-07-11 08:54:12.914 +0200
          OS Version: iPhone OS 5.0.1 (9A405)
          Report Version: 104

          Exception Type: EXC_BREAKPOINT (SIGTRAP)
          Exception Codes: 0x00000001, 0xe7ffdefe
          Crashed Thread: 0

          Dyld Error Message:
          Symbol not found: _NSURLIsExcludedFromBackupKey
          Referenced from: /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink
          Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
          in /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink
          Dyld Version: 199.5

          Show
          Olivier Louvignes added a comment - Same error with : //extern NSString * const NSURLIsExcludedFromBackupKey _ attribute _((weak_import)); #ifndef __IPHONE_5_1 NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey"; #endif in my AppDelegate.m Looks like __IPHONE_5_1 is defined on this device...! Anything else I could try? – Crash : Incident Identifier: BE27EBC6-BEF6-4BA5-A911-1006E4EE50F4 CrashReporter Key: 27779d947ecf4392cc7e1c208f8c6f871a377abf Hardware Model: iPad1,1 Process: Beelink [1265] Path: /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink Identifier: Beelink Version: ??? (???) Code Type: ARM (Native) Parent Process: launchd [1] Date/Time: 2012-07-11 08:54:12.914 +0200 OS Version: iPhone OS 5.0.1 (9A405) Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x00000001, 0xe7ffdefe Crashed Thread: 0 Dyld Error Message: Symbol not found: _NSURLIsExcludedFromBackupKey Referenced from: /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /var/mobile/Applications/36BCD3D2-3542-4082-991C-820B83628D3E/Beelink.app/Beelink Dyld Version: 199.5
          Show
          Saurabh added a comment - Seems that workaround mentioned here http://stackoverflow.com/questions/11328375/crashing-of-phonegap-1-9-0-application-due-to-nsurlisexcludedfrombackupkey-erro will work
          Hide
          Olivier Louvignes added a comment -

          That's what I use so far. Shazron what would be the impact of using such a fix? Would it be similar to pre-1.9 setup? Could it affect 5.1 localStorage backup in some way?

          Show
          Olivier Louvignes added a comment - That's what I use so far. Shazron what would be the impact of using such a fix? Would it be similar to pre-1.9 setup? Could it affect 5.1 localStorage backup in some way?
          Hide
          Shazron Abdullah added a comment -

          @Saurabh that's my solution as well. as you can see Olivier is having problems with it.

          @Olivier Just to be clear - you are compiling on iOS 5.1 SDK but deploying to a iOS 5.0.1 device?
          Try just defining the const without the #preprocessor macro conditional..

          Show
          Shazron Abdullah added a comment - @Saurabh that's my solution as well. as you can see Olivier is having problems with it. @Olivier Just to be clear - you are compiling on iOS 5.1 SDK but deploying to a iOS 5.0.1 device? Try just defining the const without the #preprocessor macro conditional..
          Hide
          Olivier Louvignes added a comment - - edited

          That's it, 5.1 SDK to 5.0.1 device, it only crashes when I use an archived binary (not running through XCode).

          Currently this is what I use in my AppDelegate (only the const) :

          //extern NSString * const NSURLIsExcludedFromBackupKey _attribute_((weak_import));
          //#ifndef __IPHONE_5_1
          NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
          //#endif

          And it do work well, just not sure of the implication of it.

          the extern way does not help, & the preprocessor macro does not match my device.
          could not it be possible to handle this at runtime ? (Check if the constant exists before using it?)

          Show
          Olivier Louvignes added a comment - - edited That's it, 5.1 SDK to 5.0.1 device, it only crashes when I use an archived binary (not running through XCode). Currently this is what I use in my AppDelegate (only the const) : //extern NSString * const NSURLIsExcludedFromBackupKey _ attribute _((weak_import)); //#ifndef __IPHONE_5_1 NSString * const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey"; //#endif And it do work well, just not sure of the implication of it. the extern way does not help, & the preprocessor macro does not match my device. could not it be possible to handle this at runtime ? (Check if the constant exists before using it?)
          Hide
          Olivier Louvignes added a comment -

          Some more info on this thread : https://github.com/ShareKit/ShareKit/pull/394
          There is something about setting optional the CoreFoundation framework that I'll try.

          Show
          Olivier Louvignes added a comment - Some more info on this thread : https://github.com/ShareKit/ShareKit/pull/394 There is something about setting optional the CoreFoundation framework that I'll try.
          Hide
          Olivier Louvignes added a comment -

          Ok I can confirm that adding the CoreFoundation and making it optional fixes my issue. So i'll go for that instead of forcing the const to a static value.

          Show
          Olivier Louvignes added a comment - Ok I can confirm that adding the CoreFoundation and making it optional fixes my issue. So i'll go for that instead of forcing the const to a static value.
          Hide
          Shazron Abdullah added a comment -

          @Olivier thanks for testing. No, it can't be handled at runtime unfortunately.

          The correct fix (with archived builds as well) as the ShareKit guys mentioned is:
          1. Add the extern
          2. Weak-link CoreFoundation in your app

          This will be what I will change it to, and test.

          Show
          Shazron Abdullah added a comment - @Olivier thanks for testing. No, it can't be handled at runtime unfortunately. The correct fix (with archived builds as well) as the ShareKit guys mentioned is: 1. Add the extern 2. Weak-link CoreFoundation in your app This will be what I will change it to, and test.
          Hide
          Shazron Abdullah added a comment -

          Added documentation issue CB-1030

          Show
          Shazron Abdullah added a comment - Added documentation issue CB-1030
          Hide
          Shazron Abdullah added a comment -

          Going to leave the fix as is, since it contains the extern already. The #ifndef macro is left in, for people linking under Xcode 4.2 Snow Leopard (iOS 5.0).

          You will need to still weak link the CoreFoundation framework. EITHER:
          1. Modify it in the Xcode 4 UI: http://stackoverflow.com/questions/6480765/how-do-i-weak-link-frameworks-on-xcode-4
          OR
          2. Add to your project Target's "Other Linker Flags" --> -weak_framework CoreFoundation

          Show
          Shazron Abdullah added a comment - Going to leave the fix as is, since it contains the extern already. The #ifndef macro is left in, for people linking under Xcode 4.2 Snow Leopard (iOS 5.0). You will need to still weak link the CoreFoundation framework. EITHER: 1. Modify it in the Xcode 4 UI: http://stackoverflow.com/questions/6480765/how-do-i-weak-link-frameworks-on-xcode-4 OR 2. Add to your project Target's "Other Linker Flags" --> -weak_framework CoreFoundation
          Hide
          Quinn C. Hoyer added a comment -

          You should add this to your Upgrade Guide for iOS.

          Show
          Quinn C. Hoyer added a comment - You should add this to your Upgrade Guide for iOS.
          Hide
          Shazron Abdullah added a comment -

          Thanks! Filed CB-1248

          Show
          Shazron Abdullah added a comment - Thanks! Filed CB-1248

            People

            • Assignee:
              Shazron Abdullah
              Reporter:
              Avidan Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development