Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archiving fails due to undefined Symbols for Google Analytics

I have integrated GAI using the most recent cocoapods version.

When I build in the Debug config everything runs just fine. However, as soon as I try to archive the Application the compiler fails with the following messages:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_GAIDictionaryBuilder", referenced from:
      objc-class-ref in libWLCore.a(WLTrackingHelper.o)
  "_OBJC_CLASS_$_GAI", referenced from:
      objc-class-ref in libWLCore.a(WLTrackingHelper.o)
  "_kGAIScreenName", referenced from:
      +[WLTrackingHelper trackView:] in libWLCore.a(WLTrackingHelper.o)
      +[WLTrackingHelper resetView] in libWLCore.a(WLTrackingHelper.o)
  "_kGAIAnonymizeIp", referenced from:
      +[WLTrackingHelper prepareDefaultTracker:withAnonymization:withUnCaughtExceptions:withDebug:] in libWLCore.a(WLTrackingHelper.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Since it works in Debug I tried to figure out where the difference in the configuration between Debug and Release lies. I found out that the Other linker flags in Release are empty whereas in Debug contains the flag for GoogleAnalytics and other frameworks and libraries.

After adding the flags to the Release Configuration of Other linker flags I got

library not found for -lGoogleAnalyticsServices

After that, I added libPods and after that libPods-GoogleAnalytics to the Link Binary With Libraries section but the errors remained the same.

I invested almost 2 days into that problem, but I could not find any solution.

like image 924
ff10 Avatar asked Dec 18 '13 15:12

ff10


People also ask

What is undefined symbols for architecture x86_64?

Why Is the Undefined Symbols for Architecture x86_64: Error Happening? This error is happening due to the lack of included values inside the declared statements in your code. The browser is going to render the information incorrectly and show this error, especially if you are working with Main and Similarity tools.

How do you fix undefined symbols for Architecture arm64?

Simple Solution Go to Target ->Linking -> other linker Flag and add $(inherited) in other linker flag in both Debug and Release.


2 Answers

After some fiddling I found the solution by adding not the library generated by cocoa pods (libPods-GoogleAnalytics), but directly linking the libGoogleAnalyticsServices to my main project. Still, I think this is not the most elegant solution possible since the linker should know that the symbols he was missing were available already, as provided by cocoapods.

like image 74
ff10 Avatar answered Oct 03 '22 05:10

ff10


Please confirm you have added $(inherited) to Other Linker Flags (Build Settings) as in the below image. Add the same in Release also, otherwise the same error will pop up at the time of archiving. enter image description here

like image 21
Ajith K Jose Avatar answered Oct 03 '22 04:10

Ajith K Jose