有没有办法将 xcode 构建设置导出到 .xcconfig 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11164876/
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 00:39:56  来源:igfitidea点击:

Is there a way export xcode build settings to .xcconfig file?

iosxcodexcconfig

提问by almas

Is it possible to export xcode build settings to .xcconfig file? Other than just copy-paste it to text file line-by-line. Thanks!

是否可以将 xcode 构建设置导出到 .xcconfig 文件?除了将其逐行复制粘贴到文本文件之外。谢谢!

回答by Michael M. Myers

This SOanswer helped me.

这个SO答案帮助了我。

Show the package contents of your project file (MyProject.xcodeproj) by two finger clicking on it in finder, then open the 'project.pbxproj' file in a text editor.

通过在 finder 中用两根手指单击来显示项目文件 (MyProject.xcodeproj) 的包内容,然后在文本编辑器中打开“project.pbxproj”文件。

Look for the section XCConfigurationList. It starts with /* Begin XCConfigurationList section */. You will find all your targets and their respective builConfigurations. Now do a find (command - f) on the long hex ID to find the other occurance in the project.pbxproj where you should also find your buildSettings. Copy and paste everything between the buildSettings brackets into your xcconfig file. You will then need to massage some of the variables, specifically the lists of search paths.

查找 XCConfigurationList 部分。它以 开头/* Begin XCConfigurationList section */。您将找到所有目标及其各自的构建配置。现在在长十六进制 ID 上执行查找(命令 - f)以查找 project.pbxproj 中的其他事件,您还应该在其中找到您的 buildSettings。将 buildSettings 括号之间的所有内容复制并粘贴到您的 xcconfig 文件中。然后您需要调整一些变量,特别是搜索路径列表。

Alternatively, you can use xcodebuild from the command line:

或者,您可以从命令行使用 xcodebuild:

First to list your schemes:

首先列出您的计划:

xcodebuild -list

xcodebuild -list

Then export your desired scheme's settings:

然后导出您想要的方案的设置:

xcodebuild -scheme "schemeName" -showBuildSettings >> mynew.xcconfig

xcodebuild -scheme "schemeName" -showBuildSettings >> mynew.xcconfig

You will then need to delete the first line or comment it out

然后您需要删除第一行或将其注释掉

回答by jemmons

You don't have to copy-and-paste line-by-line. You can select all and copy all lines at once. The only restriction is you can't copy lines with <multiple values>as a value. That is, if you've got one setting that has specifies a different value for both Debugand Release, etc. you need to deselect just that line (cmd-click) to copy.

您不必逐行复制和粘贴。您可以一次全选并复制所有行。唯一的限制是您不能复制带有<multiple values>值的行。也就是说,如果您有一个设置为DebugandRelease等指定了不同的值,则您只需要取消选择该行(按住 cmd 键单击)即可复制。