Xcode 7 警告:目标文件是为更新的 iOS 版本构建的,而不是被链接

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

Xcode 7 warnings: object file was built for newer iOS version than being linked

iosobjective-cxcode7xcode7-beta4

提问by Jony Thrive

I recently integrated Google Cloud Messaging into an app targeting iOS 7 and iOS 8. Just grabbed Xcode 7 beta 4 to get started on iOS 9 support, and now I'm getting an error from the linker:

我最近将 Google Cloud Messaging 集成到了一个针对 iOS 7 和 iOS 8 的应用程序中。刚刚获取了 Xcode 7 beta 4 以开始支持 iOS 9,现在我从链接器收到一个错误:

ld: warning: object file (.../Pods/GoogleInterchangeUtilities/Libraries
/libProtocolBuffers.a(Descriptor.pb.o)) was built for newer iOS version (8.3)
than being linked (7.0)

and a handful more like that all for parts of libProtocolBuffers.a.

还有一些更像 libProtocolBuffers.a 部分的所有内容。

Does this mean that iOS 8.3 is required to use the GCM library? If so, why did Xcode 6 happily spit out code that (by all appearances in my testing with iOS 7 devices) delivered push notifications to iOS 7.3 without issue?

这是否意味着需要 iOS 8.3 才能使用 GCM 库?如果是这样,为什么 Xcode 6 高兴地吐出代码(在我对 iOS 7 设备的测试中的所有表现)向 iOS 7.3 发送推送通知而没有问题?

Given that they're just warnings, I can still compile fine, however I prefer not to ship code that is wrong.

鉴于它们只是警告,我仍然可以很好地编译,但是我不想发布错误的代码。

Edit:I emailed google and they said top people will look into it. In the mean time, if you're reading this and bothered by the warning, maybe also email so they'll be encouraged to deal with it.

编辑:我给谷歌发了电子邮件,他们说高层会调查它。与此同时,如果你正在阅读这篇文章并被警告所困扰,也许也可以通过电子邮件来鼓励他们处理它。

采纳答案by evanescent

This just means that one of the libraries(Protocol Buffers here) GCM depends on was built for 8.3 although it's compatible with the min sdk version of GCM i.e. 7.0. XCode 7 is just more severe and reports it as a warning but it was always there just not being reported by previous versions.

这只是意味着 GCM 依赖的库之一(此处为协议缓冲区)是为 8.3 构建的,尽管它与 GCM 的最小 sdk 版本(即 7.0)兼容。XCode 7 只是更严重,并将其报告为警告,但它总是存在,只是以前的版本没有报告。

Overall this is just harmless, everything should work fine. Also there is not much that you can do unless Google patches GCM by building all of it's dependencies with the min sdk version (7.0).

总的来说,这只是无害的,一切正常。此外,除非 Google 通过使用 min sdk 版本 (7.0) 构建所有依赖项来修补 GCM,否则您无能为力。

回答by Legoless

It actually means that the Minimum Deployment Targetof the included library was is to 8.3 and linking it with lower Minimum Deployment Target produces this warning.

这实际上意味着所包含库的最小部署目标是 8.3,并将其与较低的最小部署目标链接会产生此警告。

Library does not officially support targets lower than 8.3 in this case.While linking this library to target with ower Minimum Deployment Target will still work, it might produce crashes at runtime, if any 8.3 only code is executed on a device that runs older system than 8.3.

在这种情况下,库不正式支持低于 8.3 的目标。虽然将此库链接到具有更低部署目标的目标仍然有效,但如果在运行比 8.3 旧系统的设备上执行任何仅 8.3 的代码,则可能会在运行时产生崩溃。

There is a reason why developers set 8.3 as the minimum target and this warning should NOTbe ignored. It might be harmless in this case, but it is not necessarily harmless in other cases!

开发人员将 8.3 设置为最低目标是有原因的,不应忽略此警告。在这种情况下它可能是无害的,但在其他情况下不一定是无害的!

To fix these warnings, either use an older version of the library or set your Minimum deployment target to 8.3.

要修复这些警告,请使用旧版本的库或将最低部署目标设置为 8.3。

回答by OMGHaveFun

My way to fix:

我的修复方法:

  1. Check "Deployment Target" is equal to Podfile "Platform"
  2. Delete DerivedData (/Users/yourUser/Library/Developer/Xcode)
  3. Pod install (Terminal)
  4. Clean/Build Project
  1. 检查“部署目标”是否等于 Podfile“平台”
  2. 删除派生数据 (/Users/yourUser/Library/Developer/Xcode)
  3. Pod 安装(终端)
  4. 清理/构建项目

P.s. Can add more info if needed.

Ps 如果需要,可以添加更多信息。

回答by wj2061

In targets/Build Settings/Linking/Other Linker Flags,add

目标/构建设置/链接/其他链接器标志中,添加

-w

-w

silence the warning for me.

沉默对我的警告。

回答by Codiak

FYI, the latest version of the relevant pods seems to have fixed this issue.

仅供参考,相关 pod 的最新版本似乎已经解决了这个问题。

Specifically, it looks like it was the upgrade of GoogleInterchangeUtilities from 1.0.0 to 1.1.0 that did the trick.

具体来说,看起来是 GoogleInterchangeUtilities 从 1.0.0 升级到 1.1.0 才奏效的。

If you're seeing this, a "pod update" should make it all better!

如果你看到这个,“豆荚更新”应该会让一切变得更好!

回答by Injectios

In my case the reason was that I just updated podsthen changed deployment targetto lower then it was before and got such warnings. Running podupdate again solves the issue.

就我而言,原因是我刚刚更新pods然后更改deployment target为低于之前的值并收到此类警告。pod再次运行更新可以解决问题。