Set "OTHER_LDFLAGS" through command line with xcodebuild

5.1k views Asked by At

I have successfully compiled the project through command line.But i want set library(.a) file through command line .

It successfully build with below command /Users/Mahen/Documents/workspace/TestingApplication/Test/Test.xcodeproj -configuration Debug build

Now I want set Linking .a file through command line. I have try set "OTHER_LDFLAGS" option with -force_load /Users/Mahen/Documents/workspace/Test.iOS/build/Debug-iphoneos/libTest.a -lstdc++

But it couldn't load , Can you suggest the right way Linking .a files through the command line?

Thanks

2

There are 2 answers

0
idij On

I'm not clear what your exact problem is, but hopefully one of these will help you or somebody else:

To override an option you go xcodebuild "OPTIONNAME=newvalue"

xcodebuild "OTHER_LDFLAGS= .... "

Note that this will override any other "OTHER_LDFLAGS" that you might have had in the actual xcode project.

To link a library libNAME.a you need to include in the linker flags -lNAME and also have the location of libNAME.a on the library search path -Lpath/to/my/libraries.

xcodebuild "OTHER_LDFLAGS=-Liphoneos -lTest"

To force the library to link even if there is no dependency (e.g. to include gtest cases) then you need to use -force_load path/to/my/libraries/libNAME.a

xcodebuild "OTHER_LDFLAGS=-force_load iphoneos/libTest.a"
0
Chris St. John On

To set OTHER_LDFLAGS from the command-line you would do it like so (note the placement of the quotation marks):

xcodebuild 
  -verbose 
  -configuration Debug build
  archive
  OTHER_LDFLAGS="-ObjC -weak_framework CoreMotion"
  #...