How to add “Other Linker Flags” to xcode project using command line?

戏子无情 提交于 2019-12-18 13:10:12

问题


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


回答1:


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

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



回答2:


@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

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



回答3:


open up the project.pbxproj file in an editor like BBEdit and paste in the flags you want. 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



来源:https://stackoverflow.com/questions/11147626/how-to-add-other-linker-flags-to-xcode-project-using-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!