如何使用命令行将“Other Linker Flags”添加到xcode项目?

时间:2022-02-19 23:14:33

I'm trying to automate building process of xcode project. 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. 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

我正在尝试自动化xcode项目的构建过程。问题是我需要在构建项目时添加“Other Linker Flags”。我不能手动将它添加到项目构建设置,我必须使用命令行。可能是我可以以某种方式编辑项目文件或配置文件?任何选项都是好的,只要它可以作为脚本运行。有任何想法吗?谢谢

2 个解决方案

#1


3  

You can do this by specifying an xcconfig file to xcodebuild. For example:

您可以通过为xcodebuild指定xcconfig文件来完成此操作。例如:

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

#2


1  

@Jesse Rusak's answer works, but it is a bit simpler to directly add options to the command line, being careful to escape variables from your shell like

@Jesse Rusak的答案有效,但直接向命令行添加选项有点简单,小心从shell中转义变量

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

#1


3  

You can do this by specifying an xcconfig file to xcodebuild. For example:

您可以通过为xcodebuild指定xcconfig文件来完成此操作。例如:

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

#2


1  

@Jesse Rusak's answer works, but it is a bit simpler to directly add options to the command line, being careful to escape variables from your shell like

@Jesse Rusak的答案有效,但直接向命令行添加选项有点简单,小心从shell中转义变量

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