简体   繁体   English

如何使用命令行将“其他链接器标志”添加到 xcode 项目?

[英]How to add "Other Linker Flags" to xcode project using command line?

I'm trying to automate building process of xcode project.我正在尝试自动化 xcode 项目的构建过程。 The problem is that I need to add "Other Linker Flags" when building the project.问题是我需要在构建项目时添加“其他链接器标志”。 I can't just add it to the project Build Settings manually, I have to do it using the command line.我不能只是手动将它添加到项目 Build Settings 中,我必须使用命令行来完成。 May be I can edit the project file or configuration file somehow?也许我可以以某种方式编辑项目文件或配置文件? Any options are good as long as it can be runned as a script.只要可以作为脚本运行,任何选项都是好的。 Any ideas?有任何想法吗? Thanks谢谢

You can do this by specifying an xcconfig file to xcodebuild.你可以通过为 xcodebuild 指定一个 xcconfig 文件来做到这一点。 For example:例如:

echo 'OTHER_LDFLAGS = $(OTHER_LDFLAGS) -force_load "$(SRCROOT)/calabash.framework/calabash" -lstdc++' > temp.xcconfig
xcodebuild -xcconfig temp.xcconfig ...

@Jesse Rusak 的答案有效,但直接向命令行添加选项要简单一些,注意从 shell 中转义变量,例如

xcodebuild ... "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -all_load"

open up the project.pbxproj file in an editor like BBEdit and paste in the flags you want.在像 BBEdit 这样的编辑器中打开 project.pbxproj 文件并粘贴你想要的标志。 Search for搜索

buildSettings = {
...

SWIFT_VERSION = 4.2;
}

becomes变成

buildSetting = {
...

SWIFT_VERSION = 4.2;
OTHER_LDFLAGS = "-all_load";
}

There should be a section for your Debug and Release schemes.应该有一个部分用于您的调试和发布方案。 Do it for all为所有人做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM