8

I know this question has been asked before, but I've tried everything I could find and none of it has worked.

I have a fully functional iOS app, that I now want to integrate AdMob Network Mediation with. I've already successfully had just AdMob working fine, but the Mediator requires the linkers '-all_load' and '-ObjC' to be set (in Other Linker Flags). Sure enough if I build without them, no ads are shown and in the logs it says it requires them to be set.

The problem is I cannot successfully build my app with either all_load or ObjC set. I read that ObjC isn't necessary for iOS apps, but even without it I still have the problem with all_load. The problem being I get this error:

ld: duplicate symbol [some command here] [some static library] and [path to same command] for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I remove the offending static library and rebuild, the error simply moves on to the next static library I have and so on. Being that I'm trying to install an ad mediator, my app requires several static libraries from different ad networks to be in place.

Here are some solutions that I've tried that have failed:

  • compiling for armv6, not armv7 (not an ideal fix anyway, as I want both)
  • replacing all_load with force_load [path to library], and testing on an actual iOS device as apparently this method own't work with a simulator regardless (this doesn't seem to do anything, I get the exact same problem, using the same path found in the error anyway)
  • removing all_load (builds but like I said, AdMob Mediation requires it)
  • removing offending libraries (obviously doesn't work because the error complains about every single one of my static libraries which I need)

Any help is appreciated in solving this issue.

EDIT: THE SOLUTION TO MY PROBLEM

As it turns out, the only thing I didn't try was only using -ObjC on an actual device, this seems to work for me!

EDIT2: NEVERMIND, STILL HAVING TROUBLE

I'll quote my comment below when asked what static libraries were causing me problems:

"Well I got AdMob Mediation working without any other networks by excluding the all_load and just including ObjC, which was working fine until I added my first network, Adfonic, which is currently conflicting with MobileAppTracking, I get: ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in [path]/Adfonic SDK/libAdfonic.a(Reachability.o) and [path]/Objects-normal/armv6/Reachability.o for architecture armv6 clang: error: linker command failed with exit code 1 (use -v to see invocation)"

I had the bare bones of Admob Mediator working by deleting all other ad network libraries, but with my first third-party network integration I'm getting another conflict between that and a tracking library I have implemented, MobileAppTracking. Still looking for a solution to solve 'duplicate symbols'.

EDIT 3

I can confirm that every single ad network I try with the AdMob Mediator (except for AdMob itself) fails to compile, most of them due to duplicate symbol errors. I don't understand how this can be, as I'm sure I'm not the only one using Admob's Mediation service.

EDIT 4

I'll quote my comment below:

"I actually managed to get most of the ad networks and libraries working for me, I had to delete quite a few references under Compile Sources, but I got it compiling none-the-less, wile still using -ObjC and -all_load!"

Paul
  • 147
  • 2
  • 8
  • Can you list out some of these static libraries that it's complaining about? I'm trying to reproduce the issue. – RajPara Apr 27 '12 at 17:12
  • Well I got AdMob Mediation working without any other networks by excluding the all_load and just including ObjC, which was working fine until I added my first network, Adfonic, which is currently conflicting with MobileAppTracking, I get: ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in [path]/Adfonic SDK/libAdfonic.a(Reachability.o) and [path]/Objects-normal/armv6/Reachability.o for architecture armv6 clang: error: linker command failed with exit code 1 (use -v to see invocation) – Paul Apr 27 '12 at 18:56
  • 1
    Still having trouble reproducing this issue, I got AdMob and AdFonic up without an error. What version of XCode and iOS are you running? Did you try just adding other networks to the AdMob example from their site? – RajPara Apr 30 '12 at 20:55
  • I tried the example, and it did work for me, and I actually managed to get most of the ad networks and libraries working for me, I had to delete quite a few references under Compile Sources, but I got it compiling none-the-less, wile still using -ObjC and -all_load! Thanks for your help. – Paul May 01 '12 at 00:23
  • How did you make it work? I don't understand what you had to delete. – Tibidabo Nov 11 '12 at 13:24

6 Answers6

2

you can use -force_load "path/to/your/libGoogleAdMobAds.a" instead of -all_load, this will load your libGoogleAdMobAds only

Zennichimaro
  • 5,236
  • 6
  • 54
  • 78
  • As I say above, I've tried this, but it didn't seem to fix anything, assuming I have the path right. If I don't use the right path, I get an error telling me the file was not found, and if I use the path that is specified in the duplicate symbols error, I don't get a file not found error, but I still get the duplicate error for that library. – Paul Apr 27 '12 at 16:21
  • Hmm, I would assume this should work, have you tried a clean? I think the path to be using is the relative path from where your XCode project lives – RajPara Apr 27 '12 at 23:20
  • I just tried a clean, and I retried the force_load method, but I still get the same problem. I get the following error with my other linkers set to '-fobjc-arc -force_load "MMSDK/libMMSDK_4.5.5.a"' (-fobjc-arc is required by a different library): ld: duplicate symbol _OBJC_METACLASS_$_SBJsonParser in [path]/Objects-normal/armv7/SBJsonParser.o and MMSDK/libMMSDK_4.5.5.a(SBJsonParser.o) for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) This is when trying to use the Mellenial SDK, but I get the same problem with others. – Paul Apr 30 '12 at 16:59
2

Please remove add-one folder in your SKD folder

user1304842
  • 159
  • 3
  • 15
1

Add a user-defined build setting with the name “EXCLUDED_SOURCE_FILE_NAMES”: as shown in this article, or modify the .a file as shown by this article.

CodaFi
  • 43,043
  • 8
  • 107
  • 153
Pedro Lorente
  • 345
  • 2
  • 10
1

Did you found how to fix that issue?

I just remove the -all_load param and my app works well on my device. But I'm not sure about this trick.

Benoît Freslon
  • 2,021
  • 4
  • 26
  • 35
0

I had the same problem. After adding -ObjC in other linkers, I could not compile (It was complaining about duplicate symbols and reachability.). Removing it would let me compile, but AdMob was crashing the app.

After a lot of testing and playing with a lot of parameters I did the following and it is now working: I went to Targets -> AppName -> Build Phases -> Compile Sources and removed Reachability.m. It compiled just fine and AdMod was also working without crashing.

zirinisp
  • 9,971
  • 5
  • 32
  • 38
  • Yes this was my problem, several 3rd party libraries were causing linker errors by adding -ObjC, the solution was to examine each linker error closely and remove a .m for each linker error that was most likely already included in another library. Sometimes it was not clear which ones to delete, but Reachability.m was one in my case. – Paul Jan 24 '13 at 23:00
0

Removing all folders in "Add-on" folder except the "mediation" folder.

It works for me.

Kit Ng
  • 993
  • 4
  • 12
  • 24