From c828be8583c5480adf9de8ebf679d9f72d92d24d Mon Sep 17 00:00:00 2001 From: yangchao <1162485779@qq.com> Date: Mon, 17 Aug 2026 18:32:48 +0800 Subject: [PATCH 1/2] update cmake version to 4.4.2 --- workflow/download-tools.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/download-tools.js b/workflow/download-tools.js index 74b109d6b..db90ef59e 100644 --- a/workflow/download-tools.js +++ b/workflow/download-tools.js @@ -59,7 +59,7 @@ const tools = { essential: true, }, { - url: 'http://download.cocos.com/CocosSDK/tools/cmake-3.24.3-windows-x86_64.zip', + url: 'http://download.cocos.com/CocosSDK/tools/cmake-4.4.2-windows-x86_64.zip', dist: 'cmake', essential: true, }, @@ -110,7 +110,7 @@ const tools = { essential: true, }, { - url: 'http://download.cocos.com/CocosSDK/tools/cmake-3.24.3-macos-universal.zip', + url: 'http://download.cocos.com/CocosSDK/tools/cmake-4.4.2-macos-universal.zip', dist: 'cmake', essential: true, }, From a41d2538e5f4be27f28ebfb3ef41eafb5c8d022c Mon Sep 17 00:00:00 2001 From: yangchao <1162486779@qq.com> Date: Tue, 18 Aug 2026 12:20:24 +0800 Subject: [PATCH 2/2] fix(ios): select simulator arch based on Xcode version --- .../native-common/pack-tool/platforms/ios.ts | 13 ++----- .../pack-tool/platforms/mac-os.ts | 38 ++++++++++++++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/core/builder/platforms/native-common/pack-tool/platforms/ios.ts b/src/core/builder/platforms/native-common/pack-tool/platforms/ios.ts index 5994e0ed4..6c317ed79 100644 --- a/src/core/builder/platforms/native-common/pack-tool/platforms/ios.ts +++ b/src/core/builder/platforms/native-common/pack-tool/platforms/ios.ts @@ -1,9 +1,9 @@ -import { execSync, spawn } from 'child_process'; +import { execSync } from 'child_process'; import * as fs from 'fs-extra'; import * as ps from 'path'; import * as os from 'os'; import { CocosParams } from '../base/default'; -import { cchelper, toolHelper, Paths } from '../utils'; +import { cchelper, toolHelper } from '../utils'; import { MacOSPackTool } from './mac-os'; export interface IOrientation { @@ -133,13 +133,8 @@ export default class IOSPackTool extends MacOSPackTool { throw new Error('Error: Try to build iphoneos application but no developer team id was given!'); } const nativePrjDir = this.paths.nativePrjDir; - + const simulatorArch = this.getIosSimulatorArch(); const projName = this.params.projectName; - const os = require('os'); - const cpus = os.cpus(); - const model = (cpus && cpus[0] && cpus[0].model) ? cpus[0].model : ''; - // check mac architecture - // const platform = /Apple/.test(model) ? `-arch arm64` : `-arch x86_64`; // get xcode workspace const regex = new RegExp(projName + '.xcworkspace$'); const files = fs.readdirSync(nativePrjDir); @@ -163,7 +158,7 @@ export default class IOSPackTool extends MacOSPackTool { await toolHelper.runCmake([projCompileParams, '-sdk', 'iphoneos', `-arch arm64`]); } if (options.simulator) { - await toolHelper.runCmake([projCompileParams, '-sdk', 'iphonesimulator', `-arch x86_64`]); //force compile x86_64 app for iPhone simulator on Mac + await toolHelper.runCmake([projCompileParams, '-sdk', 'iphonesimulator', `-arch ${simulatorArch}`]); } } return true; diff --git a/src/core/builder/platforms/native-common/pack-tool/platforms/mac-os.ts b/src/core/builder/platforms/native-common/pack-tool/platforms/mac-os.ts index 66391280e..13d7e4169 100644 --- a/src/core/builder/platforms/native-common/pack-tool/platforms/mac-os.ts +++ b/src/core/builder/platforms/native-common/pack-tool/platforms/mac-os.ts @@ -51,10 +51,36 @@ export abstract class MacOSPackTool extends NativePackTool { return /Apple/.test(model) && process.platform === 'darwin'; } - protected getXcodeMajorVerion(): number { + protected compareVersion(a: string, b: string): number { + const aParts = a.split('.').map((part) => Number.parseInt(part, 10) || 0); + const bParts = b.split('.').map((part) => Number.parseInt(part, 10) || 0); + const maxLength = Math.max(aParts.length, bParts.length); + + for (let i = 0; i < maxLength; i++) { + const aValue = aParts[i] ?? 0; + const bValue = bParts[i] ?? 0; + if (aValue !== bValue) { + return aValue - bValue; + } + } + + return 0; + } + + protected getXcodeVersion(): string { try { const output = execSync('xcrun xcodebuild -version').toString('utf8'); - return Number.parseInt(output.match(/Xcode\s(\d+)\.\d+/)![1]); + const match = output.match(/Xcode\s+(\d+(?:\.\d+)+)/); + return match?.[1] || '0.0'; + } catch (e) { + console.error(e); + return '0.0'; + } + } + + protected getXcodeMajorVerion(): number { + try { + return Number.parseInt(this.getXcodeVersion().split('.')[0] || '0', 10); } catch (e) { console.error(e); // fallback to default Xcode version @@ -62,6 +88,14 @@ export abstract class MacOSPackTool extends NativePackTool { } } + protected getIosSimulatorArch(): 'arm64' | 'x86_64' { + // Xcode 14.3+ no longer supports running iOS Simulator under Rosetta on Apple Silicon. + if (this.isAppleSilicon() && this.compareVersion(this.getXcodeVersion(), '14.3') >= 0) { + return 'arm64'; + } + return 'x86_64'; + } + async modifyXcodeProject() { if (this.params.platformParams.skipUpdateXcodeProject) { if (this.getXcodeMajorVerion() < 12) {