Compare commits

...
3 changed files with 70 additions and 3 deletions

No files matched your search

@@ -0,0 +1,5 @@
---
'@expo/build-tools': patch
---
Report an iOS Simulator app install that fails with "Requires a Newer Version of iOS" as the user error `EAS_INSTALL_APPLICATION_REQUIRES_NEWER_IOS`, with a message that asks for a Simulator device whose iOS version meets the app's minimum, or a lower iOS deployment target. Other install failures still report `SERVER_ERROR`.
@@ -1,3 +1,4 @@
import { ExpoError, SystemError, UserError } from '@expo/eas-build-job';
import { once } from 'node:events';
import {
access,
@@ -101,6 +102,49 @@ it.each([
expect(attempts).toBe(1);
});
// Shaped like `xcrun simctl install` output for an app whose minimum iOS version is above the Simulator runtime.
const NEWER_IOS_REQUIRED_STDERR = [
'An error was encountered processing the command (domain=IXUserPresentableErrorDomain):',
'Requires a Newer Version of iOS',
'“Example” requires a newer version of iOS.',
].join('\n');
async function rejectActionAsync(action: string, stderr: string): Promise<ExpoError> {
server.on('connection', socket => {
socket.send(JSON.stringify({ ready: true }));
socket.on('message', () => socket.send(JSON.stringify({ id: 1, exitCode: 1, stderr })));
});
const error = await runServeSimActionAsync({ ...request(), action }).catch(err => err);
expect(error).toBeInstanceOf(ExpoError);
return error;
}
it('classifies an app install that requires a newer iOS version as a user error', async () => {
const error = await rejectActionAsync('app.install', NEWER_IOS_REQUIRED_STDERR);
expect(error).toBeInstanceOf(UserError);
expect(error.toExternalExpoError()).toMatchObject({
errorCode: 'EAS_INSTALL_APPLICATION_REQUIRES_NEWER_IOS',
message: expect.stringContaining('Choose an iOS Simulator device whose iOS version meets'),
});
expect((error.cause as Error).message).toContain('Requires a Newer Version of iOS');
});
it.each([
[
'app.install',
'An error was encountered processing the command (domain=IXUserPresentableErrorDomain):\nThis app could not be installed at this time.',
],
['app.install', 'install refused'],
['app.launch', NEWER_IOS_REQUIRED_STDERR],
])('keeps other %s failures as server errors', async (action, stderr) => {
const error = await rejectActionAsync(action, stderr);
expect(error).toBeInstanceOf(SystemError);
expect(error.toExternalExpoError()).toMatchObject({
errorCode: 'SERVER_ERROR',
message: `serve-sim ${action} failed: ${stderr}`,
});
});
it('rejects a connection that closes before its action finishes', async () => {
server.on('connection', socket => socket.close());
await expect(runServeSimActionAsync(request())).rejects.toThrow('closed before completion');
@@ -1,4 +1,4 @@
import { SystemError } from '@expo/eas-build-job';
import { SystemError, UserError } from '@expo/eas-build-job';
import { constants } from 'node:fs';
import { cp, mkdir, mkdtemp, realpath, rm } from 'node:fs/promises';
import os from 'node:os';
@@ -104,8 +104,11 @@ export async function runServeSimActionWithResultAsync({
finish(
reply.exitCode === 0
? undefined
: new SystemError(
`serve-sim ${action} failed: ${(typeof reply.error === 'string' && reply.error) || (typeof reply.stderr === 'string' && reply.stderr) || 'invalid response'}`
: createServeSimActionError(
action,
(typeof reply.error === 'string' && reply.error) ||
(typeof reply.stderr === 'string' && reply.stderr) ||
'invalid response'
),
typeof reply.stdout === 'string' ? reply.stdout : ''
);
@@ -116,3 +119,18 @@ export async function runServeSimActionWithResultAsync({
}
});
}
// simctl's IXUserPresentableErrorDomain message when the app's minimum iOS version is above the Simulator runtime.
const NEWER_IOS_REQUIRED_MESSAGE = 'Requires a Newer Version of iOS';
function createServeSimActionError(action: string, detail: string): Error {
const message = `serve-sim ${action} failed: ${detail}`;
if (action === 'app.install' && detail.includes(NEWER_IOS_REQUIRED_MESSAGE)) {
return new UserError(
'EAS_INSTALL_APPLICATION_REQUIRES_NEWER_IOS',
"This app requires a newer iOS version than the selected iOS Simulator runs. Choose an iOS Simulator device whose iOS version meets the app's minimum iOS version, or lower the app's iOS deployment target.",
{ cause: new Error(message) }
);
}
return new SystemError(message);
}