使用Cocoa Pod导入Google Analytics iOS SDK时出错

时间:2022-03-03 15:17:54

At first I imported Google Analytics iOS SDK directly and everything worked. Then I started using cocoa pods to manage all of my external libraries and getting this error.

起初我直接导入了Google Analytics iOS SDK,一切正常。然后我开始使用可可豆荚来管理我的所有外部库并获得此错误。

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_GAI", referenced from:
  objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like Cocoa Pods isn't importing required libraries?

看起来Cocoa Pods没有导入所需的库?

2 个解决方案

#1


12  

As it turned out in some cases it might be necessary to manually import library into the project. In my case I had to drop libGoogleAnalyticsServices.a into Build Phases. Just locate .a file in finder and drop it into the project.

事实证明,在某些情况下,可能需要手动将库导入项目中。在我的情况下,我不得不将libGoogleAnalyticsServices.a放入Build Phases。只需在finder中找到.a文件并将其放入项目中即可。

For more details see https://github.com/CocoaPods/CocoaPods/issues/225 and https://github.com/CocoaPods/CocoaPods/issues/844.

有关更多详细信息,请参阅https://github.com/CocoaPods/CocoaPods/issues/225和https://github.com/CocoaPods/CocoaPods/issues/844。

#2


2  

Upgrade your GoogleAnalytics sdk using pod.

使用pod升级您的GoogleAnalytics sdk。

  1. Open terminal
  2. 打开终端
  3. Go to your project directory
  4. 转到您的项目目录
  5. Write pod init
  6. 写pod init
  7. Open the podfile created in your project directory
  8. 打开在项目目录中创建的podfile
  9. Write the following lines

    写下以下几行

    platform :ios, '10.0'
    
    target “GoogleAnalyticsTestApp” do
       pod 'GoogleAnalytics'
       pod 'GoogleIDFASupport'
    end
    

This will resolve the error. From the following links you can add Google's Api:

这将解决错误。从以下链接中,您可以添加Google的Api:

1.http://cocoapods.org/pods/GoogleAnalytics

1.http://cocoapods.org/pods/GoogleAnalytics

2.http://developers.google.com/ios/guides/cocoapods

2.http://developers.google.com/ios/guides/cocoapods

#1


12  

As it turned out in some cases it might be necessary to manually import library into the project. In my case I had to drop libGoogleAnalyticsServices.a into Build Phases. Just locate .a file in finder and drop it into the project.

事实证明,在某些情况下,可能需要手动将库导入项目中。在我的情况下,我不得不将libGoogleAnalyticsServices.a放入Build Phases。只需在finder中找到.a文件并将其放入项目中即可。

For more details see https://github.com/CocoaPods/CocoaPods/issues/225 and https://github.com/CocoaPods/CocoaPods/issues/844.

有关更多详细信息,请参阅https://github.com/CocoaPods/CocoaPods/issues/225和https://github.com/CocoaPods/CocoaPods/issues/844。

#2


2  

Upgrade your GoogleAnalytics sdk using pod.

使用pod升级您的GoogleAnalytics sdk。

  1. Open terminal
  2. 打开终端
  3. Go to your project directory
  4. 转到您的项目目录
  5. Write pod init
  6. 写pod init
  7. Open the podfile created in your project directory
  8. 打开在项目目录中创建的podfile
  9. Write the following lines

    写下以下几行

    platform :ios, '10.0'
    
    target “GoogleAnalyticsTestApp” do
       pod 'GoogleAnalytics'
       pod 'GoogleIDFASupport'
    end
    

This will resolve the error. From the following links you can add Google's Api:

这将解决错误。从以下链接中,您可以添加Google的Api:

1.http://cocoapods.org/pods/GoogleAnalytics

1.http://cocoapods.org/pods/GoogleAnalytics

2.http://developers.google.com/ios/guides/cocoapods

2.http://developers.google.com/ios/guides/cocoapods