Xcode 7 警告!是为更新的 iOS 版本 (5.1.1) 而构建的,而不是链接 (5.1)

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

Xcode 7 Warning! was built for newer iOS version (5.1.1) than being linked (5.1)

xcodexcode7

提问by last-Programmer

I upgraded Xcode 6 project to Xcode 7 and started seeing the warning was built for newer iOS version (5.1.1) than being linked (5.1).

我将 Xcode 6 项目升级到 Xcode 7 并开始看到警告是为更新的 iOS 版本 (5.1.1) 而不是链接 (5.1)。

How to fix this warning?

如何修复此警告?

回答by blacky85

In my case, this warning was produced because the iOS-Deployment-Target of one of my XCode subprojects was higher (7.1) than in my baseproject (7.0). If you use cococapods, this misconfiguration can happen when you specify a wrong iOS platform version in your Podfile. In my example, I specified in my Podfile

就我而言,产生此警告是因为我的一个 XCode 子项目的 iOS-Deployment-Target 高于我的基础项目 (7.0) (7.1)。如果您使用 cococapods,当您在 Podfile 中指定错误的 iOS 平台版本时,可能会发生这种错误配置。在我的示例中,我在 Podfile 中指定

platform :ios, '7.1' 

whereas I set the Deployment-Target in my XCode-Project to iOS 7.0. Setting the DeploymentTarget of the Subproject to the same iOS Version as the BaseProject fixes this warning.

而我将 XCode-Project 中的 Deployment-Target 设置为 iOS 7.0。将子项目的 DeploymentTarget 设置为与 BaseProject 相同的 iOS 版本可修复此警告。

回答by Frans

Update: seems to be resolved with Xcode 7.3 (7D175). I've removed the -w flag, the warning no longer appears.

更新:似乎已通过 Xcode 7.3 (7D175) 解决。我删除了 -w 标志,不再出现警告。

This appears to be a known bug in Xcode 7.0 and 7.1B1 (bug #21813082).

这似乎是 Xcode 7.0 和 7.1B1 中的一个已知错误(错误 #21813082)。

As a temporary workaround, to suppress extensive warnings, the -w flag can be added to Build Settings -> Other Linker Flags:

作为临时解决方法,为了抑制大量警告,可以将 -w 标志添加到 Build Settings -> Other Linker Flags:

  1. Select your Project
  2. Select your Target
  3. Select "Build Settings" tab
  4. Scroll down to "Linking"
  5. Edit "Other Linker Flags" and add "-w"
  1. 选择您的项目
  2. 选择你的目标
  3. 选择“构建设置”选项卡
  4. 向下滚动到“链接”
  5. 编辑“其他链接器标志”并添加“-w”

I've only added this to the Debug build settings and inserted the following to the AppDelegate, just as reminder:

我只将此添加到调试构建设置并将以下内容插入到 AppDelegate 中,作为提醒:

#ifdef DEBUG
#warning Linker warnings suppressed (-w in build settings)
#endif

This at least helps to quickly spot the real warnings instead of having the build results flooded with the same warning for every source (in my case 150+ warnings appeared).

这至少有助于快速发现真正的警告,而不是让每个来源的构建结果充斥着相同的警告(在我的情况下,出现了 150 多个警告)。

回答by Matt

In my case, I upgraded the projectto iOS 6, but the problem didn't go away.

就我而言,我将项目升级到 iOS 6,但问题并没有消失。

Then I realised the targetwas overriding it as iOS 5.1.1. I cleared the target settings and the warnings went away.

然后我意识到目标正在将其覆盖为 iOS 5.1.1。我清除了目标设置,警告消失了。

XCode Version 7.0 (7A220).

XCode 7.0 版 (7A220)。

Target settings

目标设置

回答by Teffi

In my case, I had my project set to 8.4 but all the rest of the subprojects/targets are still on 9.0. Appears like it is caused by deployment target inconsistencies.

就我而言,我的项目设置为 8.4,但所有其余的子项目/目标仍为 9.0。貌似是部署目标不一致造成的。

For those who are using Cocoapods:

对于那些使用 Cocoapods 的人:

  1. Navigate through your Pod projects and targets.
  2. Change all the deployment targets to your desired one.
  1. 浏览您的 Pod 项目和目标。
  2. 将所有部署目标更改为您想要的目标。

Make sure all of them are similar.

确保它们都相似。

回答by ihsan_husnul

try add "-w" on "Linking->Other Linker Flags".

尝试在“链接->其他链接器标志”上添加“-w”。

This happening in my case when mySDK built with base SDK greater than development target myProject.

在我的情况下,当 mySDK 使用大于开发目标 myProject 的基础 SDK 构建时,就会发生这种情况。

回答by Carol Capek

In my case the deployment target in the project section (7.0) was different to the target deployment targets (8.0). So check your deployment targets for your project and every single target in your project to be the same.

就我而言,项目部分 (7.0) 中的部署目标与目标部署目标 (8.0) 不同。因此,请检查项目的部署目标和项目中的每个目标是否相同。

回答by Carol Capek

First change iOS Deployment Target under Project then change Deployment Target under Targets. Delete file at /Users/yourUser/Library/Developer/Xcode/DerivedData (rm -rf yourProject). Pod install again then say bye to warning.

首先更改项目下的 iOS 部署目标,然后更改目标下的部署目标。删除文件/Users/yourUser/Library/Developer/Xcode/DerivedData (rm -rf yourProject)。再次安装 Pod,然后告别警告。

回答by Firas Shrourou

I my case I changed the Deployment Target in the targets without changing the same in the project.

我的情况是我更改了目标中的部署目标,而没有更改项目中的相同内容。

To solve the issue, I changed the Deployment Target on both the project and the Targets then I make pod update.

为了解决这个问题,我更改了项目和目标上的部署目标,然后进行 pod 更新。

回答by Arthur Ninch

Just in case anyone suffers the same bewilderment as myself: I discovered that I had an Xcode beta on an external hard drive and the system was selecting the tools on that drive instead of the internal drive. (Presumably because they were the newer beta tools?)... Ejecting the drive solved my issue!

以防万一有人遇到和我一样的困惑:我发现我在外部硬盘驱动器上有一个 Xcode 测试版,并且系统正在选择该驱动器上的工具而不是内部驱动器。(大概是因为它们是较新的测试版工具?)... 弹出驱动器解决了我的问题!

回答by Qiulang

In my case I built the libraries with latest iOS but the app's deployment target is lower than that. So I think there is nothing I can do except adding -w to other linker flag

就我而言,我使用最新的 iOS 构建了库,但应用程序的部署目标低于此目标。所以我认为除了将 -w 添加到其他链接器标志之外我无能为力