如何从脚本中的 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 出错:AppleEvent 处理程序失败.(-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