Highlighted

Cannot assign nil to NSMutableDictionary in Adobe AIR 29 App (iOS)

New Here ,
Aug 10, 2018

Copy link to clipboard

Copied

The company I work for makes an SDK which is wrapped by an AIR native extension.  We have one client where when they use this ANE they experience exceptions on iOS 8.x, but not on iOS 9.0 or higher.  The exception occurs when the ANE in an Objective-C layer makes the following assignment:

NSMutableDictionary *someDictionary = NSMutableDictionary.dictionary;

someDictionary["some_key"] = nil;

The exception reason is as follows:

*** setObjectForKey: object cannot be nil (key: dictionary)

Typically an assignment of nil in this fashion does not generate an exception. If nil, it would remove any key of the same name from the dictionary.  We started asking the question, how could this possibly generate an error assigning a value of nil to an NSMutableDictionary?

We discovered the following information from Apple's website:

NSMutableDictionary subscript syntax change

In OS X 10.11 and iOS 9, NSMutableDictionary now allows you to use its subscript syntax to assign nil for a key. Like Swift's Dictionary type, doing so will remove an existing object for that key from the dictionary. In effect, the following lines of code are now equivalent:

[dictionary removeObjectForKey:@"Key"];

dictionary[@"Key"] = nil;

These new semantics exist only when building with the OS X 10.11 or iOS 9 SDKs. If your application's deployment target is earlier operating system, then runtime support will be implicitly linked into your binary by Xcode to ensure the behavior works on any targeted operation system.

That information can be found here:

https://developer.apple.com/library/archive/releasenotes/Foundation/RN-FoundationOlderNotes/index.ht...

As we read it, it appears that it's not a given that this syntax will work in iOS 8.  First, the iOS SDK you are building against must be 9 or higher.  And it goes on to say that "If your application's deployment target is earlier operating system, then runtime support will be implicitly linked into your binary by Xcode to ensure the behavior works on any targeted operation system.".

We are currently speculating that this implicit runtime support may somehow not be getting implicitly linked into our client's binary. This could be because their iOS SDK is below 9. If it were, that would cause this. When we ask our client what iOS SDK they are building with, their response is that AIR SDK 29 comes with iOS SDK 11.0. They say they are not explicitly providing -platformsdk.  They say they verified the info.plist, and that the project is getting built with iOS SDK 11.0 and MinimumOSVersion is iOS 8.0. They also say the native extension they are building is with iOS 11.2 and the deployment target is iOS 8.0.

We're skeptical about whether or not the iOS SDK they are using is actually iOS 11.X.  If it were prior to iOS 9, we'd expect this issue to occur in exactly this way.  We don't see how an info.plist would be involved in the iOS SDK version, as they seem to be indicating.  When they create a test native iOS project, and put in the same test code, it works properly.  It appears that the building of the native iOS app is linking in the necessary implicit support for iOS 8.x, but the AIR build process is not.  In our own AIR test app, which we build with AIR 24, it works fine.  So there's something specifically and uniquely wrong with our client's specific AIR project, but we haven't been able to determine what.

Any thoughts anyone has about this would be appreciated.

TOPICS
Development

Views

284

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Cannot assign nil to NSMutableDictionary in Adobe AIR 29 App (iOS)

New Here ,
Aug 10, 2018

Copy link to clipboard

Copied

The company I work for makes an SDK which is wrapped by an AIR native extension.  We have one client where when they use this ANE they experience exceptions on iOS 8.x, but not on iOS 9.0 or higher.  The exception occurs when the ANE in an Objective-C layer makes the following assignment:

NSMutableDictionary *someDictionary = NSMutableDictionary.dictionary;

someDictionary["some_key"] = nil;

The exception reason is as follows:

*** setObjectForKey: object cannot be nil (key: dictionary)

Typically an assignment of nil in this fashion does not generate an exception. If nil, it would remove any key of the same name from the dictionary.  We started asking the question, how could this possibly generate an error assigning a value of nil to an NSMutableDictionary?

We discovered the following information from Apple's website:

NSMutableDictionary subscript syntax change

In OS X 10.11 and iOS 9, NSMutableDictionary now allows you to use its subscript syntax to assign nil for a key. Like Swift's Dictionary type, doing so will remove an existing object for that key from the dictionary. In effect, the following lines of code are now equivalent:

[dictionary removeObjectForKey:@"Key"];

dictionary[@"Key"] = nil;

These new semantics exist only when building with the OS X 10.11 or iOS 9 SDKs. If your application's deployment target is earlier operating system, then runtime support will be implicitly linked into your binary by Xcode to ensure the behavior works on any targeted operation system.

That information can be found here:

https://developer.apple.com/library/archive/releasenotes/Foundation/RN-FoundationOlderNotes/index.ht...

As we read it, it appears that it's not a given that this syntax will work in iOS 8.  First, the iOS SDK you are building against must be 9 or higher.  And it goes on to say that "If your application's deployment target is earlier operating system, then runtime support will be implicitly linked into your binary by Xcode to ensure the behavior works on any targeted operation system.".

We are currently speculating that this implicit runtime support may somehow not be getting implicitly linked into our client's binary. This could be because their iOS SDK is below 9. If it were, that would cause this. When we ask our client what iOS SDK they are building with, their response is that AIR SDK 29 comes with iOS SDK 11.0. They say they are not explicitly providing -platformsdk.  They say they verified the info.plist, and that the project is getting built with iOS SDK 11.0 and MinimumOSVersion is iOS 8.0. They also say the native extension they are building is with iOS 11.2 and the deployment target is iOS 8.0.

We're skeptical about whether or not the iOS SDK they are using is actually iOS 11.X.  If it were prior to iOS 9, we'd expect this issue to occur in exactly this way.  We don't see how an info.plist would be involved in the iOS SDK version, as they seem to be indicating.  When they create a test native iOS project, and put in the same test code, it works properly.  It appears that the building of the native iOS app is linking in the necessary implicit support for iOS 8.x, but the AIR build process is not.  In our own AIR test app, which we build with AIR 24, it works fine.  So there's something specifically and uniquely wrong with our client's specific AIR project, but we haven't been able to determine what.

Any thoughts anyone has about this would be appreciated.

TOPICS
Development

Views

285

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 10, 2018 0

Have something to add?

Join the conversation