1
2 Comments

Building a MacOS universal binary (ARM64 + x86_64)

The new generation of Apple Macs and Macbooks come with a major change in the CPU. They have an Apple processor, the M1 Apple silicon chip, a RISC / ARM64 architecture.

Old intel based applications will continue to run under the Rosetta2 emulator. Applications compiled for ARM64 will run natively.

I am collecting here the steps needed to build a MacOS universal binary for our Software Product Analytics library, "SoftMeter".

I will keep updating this post until all steps are gathered and the library is relased.

  1. What needs to be done.
    ----------------------------------
    The library must be compiled as a "fat" (universal) binary. A universal binary looks no different than a regular app, but is a binary that contains two executables, one for the usual (until today) x86_64 for intel type of processors, and one for the Apple's M1 ARM64 processor. MacOS will choose which version to execute.

  2. What do you need to have
    --------------------------------------

  • The newly released xcode 12.2 or newer version.
  • You do not need a Apple silicon Mac to build universal applications. You can build it on your pre-2020 Mac.
  • If your application uses 3rd party compiled binaries (e.g. OpenSLL), you must obtain universal binaries for those libraries. Our SoftMeter, does not rely on any 3rd party libraries, so it can be compiled immetiatelly.
  1. Adjust your compilation (build) settings
    --------------------------------------------------------
    You only need to clear any custom setting you have put under the architecture settings. Xcode comes with the default,
    "Standard architectures (Apple silicon, Intel)" which is coded as
    ARCHS=arm64 x86_64.
    Also, make that the "build only active architecture" is NO.

  2. Verify that the compiled binary contains both architectures
    ----------------------------------------------------------------------------------
    In terminal run the command
    lifo -info path-to-your-binary-file
    For example if you run this command against our SoftMeter dylib,
    lipo -info libSoftMeter.dylib
    you will get the result:
    Architectures in the fat file: libSoftMeter.dylib are: x86_64 arm64
    Note: you must use the command for the binary file inside your app bundle (not the .app bundle itself). I.e. the file under
    myapp.app/contents/MacOS/myapp
    This works in the same way also for the screensaver bundles (.saver).

  3. Digitally sign your binary
    ------------------------------------
    Digitally signing your binary does not change. The "fat" binary is still a single file.

  4. Notarize your binary with Apple
    ---------------------------------------------
    Notarizing with Apple your binary does not change. The "fat" binary is still a single file.

.............

Appendix - Useful links
-------------------------------
Porting Your macOS Apps to Apple Silicon
https://developer.apple.com/documentation/xcode/porting_your_macos_apps_to_apple_silicon?language=objc

Building a Universal macOS Binary
https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary?language=objc

Our website post
https://www.starmessagesoftware.com/blog/compile-macos-desktop-application-arm64-apple-silicon-m1-chip-cpu

  1. 1

    This is not really true when comparing flagship models. Nevertheless, Apple has many fans worldwide, and they understand the company's concept. A Mac is not the same as a Windows computer, and you have to understand that. All the accessories and services will cost more. If you can build a pc yourself and choose the best components, in your opinion, the Best CPU for streaming and gaming, then mac you buy and use. I personally see a lot of pluses and minuses from both sides. So just choose what is closer to you and enjoy the superior technology.

  2. 1

    This is interesting. I like Apple products, but I think computers are overpriced.

Trending on Indie Hackers
I watch how IH is turning into a marketing sink, and I feel sad :( 47 comments Bootstrapped my SaaS to $20,000 MRR. AMA! 28 comments Bootstrapped my productivity app to 700 paying customers! AMA. 27 comments How we got our SEO clicks from 1 to 1200 a day 14 comments Which is the best free websites to promote your product? 4 comments Looking for recommendations on hiring talent 1 comment