问题
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