I'm trying to use architecture-specific build settings in my Xcode Framework so that I can handle the case of the Apple Silicon Mac and the Intel Mac separately. I need to use this build setting as a macro in Metal to check whether the half
data type is supported on the CPU (it's supported on Apple Silicon but not supported on Intel).
My current implementation uses an xcconfig file with the following line:
IS_X86_64[arch=x86_64] = 1
Then, in my build settings I have the following user-defined condition (from the xcconfig):
I then create the macro IS_INTEL
so it can be used in Metal:
Here's The Problem
In theory I feel like this should work. However, running my Metal app on my Intel mac yields 0
for IS_X86_64
. The first thing I did was check whether I set up my build setting correctly and replaced
IS_X86_64[arch=x86_64] = 1
with
IS_X86_64[arch=*] = 1
This worked so I knew that the problem had to be that my current architecture wasn't being represented correctly. Diving further into why this was happening, it turns out that the value for CURRENT_ARCH
(which should hold the value for the current device architecture that the project is being run on) is undefined_arch
.
In their Xcode 10 release notes, apple mentioned something about undefined_arch
saying:
The new build system passes undefined_arch as the value for the ARCH environment variable when running shell script build phases. The value was previously not well defined. Any shell scripts depending on this value must behave correctly for all defined architectures being built, available via the ARCHS environment variable.
However, I'm not building my project on the shell and I don't have any shell scripts. Does anyone know how I can fix this so that architecture-specific build settings behave as they should?