skip to Main Content

I want to port my MacApp to a universal build including binaries for the new Apple Silicon Arm64 chips.

Besides being on Xcode 12.1, using the Standard Architectures build setting, what else do I need to do? My scheme only shows Any Mac (Intel)

2

Answers


  1. You should definitely read Apple’s official guide on this topic: https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary
    The process is very well covered there.

    Also, Apple has one more guide for Apple Silicon: https://developer.apple.com/documentation/xcode/porting_your_macos_apps_to_apple_silicon
    It’s also a must-read.

    So the first step is obviously to update the architectures list.
    Current MacMini/Macbooks have x86_64, Apple Silicon has arm64 and so on.

    The you should compile, and remove all compile errors one by one.

    When building my app for Apple Silicon, I’ve faced such issues:

    Wrap platform-specific code (this headline copied from Apple tutorial 🙂 )

    e.g.

    #if os(macOS)
       // Put CPU-independent macOS code here.
       #if arch(arm64)
          // Put 64-bit arm64 Mac code here.
       #elseif arch(x86_64)
          // Put 64-bit x86_64 Mac code here.
       #endif
    #elseif targetEnvironment(macCatalyst)
       // Put Mac Catalyst-specific code here.
    #elseif os(iOS)
       // Put iOS-specific code here.
    #endif
    
    

    Build fat libraries (this is a custom explanation 🙂 )

    You app may use any C/C++ static/dynamic libs, such as Curl,OpenSSL etc.
    In order to make an app universal, you should make sure that all these libs contain the code for all platforms.
    lipo will be you friend here (this is also covered in a guide).
    An example of building a static lib for Apple Silicon: https://cutecoder.org/programming/compile-open-ssl-apple-silicon/

    I’m not sure I’ve fully covered your question, so please ask more details and I’ll clarify.

    Login or Signup to reply.
  2. Xcode 12.1 does not have the macOS 11 SDK, which you need to compile for Apple Silicon. Until macOS 11 ships, you will have to download a beta version of Xcode 12 that includes the macOS 11 SDK, such as the Xcode 12.2 beta.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search