Undefined symbols for architecture armv7: “_OBJC_C

2019-01-17 04:56发布

问题:

I am trying to add Google Analytics in my iSO app and I am using Google Analytics latest SDK https://developers.google.com/analytics/devguides/collection/ios/v3/.

Added all required header and frameworks to my project successfully. But while running my app I am getting below errors

  1. (null): "_OBJC_CLASS_$_GGLContext", referenced from:objc-class-ref in AppDelegate.o

  2. (null): Linker command failed with exit code 1 (use -v to see invocation)

Below is the code which I am writtig in AppDelegate.m file

// Configure tracker from GoogleService-Info.plist.
NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

// Optional: configure GAI options.
GAI *gai = [GAI sharedInstance];
gai.trackUncaughtExceptions = YES;  // report uncaught exceptions
gai.logger.logLevel = kGAILogLevelVerbose;  // remove before app release

Also includes (_OBJC_CLASS_$_GIDSignInButton and _OBJC_CLASS_$_GIDSignIn) Please tell what I am missing. Thanks in advance.

回答1:

"The OPN [Debug] target overrides the OTHER_LDFLAGS build setting". This was the main issue. After adding $(inherited) in new line in other linker flags solved my issue.



回答2:

if you are using pod to install the libraries like the link suggests, make sure you check whether there are any errors when you run pod install. It could be that you have changed the OTHER_CFLAGS or OTHER_LDFLAGS in the build settings, that could lead to problem. If that's the case you probably want to add "$(inherited)" in a new line to both those flags.



回答3:

Looks like you're not linking-in one of the Google libraries; I guess Analytics.



回答4:

Try add libGGLCore.a and libGGLAnalytics.a to Link Binary with Libraries



回答5:

A small mistake and Google SDK doesn't work. I am new in CocoaPods and I didn't know, that you must add google analytics pod inside your target. Like this:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!   

target 'NAME_OF_THE_TARGET' do
  pod 'Google/Analytics'
end


回答6:

This happened to me when I set up a development target. The production target was working fine but the development kept bringing up those errors. My issue was in the pod file. At first:

target 'NAME-OF-TARGET' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for MAIN-TARGET
pod 'GoogleSignIn'
pod 'Firebase/Core'
pod 'Firebase/Database'

target 'DEV TARGET' do
    inherit! :search_paths           <----------
    # Pods for dev-target
    pod 'GoogleSignIn'
    pod 'Firebase/Core'
    pod 'Firebase/Database'
end

The line I have indicated the arrow was the issue. I changed it from inherit! :search_paths to use_frameworks! and the errors were done.