XCode 可以在 M1 Mac 上构建原生 Intel 二进制文件吗 [英] Can XCode build native Intel binaries on a M1 Mac

查看:66
本文介绍了XCode 可以在 M1 Mac 上构建原生 Intel 二进制文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 M1 Mac 上使用 XCode 来构建本机 Intel 二进制文件?我想开始使用 M1 架构进行测试,但仍要继续构建原生英特尔应用程序,而无需进行任何更改.

Is it possible to use XCode on an M1 Mac to build a native Intel binary? I would like to start testing with the M1 architecture but still continue building native Intel Apps with having to make any changes.

推荐答案

M1 Mac 上的 Xcode 将构建通用二进制文件,其中包含 x86_64arm64 的切片.

Xcode on an M1 Mac will build a Universal Binary, with slices for both x86_64 and arm64.

您可以在 Apple 芯片或基于 Intel 的 Mac 计算机上构建通用二进制文件,但无法在基于 Intel 的 Mac 计算机上调试二进制文件的 arm64 切片.可以在 Apple 芯片上调试通用二进制文件的两个切片,但您必须在 Rosetta 转换下运行 x86_64 切片.

You can build a universal binary on either an Apple silicon or Intel-based Mac computer, but you cannot debug the arm64 slice of your binary on an Intel-based Mac computer. It’s possible to debug both slices of a universal binary on Apple silicon, but you must run the x86_64 slice under Rosetta translation.

来源:https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

在许多情况下,这会导致无需任何更改即可为两种架构编译代码,但如果您需要进行条件编译,则可以使用编译器标志(在上面链接的同一页面上列出).

In many cases, this results in code that can be compiled for both architectures without any changes, but there are compiler flags (listed on the same page linked above) if you need to do conditional compilation.

这篇关于XCode 可以在 M1 Mac 上构建原生 Intel 二进制文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆