ios - 从 xcodeproj 文件中删除构建配置和方案的脚本?
问题描述
有没有办法通过脚本/命令行从 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 的 hdd 无法打开项目。(.xcodeproj 文件大约 10mb)
我可以打开项目,但每次点击彩虹轮,列出目标需要 10 多分钟,而且我不知道 xcode 中的选项可以一次删除多个配置/方案。
PS:
Apple 脚本解决方案 没有帮助 xcode 无法及时响应
解决方案
在你开始之前
Xcode
需要完全关闭。- 如果您要手动编辑您的
Xcode
项目,请务必 在尝试此操作之前进行备份!
计划:
删除您不想要的方案文件:
/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
的更改时,应该会反映出来。
推荐阅读
- angular - 在 Angular 中将 BehaviorSubject 测试为 Observable - Jasmine
- python - 有没有办法在 pandas 中使用 groupby 函数,以便可以将某些内容引用为 0?
- java - JavaFX应用程序中的“应用程序启动方法中的异常”
- dart - 为什么 flatten 会摆脱映射值?
- php - 如何删除 index.php 并通过 Codeigniter 中的单个重定向重定向到 https
- .net-core - 在 Main Program.cs .NetCore 3.1 控制台应用程序以外的方法中读取 appsettings.json 键
- java - 是否可以在后台捕获麦克风?
- scala - 斯卡拉集合缓冲区
- python - 根据列值获取某些行
- javascript - 如何向 React State 对象添加新的子键值