如何从脚本中的Xcode项目中删除构建配置?

如何从脚本中的Xcode项目中删除构建配置?

问题描述:

我目前正在使用AppleScript清理Xcode项目.我希望我的脚本删除一些与我团队中其他开发人员无关的构建配置.

I'm currently using AppleScript to clean up an Xcode project. I'd like my script to remove some build configurations that won't be relevant to other developers on my team.

例如,如果我具有"Debug","DebugTest"和"Release",我希望脚本删除"DebugTest".

For example, if I have "Debug", "DebugTest", and "Release", I would like the script to remove "DebugTest".

我当前正在使用以下脚本:

I'm currently using the following script:

tell application "Xcode"
open myXcodeProject
    set targetProject to project of active project document
    set targetConfigurations to build configurations of targetProject
    repeat with c in targetConfigurations
        if (name of c is equal to "DebugTest") then
            delete c
        end if
    end repeat
end tell

但是,运行脚本时出现以下错误,这使我相信我没有正确删除配置:

However, I'm getting the following error when I run the script, which leads me to beleive that I'm not deleting the configuration correctly:

Xcode got an error: AppleEvent handler failed. (-10000)

谢谢!

尝试一下...

tell application "Xcode"
    set targetProject to project of active project document
    tell targetProject
        delete (first build configuration type whose name is "DebugTest")
    end tell
end tell