TouchJSON conflicts with AdMob and Cocos2d

If you happen to use Admob and cocos2d in the same project, the compilation will fail with some linking errors. Although it is not mentioned on Admod SDK documentation, apparently Admob borrows TouchJSON from touch code, so does Cocos2d.

ld: duplicate symbol .objc_category_name_NSCharacterSet_NSCharacterSet_Extensions in /AdMob/libAdMobSimulator.a(NSCharacterSet_Extensions.o) and Debug-iphonesimulator/ptap.build/Objects-normal/i386/NSCharacterSet_Extensions.o

The duplicated links could be resolved by removing it from one of the sources. Since we don’t have Admob source code, the workaround is actually to remove the TouchJSON directories from your project which are located in the cocos2d source code.

Directory and Files to be Removed as they are statically linked through admob
+TouchJSON
-CDataScanner.h
-CDataScanner.m
+Extensions
-CDataScanner_Extensions.h
-CDataScanner_Extensions.m
-NSCharacterSet_Extensions.h
-NSCharacterSet_Extensions.m
-NSDictionary_JSONExtensions.h
-NSDictionary_JSONExtensions.m
-NSScanner_Extensions.h
-NSScanner_Extensions.m
+JSON
-CJSONDeserializer.h
-CJSONDeserializer.m
-CJSONScanner.h
-CJSONScanner.m
-CJSONSerializer.h
-CJSONSerializer.m

One Comment

  1. Webtopia says:

    This is fine if you don’t need to use TouchJSON in your application.

    I needed it for the the deserializer to work for the cocoslive component of my new app Bungee Stickmen.

    So in the end I had to rename the classes and all reference to them to classcocos.

    For example CJSONScanner.h to CJSONScannerCocos.h
    CJSONSerializer.m to CJSONSerializerCocos.m

    Of course you can rename them to whatever you want.

    Hope this helps someone.

Leave a Reply