Google Maps SDK 的 Xcode 7 链接器问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31642014/
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-09-15 07:33:10  来源:igfitidea点击:

Xcode 7 linker issue with Google Maps SDK

iosxcodegoogle-mapsgoogle-maps-sdk-iosxcode7-beta4

提问by KPath001

I just downloaded Xcode 7 beta 4 and am trying to build my Swift 2.0 application but I am getting the following error which I can't figure out the solution to:

我刚刚下载了 Xcode 7 beta 4 并正在尝试构建我的 Swift 2.0 应用程序,但出现以下错误,我无法找出解决方案:

ld: warning: -weak_framework is treated as -framework when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES). Weak linking may still happen based on availability mark-up in headers ld: 'path/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps(GMSBillingPointRecorder.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld:警告:-weak_framework 与 -bitcode_bundle 一起使用时被视为 -framework(Xcode 设置 ENABLE_BITCODE=YES)。基于标头 ld 中的可用性标记,可能仍会发生弱链接:“path/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps(GMSBillingPointRecorder.o)”不包含位码。您必须在启用位码的情况下重建它(Xcode 设置 ENABLE_BITCODE),从供应商处获取更新的库,或为此目标禁用位码。对于架构 arm64 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

Does anyone know how to fix this problem?

有谁知道如何解决这个问题?

回答by Teffi

Setting ENABLE_BITCODEflag to NOsolves the issue.

ENABLE_BITCODE标志设置为NO可以解决该问题。

For those wondering if its safe to disable it. Yes it is.

对于那些想知道禁用它是否安全的人。是的。

As per Apple Doc

根据 Apple Doc

Bitcode (iOS, watchOS)

Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.

Xcode hides symbols generated during build time by default, so they are not readable by Apple. Only if you choose to include symbols when uploading your app to iTunes Connect would the symbols be sent to Apple. You must include symbols to receive crash reports from Apple.

Note: For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required.

位码(iOS、watchOS)

位码是已编译程序的中间表示。您上传到 iTunes Connect 的包含 bitcode 的应用程序将在 App Store 上编译和链接。包含 bitcode 将允许 Apple 将来重新优化您的应用程序二进制文件,而无需向商店提交新版本的应用程序。

默认情况下,Xcode 隐藏在构建期间生成的符号,因此 Apple 无法读取它们。仅当您在将应用程序上传到 iTunes Connect 时选择包含符号时​​,这些符号才会发送给 Apple。您必须包含符号才能从 Apple 接收崩溃报告。

注意:对于 iOS 应用程序,bitcode 是默认值,但可选。如果您提供 bitcode,则应用程序包中的所有应用程序和框架都需要包含 bitcode。对于 watchOS 应用程序,位码是必需的。

Bitcode is part of Apple's new effort for App thinning. At the time of this writing, it is optional but could potentially be required later on. I think Apple is giving the frameworks/libs communities time to adapt.

Bitcode 是 Apple 为 App 瘦身所做的新努力的一部分。在撰写本文时,它是可选的,但以后可能需要。我认为 Apple 正在给框架/库社区时间来适应。

Edit: In Xcode 7 you upload your app to iTunes connect in an intermediate state called Bitcode. When users download your app, the App Store will automatically produce an optimized version of your app (i.e., 64-bit if needed) to match the device the user is using.

编辑:在 Xcode 7 中,您将您的应用程序上传到 iTunes 以称为Bitcode的中间状态连接。当用户下载您的应用程序时,App Store 将自动生成您的应用程序的优化版本(即,如果需要,为 64 位)以匹配用户使用的设备。

For now what we can do is to disable bitcode and wait for Google Maps SDK's update.

现在我们能做的就是禁用bitcode并等待Google Maps SDK的更新。

UPDATE

更新

SDK 1.11.0 - now supports Bitcode

SDK 1.11.0 - 现在支持 Bitcode

https://developers.google.com/maps/documentation/ios-sdk/releases?hl=en

https://developers.google.com/maps/documentation/ios-sdk/releases?hl=en

Resources:

资源:

Impact of Xcode build options "Enable bitcode" Yes/No

Xcode 构建选项“启用位码”的影响是/否

https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html

https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html

https://www.hackingwithswift.com/ios9

https://www.hackingwithswift.com/ios9

回答by KPath001

I changed the ENABLE_BITCODE Flag to No and compiled properly thanks @Visput for the answer

我将 ENABLE_BITCODE 标志更改为 No 并正确编译感谢@Visput 的回答

回答by nikans

Just to be clear where to disable bitcode: Target -> Build Settings -> Enable Bitcode -> No

只是要清楚在何处禁用位码:目标 -> 构建设置 -> 启用位码 -> 否

Disable Bitcode

禁用位码

GIF image is courtesy of @stevechen

GIF 图像由@stevechen 提供

回答by ehhhuang

Google has resolved this issue in SDK Version 1.11.0 - December 2015. See the release notes:

Google 已在 SDK 版本 1.11.0 - 2015 年 12 月中解决了此问题。请参阅发行说明

Bitcode is now included in the SDK binary for all device architectures. (Issue 8219).

Bitcode 现在包含在所有设备架构的 SDK 二进制文件中。(问题 8219)。