0

Creating an Adobe AIR Native Extension that uses the following objC code will crash in iOS 5.1

NSDictionary *value=[NSDictionary dictionaryWithObjectsAndKeys: @"aSampleValue",@"aSampleKey",nil];    
NSLog(@"Try objectForKeyedSubscript: %@", [value objectForKeyedSubscript:@"aSampleKey"]);

It will fail with "[__NSCFDictionary objectForKeyedSubscript:]: unrecognized selector"

I've got it working right now using Method Swizzling to remap NSDictionary objectForKeyedSubscript: to valueForKey: (if it doesn't exist) but I'm not super happy with that workaround. There's got to be a platform.xml option or compiler flag that will not strip these function calls in iOS 5.1 but I can't find anything. My

Note: This problem might look a lot like the following (and a few others, but I don't have the rep for the links) but it's not because a native xCode project works fine, but an ANE compiled with ADT does not.

Things tried and failed:


SPECS

FlashBuilder/AIR: SDK3.7 ADT -version: 3.7.0.1530

xCode project BaseSDK: 6.1 (latest) Valid Architectures: armv7 armv7s Deployment Target: iOS 5.1

Platform.XML (it's pretty long since it has some other support requirements)

<platform xmlns="http://ns.adobe.com/air/extension/3.7">
    <linkerOptions>
    <option>-ObjC</option>
    <option>-weak_framework Accounts</option>
    <option>-framework AddressBook</option>
    <option>-framework AddressBookUI</option>
    <option>-weak_framework AdSupport</option>
    <option>-framework CoreLocation</option>
    <option>-framework CoreMotion</option>
    <option>-framework CoreTelephony</option>
    <option>-framework EventKit</option>
    <option>-framework EventKitUI</option>
    <option>-framework iAd</option>
    <option>-framework MapKit</option>
    <option>-framework MediaPlayer</option>
    <option>-framework MessageUI</option>
    <option>-framework OpenAL</option>
    <option>-weak_framework PassKit</option>
    <option>-framework StoreKit</option>
    <option>-weak_framework Twitter</option>
    <option>-framework UIKit</option>
    <option>-lsqlite3</option>
    <option>-lxml2</option>
    <option>-lz</option>
    </linkerOptions>
</platform>

ADT Build Command:

adt -package -target ane build/MyANEName.ane  ANE/extension.xml -swc ANE/MyANEName.swc -platform iPhone-ARM -platformoptions ANE/platform.xml -C ANE/ios .
Community
  • 1
  • 1
  • I'm confused. Are the first two lines code that *you* wrote. If so then just use `objectForKey:` instead. – borrrden May 25 '13 at 02:26
  • There's code that I don't control that uses objectForKeyedSubscript causing the issue. You're right though, if it was all my code it would t be a big deal. – Matt Cardoza Jun 01 '13 at 21:17

1 Answers1

0

I had this same issue, I solved it by using the -platformsdk option for ADT and pointing it to the iOS 6.1 SDK

On OSX this is located here:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk

So add this to your ADT command:

-platformsdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
nhahtdh
  • 55,989
  • 15
  • 126
  • 162