xcode 从终端设置xcode“构建设置”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27178452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:16:20  来源:igfitidea点击:

Set xcode "build setting" from terminal?

xcodexcodebuildxcrun

提问by nizzle

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:

无论如何,我可以在不打开 xcode 的情况下更改 xcode 中的设置吗?我有一个自动化的 xcodebuild / xcrun 进程正在进行,但我需要更改 1 个值:

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

目标 > 选择您的目标 > 构建设置 > 代码签名资源规则路径添加:$(SDKROOT)/ResourceRules.plist

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

我找不到任何可以放置此行的文件...

回答by Opal

What You can do is to run:

你可以做的是运行:

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

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

此命令显示为目标和通过的配置填写的所有设置。找到包含的密钥的名称$(SDKROOT)/ResourceRules.plist(我们称之为THE_KEY),然后尝试:

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

Don't guarantee that it will work.

不要保证它会起作用。

回答by Hustlion

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

你可以试试pbxproj。这是一个 Python 模块,可帮助您使用命令行操作 XCode 项目。

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

与您的问题相关的部分可能是https://github.com/kronenthaler/mod-pbxproj/wiki/flags#add-code-sign

You can pip install pbxprojto have it.

你可以pip install pbxproj拥有它。

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()