@@ -51,14 +51,49 @@ jobs:
5151 | grep -m1 "platform:iOS Simulator" || true
5252 )
5353
54- DEVICE_UDID=$(echo "${DEST_LINE}" | sed -n 's/.*id:\([^,}]*\ ).*/\1/p' | tr -d ' ')
54+ DEVICE_UDID=$(echo "${DEST_LINE}" | sed -n 's/.*id:\([0-9A-F-]\{36\}\ ).*/\1/p')
5555
5656 if [[ -z "${DEVICE_UDID:-}" ]]; then
57- echo "No usable iOS Simulator destination found for scheme SOPA."
58- xcodebuild -project SOPA.xcodeproj -scheme SOPA -showdestinations
59- exit 1
57+ echo "No concrete simulator destination found, creating one via simctl."
58+
59+ RUNTIME_ID=$(
60+ xcrun simctl list runtimes available \
61+ | sed -n 's/.*(\(com\.apple\.CoreSimulator\.SimRuntime\.iOS-[^)]*\)).*/\1/p' \
62+ | tail -n 1
63+ )
64+
65+ DEVICE_TYPE_ID=$(
66+ xcrun simctl list devicetypes \
67+ | sed -n 's/.*iPhone 16.*(\(com\.apple\.CoreSimulator\.SimDeviceType\.[^)]*\)).*/\1/p' \
68+ | head -n 1
69+ )
70+
71+ if [[ -z "${DEVICE_TYPE_ID:-}" ]]; then
72+ DEVICE_TYPE_ID=$(
73+ xcrun simctl list devicetypes \
74+ | sed -n 's/.*iPhone.*(\(com\.apple\.CoreSimulator\.SimDeviceType\.[^)]*\)).*/\1/p' \
75+ | head -n 1
76+ )
77+ fi
78+
79+ if [[ -z "${RUNTIME_ID:-}" || -z "${DEVICE_TYPE_ID:-}" ]]; then
80+ echo "Unable to resolve runtime/device type for simulator creation."
81+ xcrun simctl list runtimes available
82+ xcrun simctl list devicetypes
83+ exit 1
84+ fi
85+
86+ DEVICE_UDID=$(xcrun simctl create "SOPA-CI-iPhone" "${DEVICE_TYPE_ID}" "${RUNTIME_ID}")
87+
88+ if [[ -z "${DEVICE_UDID:-}" ]]; then
89+ echo "Failed to create simulator device."
90+ exit 1
91+ fi
6092 fi
6193
94+ xcrun simctl boot "${DEVICE_UDID}" || true
95+ xcrun simctl bootstatus "${DEVICE_UDID}" -b || true
96+
6297 echo "destination=id=${DEVICE_UDID}" >> "$GITHUB_OUTPUT"
6398 echo "Using destination id=${DEVICE_UDID}"
6499
0 commit comments