XCode Simulator에 App(.ipa) 파일 설치하기

취약점 테스트 기기로 쓰는 iOS 디바이스에 문제가 있어 Simulator를 알아보던 중 간단한 팁이 있어 작성합니다. 일반적으로 Simulator에 Xcode로 컴파일한 앱이 아니면 설치가 불가능합니다. 다만 약간의 트릭을 쓰면 쉽게 가능하지만요. 오늘은 app 파일인 .ipa(app)으로 Xcode Simulator에 설치해 봅시다.

Extract .ipa file #

PK헤더

ipa 파일은 Android apk 와 유사하게 압축 파일입니다. 확장자를 변경 후 압축을 풀어줍니다.

cp test.ipa test.zip
unzip test.zip

압축을 풀어서 내용을 보면 .app 디렉토리가 나옵니다. 이 디렉토리에는 app에 대한 많은 정보가 들어있고 이 디렉토리를 통해 Simulator에 설치가 가능합니다.

Xcode Simulator에 설치하기 #

xcode는 xcrun 이란 명령으로 커맨드라인에서 명령을 줄 수 있으며 simctl 옵션으로 simulator로 명령 전달이 가능합니다. install 명령을 주어 app 파일로 설치할 수 있습니다.

xcrun simctl install [simulator 고유값] [app 경로]

app 경로는 방금 풀어낸 디렉토리여서 알겠지만 고유값은 과연 어디있을까요? User 디렉토리 하위 Library/Developer/CoreSimulator/Devices/ 에 Simulator Devices 들이 존재합니다.

ls ~/Library/Developer/CoreSimulator/Devices/
2AA64BA2-1B71-4FBA-9735-294CC97715BCABSD
[....]

이런식으로 굉장히 많습니다. 물론 이 데이터들에 대한 정보는 device_set.plist 파일에 xml로 잘 정리되어있습니다.

cat ~/Library/Developer/CoreSimulator/Devices/device_set.plist

~/Library/Developer/CoreSimulator/Devices/device_set.plist

xcrun simctl install 2AA64BA2-1B71-4FBA-9735-294CC97715BCABSD ./test.app

App install script #

매번 설치마다 디바이스를 찾기는 번거롭습니다. 그리고 때에 따라 모든 Simulator에 설치가 필요할 상황도 있죠.

ad=$1
echo "Install" $ad
nowdir=$(pwd)
cd ~/Library/Developer/CoreSimulator/Devices/
devices=$(ls -d */)
cd "$nowdir"
for device in $devices
do
    device_id=${device%/}
    xcrun simctl install "$device_id" "$ad"
done