Set “OTHER_LDFLAGS” through command line with xcodebuild

五迷三道 提交于 2019-12-18 17:33:53

问题


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


回答1:


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"



回答2:


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"
  #...


来源:https://stackoverflow.com/questions/20947969/set-other-ldflags-through-command-line-with-xcodebuild

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