Reputation: 21
I need to set Preprocessor Macro
in Xcode
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 Xcode
versions 7.1.1
and 7.3.1
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 _64BIT
macro must be added in the pre-processor macro section of Xcode.”
So here is what I've tried:
.pbxproj
file manually by replacing GCC_PREPROCESSOR_DEFINITIONS
[arch=*] with GCC_PREPROCESSOR_DEFINITIONS
[arch=arm64] (didn’t give desired effect)Do you have any ideas what is wrong with my Xcode
settings, why doesn’t it show architecture options in Preprocessor
section? Or are there other ways to configure macro in my case?
Upvotes: 1
Views: 1643
Reputation: 21
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 = (
"DEBUG=1",
"$(inherited)",
);
"GCC_PREPROCESSOR_DEFINITIONS[arch=arm64]" = (
"$(inherited)",
_64BIT,
);
"GCC_PREPROCESSOR_DEFINITIONS[arch=x86_64]" = (
"$(inherited)",
_64BIT,
);
So here is debug-config:
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:
For i386 and x86_64 "bitness" of simulated device is implied here, not your Mac's.
Upvotes: 1