feat(ios): ignore --arch flag on simulators running iOS < 26 (#4917)

This commit is contained in:
Yaroslav Serhieiev
2026-03-21 14:45:57 +02:00
committed by GitHub
parent c1206bace8
commit 7fa811c851
2 changed files with 42 additions and 4 deletions
@@ -25,6 +25,10 @@ const SIMCTL_SET_PERMISSION_ACTIONS ={
};
class AppleSimUtils {
constructor() {
this._getMajorIOSVersion = _.memoize(this._getMajorIOSVersion.bind(this));
}
async setPermissions(udid, bundleId, permissionsObj) {
for (const [service, value] of Object.entries(permissionsObj)) {
switch (service) {
@@ -245,7 +249,8 @@ class AppleSimUtils {
async launch(udid, bundleId, launchArgs, languageAndLocale, arch) {
const frameworkPath = await environment.getFrameworkPath();
const result = await this._launchMagically(frameworkPath, udid, bundleId, launchArgs, languageAndLocale, arch);
const effectiveArch = arch && (await this._isArchArgumentAccessible(udid)) ? arch : undefined;
const result = await this._launchMagically(frameworkPath, udid, bundleId, launchArgs, languageAndLocale, effectiveArch);
await this._printLoggingHint(udid, bundleId);
return this._parseLaunchId(result);
@@ -274,9 +279,21 @@ class AppleSimUtils {
}
async _isSpringBoardInaccessible(udid) {
return (await this._getMajorIOSVersion(udid)) >= 16;
}
async _isArchArgumentAccessible(udid) {
const majorIOSVersion = await this._getMajorIOSVersion(udid);
if (majorIOSVersion < 26) {
log.warn({}, `--arch is not supported on iOS ${majorIOSVersion} (requires iOS 26+)`);
return false;
}
return true;
}
async _getMajorIOSVersion(udid) {
const device = await this._findDeviceByUDID(udid);
const majorIOSVersion = parseInt(device.os.version.split('.')[0]);
return majorIOSVersion >= 16;
return parseInt(_.get(device, 'os.version', '').split('.')[0]);
}
async _launchAndTerminateSettings(udid) {
@@ -27,13 +27,27 @@ describe('AppleSimUtils', () => {
});
});
it('should build --arch=x86_64 in simctl command when arch is set', async () => {
function givenArchArgumentAccessible(accessible) {
jest.spyOn(uut, '_isArchArgumentAccessible').mockResolvedValue(accessible);
}
it('should pass --arch=x86_64 when arch is set and iOS >= 26', async () => {
givenArchArgumentAccessible(true);
await uut.launch(udid, bundleId, {}, '', 'x86_64');
const launchCmd = childProcess.execWithRetriesAndLogs.mock.calls[0][0];
expect(launchCmd).toContain(`simctl launch --arch=x86_64 ${udid} ${bundleId}`);
});
it('should strip --arch when arch is set but iOS < 26', async () => {
givenArchArgumentAccessible(false);
await uut.launch(udid, bundleId, {}, '', 'x86_64');
const launchCmd = childProcess.execWithRetriesAndLogs.mock.calls[0][0];
expect(launchCmd).toContain(`simctl launch ${udid} ${bundleId}`);
expect(launchCmd).not.toContain('--arch');
});
it('should omit --arch when arch is undefined', async () => {
await uut.launch(udid, bundleId, {}, '');
@@ -41,5 +55,12 @@ describe('AppleSimUtils', () => {
expect(launchCmd).toContain(`simctl launch ${udid} ${bundleId}`);
expect(launchCmd).not.toContain('--arch');
});
it('should not query device version when arch is undefined', async () => {
const spy = jest.spyOn(uut, '_isArchArgumentAccessible');
await uut.launch(udid, bundleId, {}, '');
expect(spy).not.toHaveBeenCalled();
});
});
});