Xcode 8/xcodebuild:如何从命令行触发'Update Signing'?
Xcode 8/xcodebuild: how to trigger 'Update Signing' from command line?
背景:Xcode 8 有新设施到 'Automatically Update Signing'。由于建筑物 mac 上没有配置文件,Xcode 将自动从 Apple 开发门户中提取所需的配置文件。
可以rm -rf ~/Library/MobileDevice/Provisioning\ Profiles
然后打开Xcode项目,Xcode会自动拉取配置文件,会在Xcode中看到'Update Signing':
如何从命令行触发此 'Update Signing'? xcodebuild 的手册页没有提到这一点。简单地 运行 一个 'xcodebuild' 不会 运行 这一步。
无法使用 xcodebuild
执行此操作。
但是,我有一个 work-around 似乎可以帮我完成任务。我使用 AppleScript 在 Xcode 中打开工作区,等待适当的时间(比如 10 秒)然后退出 Xcode。签名更新是在打开工作区时完成的,而不是在您尝试构建时完成的,因此这足以解决任何签名问题。
我使用的 AppleScript 是这样的(基于我在互联网上找到的一些代码):
tell application "/Applications/Xcode.app"
open "/Users/gary/MyWorkspace.xcworkspace"
set workspaceDocument to workspace document "MyWorkspace.xcworkspace"
-- Wait for the workspace document to load with a 60 second timeout
repeat 120 times
if loaded of workspaceDocument is true then
exit repeat
end if
delay 0.5
end repeat
if loaded of workspaceDocument is false then
error "Xcode workspace did not finish loading within timeout."
end if
-- Xcode will only update the signing for targets in the active scheme,
-- so make sure the required scheme is the active one
set schemeToUse to scheme "SchemeToUse" of workspaceDocument
set active scheme of workspaceDocument to schemeToUse
-- The time taken to update signing issues is related to the number of targets.
-- The number of targets built by a scheme is not exposed through AppleScript,
-- so count the total number of targets in the workspace
set totalTargets to 0
repeat with theProject in projects in workspaceDocument
set totalTargets to totalTargets + (count of targets of theProject)
end repeat
-- For each target, wait a short amount of time
repeat totalTargets times
delay 3.0
end repeat
quit
end tell
您需要根据您的情况更改工作区路径、工作区名称和方案名称。
运行 AppleScript 从命令行有很多方法,包括 osascript
命令,但我一直在 Python.
背景:Xcode 8 有新设施到 'Automatically Update Signing'。由于建筑物 mac 上没有配置文件,Xcode 将自动从 Apple 开发门户中提取所需的配置文件。
可以rm -rf ~/Library/MobileDevice/Provisioning\ Profiles
然后打开Xcode项目,Xcode会自动拉取配置文件,会在Xcode中看到'Update Signing':
如何从命令行触发此 'Update Signing'? xcodebuild 的手册页没有提到这一点。简单地 运行 一个 'xcodebuild' 不会 运行 这一步。
无法使用 xcodebuild
执行此操作。
但是,我有一个 work-around 似乎可以帮我完成任务。我使用 AppleScript 在 Xcode 中打开工作区,等待适当的时间(比如 10 秒)然后退出 Xcode。签名更新是在打开工作区时完成的,而不是在您尝试构建时完成的,因此这足以解决任何签名问题。
我使用的 AppleScript 是这样的(基于我在互联网上找到的一些代码):
tell application "/Applications/Xcode.app"
open "/Users/gary/MyWorkspace.xcworkspace"
set workspaceDocument to workspace document "MyWorkspace.xcworkspace"
-- Wait for the workspace document to load with a 60 second timeout
repeat 120 times
if loaded of workspaceDocument is true then
exit repeat
end if
delay 0.5
end repeat
if loaded of workspaceDocument is false then
error "Xcode workspace did not finish loading within timeout."
end if
-- Xcode will only update the signing for targets in the active scheme,
-- so make sure the required scheme is the active one
set schemeToUse to scheme "SchemeToUse" of workspaceDocument
set active scheme of workspaceDocument to schemeToUse
-- The time taken to update signing issues is related to the number of targets.
-- The number of targets built by a scheme is not exposed through AppleScript,
-- so count the total number of targets in the workspace
set totalTargets to 0
repeat with theProject in projects in workspaceDocument
set totalTargets to totalTargets + (count of targets of theProject)
end repeat
-- For each target, wait a short amount of time
repeat totalTargets times
delay 3.0
end repeat
quit
end tell
您需要根据您的情况更改工作区路径、工作区名称和方案名称。
运行 AppleScript 从命令行有很多方法,包括 osascript
命令,但我一直在 Python.