Xcode12|Xcode12 编译报错: built for iOS, for architecture arm64...

升级Xcode12后,编译项目时,可能会出现以下错误:
building for iOS Simulator, but linking in object:

building for iOS Simulator, but linking in object ... file built for iOS, for architecture arm64

Embedded binary is not signed with the same certificate:
Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's. Embedded Binary Signing Certificate: XXX Parent App Signing Certificate: XXX

.app" couldn’t be opened because you don’t have permission to view it.:
The file "XXX.app" couldn’t be opened because you don’t have permission to view it.

产生这些报错的根本原因是新版本的Xcode 12更改了编译架构的设置方式:
旧版本的Xcode编译架构设置方式: 用Xcode打开项目 -> Project -> PROJECT -> Build Setting ->
  1. 首先在Architectures -> Valid Architectures -> 设置可用的编译架构指令集
  2. 然后在User-Defined -> EXCLUDED_ARCHS -> 设置排除的编译架构指令集
而新版Xcode12的编译架构设置方式: 用Xcode打开项目 -> Project -> PROJECT -> Build Setting ->
  1. 首先在Architectures -> Excluded Architectures -> 排除的编译架构指令集
  2. 然后在User-Defined -> VALID_ARCHS -> 设置可用的编译架构指令集
【Xcode12|Xcode12 编译报错: built for iOS, for architecture arm64...】因此,解决上述问题的方案就是在新版的Xcode12中设置:
  1. 在Architectures -> Excluded Architectures -> 设置排除的编译架构指令集为"arm64"。(建议只设置Debug模式,Release模式还是要支持arm64的,否则打包后无法在真机上海安装)
  2. 同时,删除User-Defined中的VALID_ARCHS栏,即可用的编译架构指令集的设置(操作方法:选择PROJECT -> Build Setting ->User-Defined ->选中VALID_ARCHS,直接按Delete键)。

    推荐阅读