Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 200
almas Avatar asked Jun 21 '12 22:06

almas


People also ask

How do I add another linker flag?

Add Linker FlagSelect your project in the sidebar and switch to the “Build Settings” tab. Search for the “Other Linker Flags” setting. Double click the Other Linker Flags row's value area, on the right side. A pop-up should appear.

What does ObjC linker flag do?

The -ObjC Linker Flag Passing the -ObjC option to the linker causes it to load all members of static libraries that implement any Objective-C class or category. This will pickup any category method implementations. But it can make the resulting executable larger, and may pickup unnecessary objects.

Where are Xcode build settings?

Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.


2 Answers

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 ...
like image 102
Jesse Rusak Avatar answered Oct 15 '22 19:10

Jesse Rusak


@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"
like image 37
Paul Beusterien Avatar answered Oct 15 '22 18:10

Paul Beusterien