是否可以从命令行将xcode scheme
导入xcode project
或xcode workspace
?
我想使用shell脚本自动化存档过程,并且我想验证该方案是否存在于xcode project
或xcode workspace
中,如果该方案不退出从{.xcscheme
导入它1}}文件。
答案 0 :(得分:1)
实际上这很容易实现。正如您已经想到的那样,Xcode方案只是驻留在xcodeproj容器“文件”中的文件。
如果您想检查方案是否存在,您只需要检查.xcscheme
文件是否存在于以下任一位置:<your_project>.xcodeproj/xcuserdata/<your_user>.xcuserdatad/xcschemes/
<your_project>.xcodeproj/xcshareddata/xcschemes/
如果不是,您只需将其复制到那里(最好是xcshareddata/xcschemes/
文件夹)。
以下代码可以解决这个问题:
#!/bin/bash
# Set to your project and scheme
export PROJECT_FILE="MyProject.xcodeproj"
export SCHEME="abc.xcscheme"
# Generate path to shared schemes folder
export SCHEMES=$PROJECT_FILE/xcshareddata/xcschemes
if [ ! -f $SCHEMES/$SCHEME ]; then
# Create folder if necessary
mkdir -p $SCHEMES
# Copy scheme
cp $SCHEME $SCHEMES/$SCHEME
fi