Skip to content

Commit 3ca49cb

Browse files
thymikeeclaude
andcommitted
fix(limrun): start the iOS runner under the hosts' Xcode 27
Limrun hosts now run XCTest with Xcode 27. A runner built with Xcode 26 embeds XCTest 26 and its test host crashes at startup there. Build the release runner with Xcode 27, point Runner.xctestrun at the host's platform XCTest through DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH, and refuse a runner that still embeds XCTest.framework. Fixes #4301 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 83945b7 commit 3ca49cb

7 files changed

Lines changed: 40 additions & 34 deletions

File tree

‎.github/workflows/release-ios-runner.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ jobs:
5252
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5353
shell: bash
5454

55-
# Limrun simulators run iOS 26 and cannot reach this machine's Xcode. Xcode 26 embeds XCTest in
56-
# the runner app; Xcode 27 leaves it out, and the packaging step refuses such a runner.
57-
- name: Select Xcode 26
55+
# Limrun hosts run XCTest with Xcode 27 and load XCTest from that Xcode. A runner built with an
56+
# older Xcode embeds its own XCTest, which crashes there, and the packaging step refuses it.
57+
- name: Select Xcode 27
5858
run: |
5959
set -euo pipefail
60-
XCODE_APP="$(ls -d /Applications/Xcode_26*.app | sort -V | tail -n 1)"
60+
XCODE_APP="$(ls -d /Applications/Xcode_27*.app | sort -V | tail -n 1)"
6161
echo "DEVELOPER_DIR=${XCODE_APP}/Contents/Developer" >> "$GITHUB_ENV"
6262
echo "Using ${XCODE_APP}"
6363
shell: bash

‎scripts/package-ios-simulator-runner.sh‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,12 @@ if [ -n "$EXPECTED_RUNNER_BUNDLE_ID" ] && [ "$RUNNER_BUNDLE_ID" != "$EXPECTED_RU
9292
fi
9393

9494
ditto "$RUNNER_APP_PATH" "$STAGED_APP_PATH"
95-
# Remote simulators cannot resolve dependencies from the build machine's Xcode paths, so the runner
96-
# must carry XCTest itself. Xcode 26 embeds it; Xcode 27 leaves it out, and Limrun simulators run iOS 26.
97-
if [ ! -d "$STAGED_APP_PATH/Frameworks/XCTest.framework" ]; then
98-
echo "The runner app does not embed XCTest.framework. Build the simulator runner with Xcode 26 (set DEVELOPER_DIR to an Xcode 26 install): Xcode 27 resolves XCTest from the build machine, which a remote simulator cannot reach." >&2
95+
# Limrun hosts run XCTest with Xcode 27, which loads XCTest from its own platform directory. A runner
96+
# that embeds XCTest.framework comes from an older Xcode, and its test host crashes there.
97+
if [ -d "$STAGED_APP_PATH/Frameworks/XCTest.framework" ]; then
98+
echo "The runner app embeds XCTest.framework. Build the simulator runner with Xcode 27 (set DEVELOPER_DIR to an Xcode 27 install): Limrun hosts load XCTest from their own Xcode 27, and an older embedded copy crashes the test host." >&2
9999
exit 1
100100
fi
101-
PLATFORM_PATH="$(xcrun --sdk iphonesimulator --show-sdk-platform-path)"
102-
# Newer Xcode 26 releases link Testing.framework against this library; Xcode 26.2 ships none.
103-
INTEROP_LIBRARY="$PLATFORM_PATH/Developer/usr/lib/lib_TestingInterop.dylib"
104-
if [ -f "$INTEROP_LIBRARY" ]; then
105-
cp "$INTEROP_LIBRARY" "$STAGED_APP_PATH/Frameworks/"
106-
fi
107-
# Swift Testing loads overlays at runtime; keep them from the same toolchain as its bundled framework.
108-
if [ -d "$STAGED_APP_PATH/Frameworks/Testing.framework" ]; then
109-
for FRAMEWORK in "$PLATFORM_PATH"/Developer/Library/Frameworks/_Testing_*.framework; do
110-
if [ -d "$FRAMEWORK" ]; then
111-
ditto "$FRAMEWORK" "$STAGED_APP_PATH/Frameworks/$(basename "$FRAMEWORK")"
112-
fi
113-
done
114-
fi
115101
rm -f "$ARCHIVE_PATH"
116102
(
117103
cd "$STAGE_DIR"

‎src/core/interactors/limrun-ios-runner-products.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ test('a normal app without a test bundle reports the invalid runner path', async
3232
expect(fetch).not.toHaveBeenCalled();
3333
});
3434

35-
test('a runner built without its own XCTest is refused before it reaches Limrun', async () => {
35+
test('a runner that embeds its own XCTest is refused before it reaches Limrun', async () => {
3636
const directory = await mkdtempForTest('runner-products-');
3737
const appPath = path.join(directory, 'AgentDeviceRunnerUITests-Runner.app');
38-
// An Xcode 27 build: the test bundle is there, the XCTest frameworks are not.
38+
// An Xcode 26 build: the runner app carries XCTest, which crashes under the host's Xcode 27.
3939
await fs.mkdir(path.join(appPath, 'PlugIns', 'AgentDeviceRunnerUITests.xctest'), {
4040
recursive: true,
4141
});
42+
await fs.mkdir(path.join(appPath, 'Frameworks', 'XCTest.framework'), { recursive: true });
4243
const fetch = vi.fn();
4344
vi.stubGlobal('fetch', fetch);
4445
await expect(
@@ -52,7 +53,7 @@ test('a runner built without its own XCTest is refused before it reaches Limrun'
5253
}),
5354
).rejects.toMatchObject({
5455
code: 'INVALID_ARGS',
55-
message: 'The Limrun XCTest runner does not embed XCTest.framework',
56+
message: 'The Limrun XCTest runner embeds XCTest.framework from an Xcode older than 27',
5657
details: { reason: 'limrun_runner_products_invalid' },
5758
});
5859
expect(fetch).not.toHaveBeenCalled();

‎src/core/interactors/limrun-ios-runner-products.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ export async function prepareLimrunRunnerProducts(input: {
119119
'INVALID_ARGS',
120120
);
121121
}
122-
// A remote simulator cannot reach the build machine's Xcode, so the runner must carry XCTest
123-
// itself. Xcode 26 embeds it in the runner app; Xcode 27 leaves it out and resolves it from the
124-
// build machine, so such a runner never starts on a Limrun simulator.
125-
const xctest = await fs
122+
// Limrun hosts drive XCTest with Xcode 27, which loads XCTest from its own platform directory
123+
// (see TestingEnvironmentVariables below). A runner that embeds XCTest.framework was built with
124+
// an older Xcode, and its test host crashes at startup there.
125+
const embeddedXctest = await fs
126126
.stat(path.join(appPath, 'Frameworks', 'XCTest.framework'))
127127
.catch(() => null);
128-
if (!xctest?.isDirectory()) {
128+
if (embeddedXctest?.isDirectory()) {
129129
throw limrunRunnerError(
130130
'limrun_runner_products_invalid',
131-
'The Limrun XCTest runner does not embed XCTest.framework',
131+
'The Limrun XCTest runner embeds XCTest.framework from an Xcode older than 27',
132132
{
133-
hint: 'Build and package the simulator runner with Xcode 26, for example with DEVELOPER_DIR set to an Xcode 26 install.',
133+
hint: 'Build and package the simulator runner with Xcode 27, for example with DEVELOPER_DIR set to an Xcode 27 install.',
134134
},
135135
'INVALID_ARGS',
136136
);
@@ -160,6 +160,10 @@ ${Object.entries(RUNNER_XCTESTRUN_CAPTURE_OPTIONS)
160160
.map(([key, value]) => `<key>${key}</key>${string(value)}`)
161161
.join('')}
162162
<key>OnlyTestIdentifiers</key><array><string>RunnerTests/testCommand</string></array>
163+
<key>TestingEnvironmentVariables</key><dict>
164+
<key>DYLD_FRAMEWORK_PATH</key><string>__PLATFORMS__/iPhoneSimulator.platform/Developer/Library/Frameworks</string>
165+
<key>DYLD_LIBRARY_PATH</key><string>__PLATFORMS__/iPhoneSimulator.platform/Developer/usr/lib</string>
166+
</dict>
163167
<key>EnvironmentVariables</key><dict>${Object.entries(environment)
164168
.map(([key, value]) => `<key>${key}</key>${string(value)}`)
165169
.join('')}</dict>

‎src/core/interactors/limrun-ios-runner.fixtures.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type RunnerFixture = {
3535
requests: string[];
3636
readonly manifest: Manifest | undefined;
3737
readonly environment: Record<string, string>;
38+
readonly testingEnvironment: Record<string, string>;
3839
readonly command: Record<string, unknown> | undefined;
3940
readonly testRun: ServerResponse | undefined;
4041
};
@@ -64,13 +65,13 @@ export async function fixture(
6465
const directory = await mkdtempForTest('limrun-runner-');
6566
const app = path.join(directory, 'AgentDeviceRunnerUITests-Runner.app');
6667
await fs.mkdir(path.join(app, 'PlugIns', 'AgentDeviceRunnerUITests.xctest'), { recursive: true });
67-
await fs.mkdir(path.join(app, 'Frameworks', 'XCTest.framework'), { recursive: true });
6868
await fs.writeFile(path.join(app, 'Runner'), 'simulator runner', { mode: 0o755 });
6969
const requests: string[] = [];
7070
const commands: Record<string, unknown>[] = [];
7171
let manifest: Manifest | undefined;
7272
const uploads: Manifest[] = [];
7373
const environment: Record<string, string> = {};
74+
let testingEnvironment: Record<string, string> = {};
7475
let command: Record<string, unknown> | undefined;
7576
let testRun: ServerResponse | undefined;
7677
let admitted: ServerResponse | undefined;
@@ -214,6 +215,12 @@ export async function fixture(
214215
new RegExp(`<key>AGENT_DEVICE_RUNNER_${key}</key><string>(.*?)</string>`),
215216
)![1]!;
216217
}
218+
const testing = xml.match(/<key>TestingEnvironmentVariables<\/key><dict>(.*?)<\/dict>/s);
219+
testingEnvironment = Object.fromEntries(
220+
[...(testing?.[1] ?? '').matchAll(/<key>(.*?)<\/key><string>(.*?)<\/string>/g)].map(
221+
([, key, value]) => [key!, value!],
222+
),
223+
);
217224
response.end(JSON.stringify({ ok: true }));
218225
return;
219226
}
@@ -315,6 +322,9 @@ export async function fixture(
315322
get environment() {
316323
return environment;
317324
},
325+
get testingEnvironment() {
326+
return testingEnvironment;
327+
},
318328
get command() {
319329
return command;
320330
},

‎src/core/interactors/limrun-ios-runner.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ test('stages a token-authenticated runner once and presents forwarded XCTest sna
2929
});
3030
expect(f.environment.BIND_IP).toBe('10.244.1.2');
3131
expect(f.environment.TOKEN?.length).toBeGreaterThanOrEqual(32);
32+
// The host's Xcode 27 resolves the runner's @rpath XCTest from its own simulator platform.
33+
expect(f.testingEnvironment).toEqual({
34+
DYLD_FRAMEWORK_PATH: '__PLATFORMS__/iPhoneSimulator.platform/Developer/Library/Frameworks',
35+
DYLD_LIBRARY_PATH: '__PLATFORMS__/iPhoneSimulator.platform/Developer/usr/lib',
36+
});
3237
expect((f.manifest?.files.find((f) => f.path === 'Runner.app/Runner')?.mode ?? 0) & 0o111).toBe(
3338
0o111,
3439
);

‎website/docs/docs/limrun.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Open your app before taking a snapshot. Snapshots target the app you opened in t
125125

126126
`install` leaves your app stopped. Use `open` to launch it. To change launch arguments on an app that is already running, use `open --relaunch --launch-args`. Screenshots download as lossless PNG files, and recording downloads the finished MP4 when you stop it. Push notifications use the same command and payload format as local simulators.
127127

128-
If you use a nightly or unpublished agent-device build, obtain a matching packaged iOS runner from the build's maintainer. Set `AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP` to the extracted `.app` path before starting agent-device. The runner must be built with Xcode 26, because Limrun simulators run iOS 26 and an Xcode 27 build does not include the XCTest frameworks it needs there; agent-device refuses such a runner. If the daemon is already running, stop it with `agent-device daemon stop` using the same `--state-dir`, then reconnect.
128+
If you use a nightly or unpublished agent-device build, obtain a matching packaged iOS runner from the build's maintainer. Set `AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP` to the extracted `.app` path before starting agent-device. The runner must be built with Xcode 27, because Limrun runs XCTest with Xcode 27. agent-device refuses a runner built with an older Xcode. If the daemon is already running, stop it with `agent-device daemon stop` using the same `--state-dir`, then reconnect.
129129

130130
## Connect an iOS app to Metro
131131

0 commit comments

Comments
 (0)