ios 无法将 GoogleAnalytics 3.01 与 XCode 5 链接(缺少所需的架构 x86_64)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18934043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:31:04  来源:igfitidea点击:

Unable to link GoogleAnalytics 3.01 with XCode 5 (missing required architecture x86_64)

iosxcodecocoa-touchgoogle-analyticslinker-errors

提问by casparjespersen

I have built my App (targeted for iOS7) and now want to apply Google Analytics as the last step before submission. What I did:

我已经构建了我的应用程序(针对 iOS7),现在想应用 Google Analytics 作为提交前的最后一步。我做了什么:

  1. Downloaded GA for iOS 3.01
  2. Imported contentof /GoogleAnalytics/Library/into group "GoogleAnalytics"
  3. Imported libGoogleAnalyticsServices.ainto group "GoogleAnalytics"
  4. Added Build Phasesand swapped build phase libGoogleAnalytics_debug.awith libGoogleAnalyticsServices.a
  5. Added code block #include "GAI.h"to my -Prefix.pch-file.
  6. Initialize the [GAI sharedInstance]in my AppDelegate.
  1. 已下载适用于 iOS 3.01 的 GA
  2. 进口量/GoogleAnalytics/Library/成组“Google分析”
  3. 导入libGoogleAnalyticsServices.a组“GoogleAnalytics”
  4. 增加了构建阶段和构建交换阶段libGoogleAnalytics_debug.alibGoogleAnalyticsServices.a
  5. 将代码块添加#include "GAI.h"到我的-Prefix.pch-file。
  6. 初始化[GAI sharedInstance]我的AppDelegate

I have attached screenshots of the setup in the bottom of this post. When I try to build (either device or simulator, both 32bit), I get the following linker errors:

我在这篇文章的底部附上了设置的屏幕截图。当我尝试构建(设备或模拟器,均为 32 位)时,出现以下链接器错误:

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

How do I solve this?

我该如何解决这个问题?

UPDATE 1

更新 1

I also get the warning

我也收到警告

ld: warning: ignoring file .../libGoogleAnalyticsServices.a, missing required architecture x86_64 in file .../libGoogleAnalyticsServices.a (3 slices)
ld: warning: ignoring file .../SDWebImage.framework/SDWebImage, missing required architecture x86_64 in file .../SDWebImage.framework/SDWebImage (3 slices)

UPDATE 2

更新 2

This error only occurs when building for 64bit. I had accidentally set "Build Only for active architectures" to NO, when this changed to YES, I was able to build yet again. This means that the App now does NOT work on iPhone 5S - which is still a problem.

此错误仅在为 64 位构建时发生。我不小心将“仅针对活动架构构建”设置为 NO,当它更改为 YES 时,我能够再次构建。这意味着该应用程序现在无法在 iPhone 5S 上运行 - 这仍然是一个问题。

回答by Ryan Romanchuk

You're not doing anything wrong. I'm pretty sure google has not yet provided a arm64 version of their libGoogleAnalyticsServices.a, which is really annoying ...it has been weeks since the public the release of Xcode 5GM.

你没有做错任何事。我很确定谷歌还没有提供他们的 libGoogleAnalyticsServices.a 的 arm64 版本,这真的很烦人……自从 Xcode 5GM 公开发布已经有几周了。

For now, I guess only build for armv7, armv7s or remove google analytics until they get their head out of their pants.

目前,我想只为 armv7、armv7s 构建或删除谷歌分析,直到他们从他们的裤子中脱身。

UDATE:Finally fixed https://developers.google.com/analytics/devguides/collection/ios/resources

UDATE:终于修复了https://developers.google.com/analytics/devguides/collection/ios/resources

回答by pabloverd

Select this option in the Architecture section in "Build Settings" and your code will run on iPhone 5S, I had the same trouble.

在“构建设置”的“架构”部分中选择此选项,您的代码将在 iPhone 5S 上运行,我遇到了同样的问题。

Build Settings

构建设置

回答by Ali

Good news everyone, fixed by the 3.03 release:

大家好消息,由 3.03 版本修复:

64-bit support is now available in v3.03 of the Google Analytics Services SDK for iOS. (Source)

64 位支持现已在适用于 iOS 的 Google Analytics Services SDK v3.03 中提供。(来源

回答by Petro Korienev

I see on first screenshot that your project has 2 targets. Are you sure that libGoogleAnalyticsServices.a added to both targets? Linked frameworks may differ from target to target, so it's most common error this way... Also try remove GA from project, then Clean, then Clean Build Folder, then restart Xcode and add GA again =) Yesterday this helped me =)

我在第一个屏幕截图上看到您的项目有 2 个目标。您确定将 libGoogleAnalyticsServices.a 添加到两个目标中吗?链接的框架可能因目标而异,因此这是最常见的错误...还尝试从项目中删除 GA,然后清理,然后清理构建文件夹,然后重新启动 Xcode 并再次添加 GA =) 昨天这对我有帮助 =)