xcode 如何删除警告:“-pie 被忽略。它仅在链接主可执行文件时使用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52789127/
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
How to Remove Warning: "-pie being ignored. it is only used when linking a main executable"
提问by sarah
Since updating to Xcode10 and Swift 4.2, I always get this build time warnings in my pod. what do I have to do to remove these warnings?
自从更新到 Xcode10 和 Swift 4.2 以来,我总是在我的 pod 中收到此构建时间警告。我该怎么做才能消除这些警告?
I have tried to delete derived data, clean and build project, but it doesn't work :(
我试图删除派生数据,清理并构建项目,但它不起作用:(
I find someone asks the same question here https://github.com/Alamofire/Alamofire/issues/2624and there is an answer from Jon Shier, but I still can't resolve the issue after removing the previous xcworkspace and update cocoapods, I have not implemented to change "Generate Position-Dependent Executable" setting because I can't find it. please share if you can find the solution of this issue :)
我发现有人在这里问了同样的问题https://github.com/Alamofire/Alamofire/issues/2624并且有一个来自 Jon Shier 的回答,但是在删除以前的 xcworkspace 并更新 cocoapods 后我仍然无法解决问题,我没有实现更改“生成位置相关的可执行文件”设置,因为我找不到它。如果您能找到此问题的解决方案,请分享:)
回答by Ben
Setting "Generate Position-Dependent Code" to Yes does not feel like the right fix. Position-independent is preferred. Non-app targets like frameworks and libraries will always be position independent anyway, hence the warning.
将“生成位置相关代码”设置为“是”感觉不是正确的解决方法。位置无关是首选。像框架和库这样的非应用程序目标无论如何总是位置无关的,因此是警告。
The warning shown is a linker message and the other setting in @Marcpek's screen shot seems more suitable: "Linking > Generate Position-Dependent Executable". QuickHelp shows this is the LD_NO_PIE
setting.
显示的警告是链接器消息,@Marcpek 屏幕截图中的其他设置似乎更合适:“链接 > 生成位置相关的可执行文件”。QuickHelp 显示这是LD_NO_PIE
设置。
Even though this inherits No
anyway from the OS defaults I tried setting it to No again in my CocoaPod targets explicitly and that seemed to work, fixing the linker warning.
尽管这No
无论如何都是从操作系统默认值继承的,但我尝试在我的 CocoaPod 目标中再次将其明确设置为 No 并且这似乎有效,修复了链接器警告。
Any project settings you make will be lost the next time you run pod install
so edit the Podfile to make the change permanent. Add config.build_settings['LD_NO_PIE'] = 'NO'
into post_install phase:
下次运行时pod install
,您所做的任何项目设置都将丢失,因此请编辑 Podfile 以使更改永久化。添加config.build_settings['LD_NO_PIE'] = 'NO'
到 post_install 阶段:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LD_NO_PIE'] = 'NO'
end
end
end
回答by Marcpek
What finally worked for me is to enable position-dependent code for the Pods project. I tried disabling warnings from pods and clearing (instead of enabling) the Generate Position-Dependent Codesetting before but that didn't really work.
最终对我有用的是为 Pods 项目启用依赖位置的代码。我之前尝试禁用来自 pod 的警告并清除(而不是启用)生成位置相关代码设置,但这并没有真正起作用。
Disable -pie for Pods
为 Pod 禁用 -pie
To enable position-dependent code (and hence remove -pie, which is Position Independent Code), after opening the xcworkspace, go to the Pods project build settings (the settings for the whole Pods
project, see screenshot), search for position
and set the Generate Position-Dependent Codebuild setting to Yes.
要启用位置相关代码(因此除去-pie,这是Position我ndependent ÇODE),打开xcworkspace后,去荚项目构建设置(设置为整个Pods
项目,见截图),搜索position
和将生成位置相关代码构建设置设置为是。
回答by stevex
One option is to switch to linking pods as static libraries instead of frameworks. use_frameworks!
was required when Swift didn't support static libraries, but now that it does, you can remove that line from your Podfile, pod install
, and the warning should be gone.
一种选择是切换到将 pod 链接为静态库而不是框架。use_frameworks!
当 Swift 不支持静态库时是必需的,但现在它支持了,您可以从 Podfile 中删除该行pod install
,警告应该消失了。
More info on the history of use_frameworks
: https://stackoverflow.com/a/49469205/8831
关于历史的更多信息use_frameworks
:https: //stackoverflow.com/a/49469205/8831
回答by Слава Белов
- update cocoapods
- delete xcworkspace
- run "pod install"
- clear Build folder in menu "Product"
- 更新 cocoapods
- 删除 xcworkspace
- 运行“吊舱安装”
- 清除菜单“产品”中的构建文件夹