8

Upgrading to UrbanAirship 3.0.0 with Xcode 5.0, I'm getting an error when calling this code:

[UAirship takeOff:config];

The error is

+[NSJSONSerialization stringWithObject:]: unrecognized selector sent to class 0x3b2ca9fc
2013-09-19 15:02:31.981 [178:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSJSONSerialization stringWithObject:]: unrecognized selector sent to class 0x3b2ca9fc'

This doesn't seem to appear when setting the key "inProduction" to "YES" in the AirshipConfig.plist, which makes sense as calling takeOff: populates the instance of UAirShip. It seems to be due to the category NSJSONSerialization+UAAdditions.

Any help on this one? Thanks

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132

5 Answers5

16

To fix this issue, you must include "-ObjC" flag in "Other Linker Flags" found in your projects build settings.

UAirship library 3.x now makes use of Objective-C categories so this flag must be set to avoid the runtime exception.

Details on the issue can be found here:

https://developer.apple.com/library/mac/qa/qa1490/_index.html

Updated the docs:

http://docs.urbanairship.com/build/ios.html#build-settings http://docs.urbanairship.com/topic_guides/ios_migration.html#linker-flags

ralepinski
  • 1,756
  • 8
  • 15
  • Awesome, had this upgrading to 5.0.3 in XCode 6, worked fine one day and then the next it was crashing... very strange but adding the linker flag worked! – CMash Mar 25 '15 at 16:35
0

Doesn't seam to be happening with the source: https://github.com/urbanairship/ios-library

OscarVGG
  • 2,632
  • 2
  • 27
  • 34
  • I'm using the source and carefully followed the UrbanAirship's tutorial found here http://docs.urbanairship.com/build/ios.html but it doesn't solve the problem – Jason LAPIERRE Sep 20 '13 at 09:12
0

You must have included both the libraries:

  • libUAirship-3.0.0.a
  • libUAirship-iOS5-3.0.0.a

You have to use either of the library for respective iOS

Akki
  • 1
  • Actually, I've only added the library `libUAirship-iOS5-3.0.0` I'm running my app with iOS Deployment Target - iOS 5.0 and Base SDK is iOS 7.0 – Jason LAPIERRE Sep 20 '13 at 09:20
0

After looking at different solutions, it turns out that this fixes the issue:

• Download sources from https://github.com/urbanairship/ios-library directly into your App folder (don't take .zip given on their website)

• Drag & drop the Airship folder in your Project (do not use the AirshipLib one)

Don't link any of the libUAirship-3.0.0.a or libUAirship-iOS5-3.0.0.a

• Boom. It's working.

Hope it'll help some others out there looking to fix this for ages.

0

Just to add, my problem was that I added -ObjC flag to the project, and it should be added to the target settings.

Also, if that does not compile, there is another option

-Wl,-force_load,<PathToYourLib>/libUAirship-4.0.0.a    

Also should be added to the target. Fill the real path to your lib instead of <PathToYourLib>.

Lena Bru
  • 13,521
  • 11
  • 61
  • 126