Cocoa 32 bit and 64 bit binaries within app
My latest Mac App got rejected from the Mac App Store.
Basically it didn't work due to a self contained unix executable contained within the app. I have included a binary within my app before, that app is in the Mac App Store but this unix binary is giving me troubles.
I have compiled 2 different versions of this binary on a i386 machine and the other on x86_64 machine. Using "file appname", I get for the 64 bit binary
Mach-O 64-bit executable x86_64
and the 32 bit binary
Mach-O executable i386
At runtime I try to execute 开发者_运维问答the correct binary but I noticed doesn't seem to matter? Which binary I use, I can execute the x86_64 on and i386 machine and things work fine.
My application build settings are what comes with the default project (standard 32/64 bit intel).
The question is should I attempt to run the 32 bit binary when I the app is running on an i386 machine?
And why does my x86_64 binary work when I run this on a i386 machine?Thanks, John.
Why are you not building your Unix tool as a universal binary? Then the operating system will pick the correct version of the binary to run based on the machine's architecture.
EDIT - to add my comment as part of the proper answer.
You need to build the i386 and x86_64 binaries. Obviously, you need to build the exe and all the dependencies for both architectures. It may be enough to use the gcc flag -arch=i386 everywhere for the i386 architecture. Then you can use lipo to combine the two binaries.
You are making things too complicated. You do not need a 64bit machine to build the 64bit binary, nor is it a problem to build the 32bit binary on the 64bit machine.
GCC and thus XCode easilly supports building of either 32bit universal, or 32/64bit Universal images so you don't have to worry at all about running the correct one.
精彩评论