Set xcode “build setting” from terminal?

倖福魔咒の 提交于 2019-12-18 04:49:06

问题


Is there anyway that I can change a setting in xcode without opening xcode? I have an automated xcodebuild / xcrun process going on but I need to change 1 value:

Targets > Select your target > Build Settings > Code Signing Resource Rules Path add : $(SDKROOT)/ResourceRules.plist

I can't find any file where I might put this line...


回答1:


What You can do is to run:

xcodebuild -target <target> -configuration <configuration> -showBuildSettings

This command shows all the settings that are filled for target and configuration passed. Find the name of the key that contains $(SDKROOT)/ResourceRules.plist (let call it THE_KEY) and then try:

xcodebuild -target <target> -configuration <configuration> THE_KEY=<new_value>

Don't guarantee that it will work.




回答2:


You could try pbxproj. This is a python module that helps you manipulate XCode projects with commandline.

The related part to your probelm may be https://github.com/kronenthaler/mod-pbxproj/wiki/flags#add-code-sign

You can pip install pbxproj to have it.

And here's an example provided in the official repo:

from pbxproj import XcodeProject
# open the project
project = XcodeProject.load('myapp.xcodeproj/project.pbxproj')

# add a file to it, force=false to not add it if it's already in the project
project.add_file('MyClass.swift', force=False)

# set a Other Linker Flags
project.add_other_ldflags('-ObjC')

# save the project, otherwise your changes won't be picked up by Xcode
project.save()


来源:https://stackoverflow.com/questions/27178452/set-xcode-build-setting-from-terminal

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