Urban Airship crashes when calling takeoff

╄→гoц情女王★ 提交于 2019-12-14 03:45:09

问题


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


回答1:


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




回答2:


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




回答3:


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




回答4:


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.




回答5:


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>.



来源:https://stackoverflow.com/questions/18897103/urban-airship-crashes-when-calling-takeoff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!