Bringing a package under the hood of Xcode - maybe OT ?

Andrew Udvare audvare at gmail.com
Fri Jan 11 23:05:59 UTC 2019



> On 2019-01-11, at 16:27, Ryan Schmidt <ryandesign at macports.org> wrote:
> 
> To cross-compile for iOS, you would presumably need to tell the build system what architecture(s) to build for and what SDK to use. Often, that can be done by adding the right -arch flags to the CFLAGS, CXXFLAGS, OBJCFLAGS, OBJCXXFLAGS, and LDFLAGS environment variables, and adding the right -syslibroot flag (pointing to the iOS SDK you want to use) to the CFLAGS, CXXFLAGS, OBJCFLAGS, and OBJCXXFLAGS variables, and adding the right -Wl,-syslibroot, flag (pointing to the right iOS SDK) to the LDFLAGS.

On current macOS and Xcode, this is done like so:

env CC=clang CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -target arm-apple-darwin -arch arm64' ./configure --build=x86_64-apple-darwin --host=arm-apple-darwin
make

You'll see the dylib file has aarch64 architecture:

 $ file ./artnet/.libs/libartnet.1.dylib
./artnet/.libs/libartnet.1.dylib: Mach-O 64-bit arm64 dynamically linked shared library, flags:<|DYLDLINK|NO_REEXPORTED_DYLIBS>

But this only builds a library (dylib) and on iOS you don't directly load libraries. With the given output from libarinet, if you want it as a separate library, you have to make a framework and bundle that with your app (allowed since iOS 8).

Any binaries compiled this way will only work on a jailbroken due to lack of code signing.

--
Andrew


More information about the macports-users mailing list