Skip to content

Commit d6754c8

Browse files
bmehta001Copilot
andcommitted
Fix iOS CI simulator selection and docs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e86f8f9 commit d6754c8

4 files changed

Lines changed: 92 additions & 7 deletions

File tree

.github/workflows/build-ios-mac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: build
5656
run: |
5757
if [[ "${{ matrix.os }}" == "macos-14" ]]; then
58-
export IOS_DEPLOYMENT_TARGET=14.0;
58+
export IOS_DEPLOYMENT_TARGET=13.0;
5959
elif [[ "${{ matrix.os }}" == "macos-15" ]]; then
6060
export IOS_DEPLOYMENT_TARGET=15.0;
6161
fi

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Other resources to learn how to setup the build system:
9494
* **Supported** - these platforms are known to work well with the SDK in
9595
production.
9696
* **Covered by CI** - these platforms are tested as part of CI.
97+
* For iOS simulator, CI covers representative supported simulator
98+
configurations on the current macOS runner images rather than every
99+
supported iOS 12+ runtime.
97100

98101
## Test
99102

build-tests-ios.sh

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,74 @@ cd tests/unittests
1212
xcrun simctl list devices available
1313
echo 'End of xcrun simctl list devices available'
1414

15-
# Resolve simulator UUID to avoid ambiguous destination matching.
16-
# Grab the last (newest OS) available device matching the requested name.
17-
SIM_ID=$(xcrun simctl list devices available | grep "$SIMULATOR" | grep -oE '[A-F0-9-]{36}' | tail -1)
15+
# Resolve simulator UUID from simctl JSON using an exact name match.
16+
# If the same device name exists across multiple iOS runtimes, pick the
17+
# newest runtime and fail if that runtime still contains duplicate matches.
18+
SIM_JSON=$(mktemp)
19+
cleanup_sim_json() {
20+
rm -f "$SIM_JSON"
21+
}
22+
trap cleanup_sim_json EXIT
23+
xcrun simctl list devices available --json > "$SIM_JSON"
24+
SIM_MATCH=$(
25+
python3 - "$SIMULATOR" "$SIM_JSON" <<'PY'
26+
import json
27+
import re
28+
import sys
29+
from pathlib import Path
30+
31+
simulator_name = sys.argv[1]
32+
raw = Path(sys.argv[2]).read_text()
33+
json_start = raw.find('{')
34+
if json_start < 0:
35+
print("ERROR: simctl did not emit JSON", file=sys.stderr)
36+
raise SystemExit(1)
37+
38+
devices_by_runtime = json.loads(raw[json_start:]).get("devices", {})
39+
matches = []
40+
for runtime, devices in devices_by_runtime.items():
41+
if not runtime.startswith("com.apple.CoreSimulator.SimRuntime.iOS-"):
42+
continue
43+
44+
match = re.search(r"iOS-(\d+)(?:-(\d+))?$", runtime)
45+
if match is None:
46+
continue
47+
48+
version = tuple(int(part) for part in match.groups(default="0"))
49+
runtime_label = "iOS " + ".".join(str(part) for part in version)
50+
51+
for device in devices:
52+
if device.get("name") == simulator_name and device.get("isAvailable", True):
53+
matches.append((version, runtime_label, device["udid"]))
54+
55+
if not matches:
56+
print(f"ERROR: No available simulator found for '{simulator_name}'", file=sys.stderr)
57+
raise SystemExit(1)
58+
59+
newest_version = max(version for version, _, _ in matches)
60+
newest_matches = [(runtime_label, udid) for version, runtime_label, udid in matches if version == newest_version]
61+
62+
if len(newest_matches) != 1:
63+
print(f"ERROR: Multiple available simulators found for '{simulator_name}' in newest runtime:", file=sys.stderr)
64+
for runtime_label, udid in newest_matches:
65+
print(f" - {runtime_label}: {udid}", file=sys.stderr)
66+
raise SystemExit(1)
67+
68+
runtime_label, udid = newest_matches[0]
69+
print(f"{udid}|{runtime_label}")
70+
PY
71+
)
72+
cleanup_sim_json
73+
trap - EXIT
74+
SIM_ID=${SIM_MATCH%%|*}
75+
SIM_RUNTIME=${SIM_MATCH#*|}
1876

1977
if [ -z "$SIM_ID" ]; then
2078
echo "ERROR: No available simulator found for '$SIMULATOR'"
2179
exit 1
2280
fi
2381

24-
echo "Using simulator: $SIMULATOR (id=$SIM_ID)"
82+
echo "Using simulator: $SIMULATOR ($SIM_RUNTIME, id=$SIM_ID)"
2583

2684
xcodebuild test -scheme iOSUnitTests -destination "id=$SIM_ID"
2785

docs/cpp-start-ios.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,36 @@ Run `build-ios.sh [clean] [release|debug]` script in the root folder of the sour
1616

1717
Run `build-ios.sh [clean] [release|debug] [arm64|arm64e]`.
1818

19+
### Run iOS tests
20+
21+
Run `./build-tests-ios.sh [release|debug] "<simulator name>"`.
22+
23+
Example:
24+
25+
```sh
26+
./build-tests-ios.sh release "iPhone 17"
27+
```
28+
29+
Use a simulator name returned by `xcrun simctl list devices available`.
30+
The script resolves an exact device name from `simctl --json`, prefers the
31+
newest installed iOS runtime for that device name, and fails if that newest
32+
runtime still contains multiple matches.
33+
34+
If Xcode reports that the requested simulator runtime is missing, install it
35+
from Xcode > Settings > Components or run
36+
`xcodebuild -downloadPlatform iOS -architectureVariant arm64`.
37+
1938
## 3. Integrate the SDK into your C++ project
2039

21-
SDK package contains headers and library installed at the following locations:
40+
SDK package contains headers and library installed at the following locations
41+
by default:
2242

2343
* Headers: /usr/local/include/mat
24-
* Library: /usr/local/lib/${arch}/libmat.a
44+
* Library: /usr/local/lib/libmat.a
45+
46+
If you set a custom install prefix via
47+
`CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/path/to/install"`, the SDK is installed
48+
under `<prefix>/include/mat` and `<prefix>/lib/libmat.a`.
2549

2650
1DS SDK is built using cmake, but you can explore building it with any other build system of your choice.
2751

0 commit comments

Comments
 (0)