Skip to content

Instantly share code, notes, and snippets.

@hirohitokato
Last active December 14, 2017 15:55
Show Gist options
  • Save hirohitokato/dd73939ff153f19ff06937e107154301 to your computer and use it in GitHub Desktop.
Save hirohitokato/dd73939ff153f19ff06937e107154301 to your computer and use it in GitHub Desktop.
Xcodeが開いている状態で実行すると、目的のAppのコンテナダウンロードを実行し保存先ダイアログまで表示するAppleScript
set DEVICE_NAME to "ここにアプリが入ったデバイス名(My iPhoneとか)"
set APP_NAME to "ここにアプリ名"
tell application "System Events"
tell process "Xcode"
--- set frontmost to true
click menu item "Devices" of menu "Window" of menu bar 1
tell window "Devices"
--- button 1-3はクローズ・最大化・最小化
--- table 1 of scroll area 1 of splitter group 1は左ペイン内のがデバイスやシミュレータなど
--- menu button 1-2 of splitter group 1はウィンドウ左下部のシミュレータ追加、コンテキストメニュー等
tell table 1 of scroll area 1 of splitter group 1
--- row 1からアプリが並ぶので、APP_NAMEにマッチするものを選択
repeat with aRow in rows
if name of first UI element of aRow is DEVICE_NAME then select aRow
end repeat
end tell
--- scroll area 1 of splitter group 1 of splitter group 1は右ペイン
tell scroll area 1 of splitter group 1 of splitter group 1
--- every UI element: 右ペインの情報
--- {static text "Device Information" ,
--- scroll area 1 ,
--- image 1 ,
--- button "View Device Logs" ,
--- button "Take Screenshot" ,
--- static text "Paired Watches" ,
--- scroll area 2 ,
--- static text "Installed Apps" ,
--- scroll area 3 , <- ここのtable 1がInstalled Appsの一覧
--- menu button 1 , <- ここがコンテナ操作系の歯車アイコン
--- button 3 ,
--- button 4 ,
--- scroll bar 1}
tell table 1 of scroll area 3
--- row 1からアプリが並ぶので、APP_NAMEにマッチするものを選択
repeat with aRow in rows
if name of first UI element of aRow is APP_NAME then select aRow
end repeat
end tell
--- 歯車アイコンをクリック
--- {menu item "Show Container" of menu 1 of menu button 1,
--- menu item "Download Container…" of menu 1 of menu button 1,
--- menu item "Replace Container…" of menu 1 of menu button 1}
click menu button 1
click menu item "Download Container…" of menu 1 of menu button 1 --- ⭐これでコンテナダウンロードの保存先ダイアログが表示される
end tell
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment