Post

M4芯片的mac运行x86架构

M4芯片的mac运行x86架构

前言

由于项目里部分三方库已经很久远,支持的模拟器版本不包arm64-simulator架构,导致直接在新电脑上运行模拟器直接启动不了

1、三方库信息如下:
1
2
lipo -info /Users/xx/xxx/xxx.a 
Architectures in the fat file: /Users/xx/xxx/xxx.a are: armv7 armv7s i386 x86_64 arm64 
2、如果直接使用会报错

Building for 'iOS-simulator', but linking in object file xxx.a[arm64][2](xxx.o)) built for 'iOS'

3、因为这个原因,导致三方库的xxx.podspec需要添加如下内容
1
2
3
4
5
6
7
8
Pod::Spec.new do |s|
  s.name             = "xxx"
  ....
  s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
  s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
  ....
end

4、Xcode运行模拟器报错信息如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
提示信息:
Simulator device failed to launch com.xx.xxx.
Domain: FBSOpenApplicationServiceErrorDomain
Code: 1
Failure Reason: The request was denied by service delegate (SBMainWorkspace).
User Info: {
    BSErrorCodeDescription = RequestDenied;
    DVTErrorCreationDateKey = "2025-04-16 18:55:49 +0000";
    FBSOpenApplicationRequestID = 0x339d;
    IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher;
    SimCallingSelector = "launchApplicationWithID:options:pid:error:";
}
--
The request to open "com.xx.xxx" failed.
Domain: FBSOpenApplicationServiceErrorDomain
Code: 1
Failure Reason: The request was denied by service delegate (SBMainWorkspace).
User Info: {
    BSErrorCodeDescription = RequestDenied;
    FBSOpenApplicationRequestID = 0x339d;
}
--
The operation couldn’t be completed. The process failed to launch.
Domain: FBProcessExit
Code: 64
Failure Reason: The process failed to launch.
User Info: {
    BSErrorCodeDescription = "launch-failed";
}
--
The operation couldn’t be completed. Launch failed.
Domain: RBSRequestErrorDomain
Code: 5
Failure Reason: Launch failed.
--
Launchd job spawn failed
Domain: NSPOSIXErrorDomain
Code: 111
--
...省略。。。
System Information

macOS Version 15.3.2 (Build 24D81)
Xcode 16.0 (23051) (Build 16A242d)
Timestamp: 2025-04-16T11:55:49-07:00

解决方案 安装Rosetta 2,让M系列芯片的电脑也可以按x86_64的方式运行

1
/usr/sbin/softwareupdate --install-rosetta --agree-to-license

重启xcode运行运行即可

This post is licensed under CC BY 4.0 by the author.