Igor Karpov Igor Karpov - 3 months ago 24
C Question

Xcode 7: Set Preprocessor Macros per architecture

I need to set

Preprocessor Macro
just for specific architecture (arm64). How can I do this?

There is similar question here on Stackoverflow: Xcode 6: Set Preprocessor Macros per architecture.
But in my case
Xcode 7
just doesn’t let me to choose the architecture. Tried on
with the same result: the only architecture option offered by Xcode is “*” (see the picture below).
Preprocessor settings section

Just in case here are my Architectures settings:
Architectures settings section

To give you more understanding why do I actually need this:
I use 3rd-party C-library which relies on a flag set to tell it if it is running on a 32-bit or 64-bit platform.
Note from library's integration guide: “When building for the 64-bit architecture, the
macro must be added in the pre-processor macro section of Xcode.”

So here is what I've tried:

  • to find a way to set architecture-specific macro in Xcode UI (described above)

  • to amend
    file manually by replacing
    [arch=*] with
    [arch=arm64] (didn’t give desired effect)

Do you have any ideas what is wrong with my
settings, why doesn’t it show architecture options in
section? Or are there other ways to configure macro in my case?


Finally I've figured it out.

Achieved result: _64BIT macro would be added during preprocessing to every (at least known for today) 64-bit environment, regardless of is it a simulator of 64-bit device or a real 64-bit device.

The solution is to manually edit .pbxproj-file as follows:

            "GCC_PREPROCESSOR_DEFINITIONS[arch=arm64]" = (
            "GCC_PREPROCESSOR_DEFINITIONS[arch=x86_64]" = (

So here is debug-config:

  • first section defines default macros which would be applied for all architectures;
  • 2nd and 3rd define custom macros which would be applied to specific architecture only.

Then changes that you've done manually would be visible within Preprocessor settings editor. It really looks like bug in Xcode in the editor.

You can notice that I've already tried this approach before posting the question, but I've misinterpreted the results of my attempt. The thing is that I've tested my app on the simulator, and architectures are different on real device and corresponding simulator. I've configured macro to be included on arm64 architecture, but simulator's actual architecture was x86_64.

For further reference, this article explains where does every architecture actually take place:

  • arm7: Used in the oldest iOS 7-supporting devices
  • arm7s: As used in iPhone 5 and 5C
  • arm64: For the 64-bit ARM processor in iPhone 5S [and I believe the same is for newer iPhones]
  • i386: For the 32-bit simulator
  • x86_64: Used in 64-bit simulator

For i386 and x86_64 "bitness" of simulated device is implied here, not your Mac's.