有没有办法通过脚本/命令行从 xcodeproj 中删除构建配置和方案,而无需在文本编辑器中编辑 (project.pbxproj) 希望它不会交叉验证和影响构建。
我试过xcodeproj
它允许您读取 prj 并将其表示为 yaml,我想要一个可以编辑 yaml 并从中生成 xcodeproj 的地方。
我还尝试从 xcshareddata
中删除方案,但性能仍然没有改善。
shell> xcodebuild -project myproject.xcodeproj -list
# output
Information about project "myproject":
Targets:
myproject
myprojectTests
ScreensForManPages
UITestsCA
....
....
UITestsUS
Build Configurations:
ae-debug
ae-debug-another-condition
ae-release
ae-release-another-condition
...
...
250+ build config in between
...
...
zw-debug
zw-debug-another-condition
zw-release
zw-release-another-condition
If no build configuration is specified and -scheme is not passed then "ae-release-another-condition" is used.
Schemes:
myproject-ae-debug
myproject-ae-debug-another-condition
myproject-ae-release
...
...
250+ schemes in between
...
...
myproject-zw-debug
myproject-zw-debug-another-condition
myproject-zw-release
myproject-zw-release-another-condition
原因:
我最近继承了一个项目,其中有 250 多个构建配置和 250 多个方案。不幸的是,我的工作机器是很好的旧mbp,带有硬盘,运行osx mojave和xcode 10,无法打开该项目。 (.xcodeproj 文件大约 10mb)
我可以打开项目,但是每次点击彩虹轮,列出目标需要超过 10 分钟,而且我不知道 xcode 中的选项可以一次删除多个配置/方案。
附注:
Apple script solution 没有帮助 xcode 无法及时响应
最佳答案
开始之前
Xcode
needs to be completely closed.- If you are going to manually edit your
Xcode
project DEFINITELY make a backup before attempting this!
方案:
删除你不想要的方案文件:
/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes
编辑管理plist:
/MyApp/MyApp.xcodeproj/xcuserdata/Username.xcuserdatad/xcschemes/xcschememanagement.plist
在文件中删除不需要的方案(例如 MyApp Custom
):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
///////////////////////////////////////////////// remove start
<key>MyApp Custom.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
///////////////////////////////////////////////// remove end
<key>MyApp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>AFDACD5A2209867B00004213</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
构建配置:
/MyApp/SomeProgram.xcodeproj/project.pbxproj
我不建议手动编辑这个文件,而是通过 Xcode
删除构建配置,但是如果你勇敢地进入文件,你会看到配置。您还可以使用 plist 编辑器(plistbuddy 等)编辑此文件——删除您不想要的:
AFADF25C22269ABE000D354D = {
buildSettings = {
...
};
isa = XCBuildConfiguration;
name = Custom;
};
您还会看到与其他配置分组的相应 UID
:
AFDACD542209865600004213 = {
buildConfigurations = (
AFDACD552209865600004213,
AFDACD562209865600004213,
AFADF25C22269ABE000D354D ////// remove
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
isa = XCConfigurationList;
};
现在,当您打开 .xcodeproj
时,更改应该会反射(reflect)出来。
关于ios - 从 xcodeproj 文件中删除构建配置和方案的脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54899179/