Compiling Nextcloud for Apple Silicon
My 2016 MacBook Pro has really been showing its age, and the butterfly keyboard has been increasingly tough to type on, so I’ve been in the market for a replacement. While I don’t love the closed source approach Apple is taking with their Apple Silicon ARM64 Chips, their recent MacBook Pro lineup sets a totally new standard for power in a notebook.
I got my order in for the M1 Max, which is my first ARM64 based notebook, and started migrating over to it. As the first M1 based notebooks were released over a year ago, virtually all of the programs I want available have already been compiled to use the native M1 architecture, with one notable exception.
Nextcloud, which I use as a partial G-Suite replacement, is still only compiled for Intel based macs which require Rosetta 2 in order to run. This wouldn’t be that big of a deal as Rosetta 2 seems to be pretty seamless, but there are several reports of huge amounts of CPU usage by the Intel version of the app. Because Nextcloud is always running in the background, this isn’t a “once and awhile” issue.
Several enterprising folks with a little help from the Nextcloud team have successfully compiled a version of the client side Nextcloud app for Apple Silicon. Building on the work they put together in Github thread I was able to get a working installation, but it took some finesse. For anyone who wants to get a version compiled themselves, here are the specific steps I followed:
1. Install Homebrew
If you don’t have it installed, open up a terminal and get the excellent package manager homebrew up and running. More information on Homebrew can be found here. You’ll be prompted to download XCode command line tools, and will have to enter your login password to install:
|
|
2. Set up the working directory
Create a folder in your home directory to build the related packages:
|
|
3. Install Dependencies from Homebrew
Homebrew will save us from having to compile many the dependencies manually. It looks like some people were running a version of Inkscape through Rosetta for icon generation. Inkscape is actually syntax compatible with librsvg, which has Apple Silicon support out of the box:
|
|
4. Build Qt5 for Apple Silicon
Even though Qt6.2 was just released with native Apple Silicon support, the Nextcloud application isn’t compatible with it yet. Nextcloud still uses Qt5, and version 5.15 is the latest freely and publically available version. There are newer versions than 5.15 of Qt5 available behind a paywall, but 5.15 works really well for our needs. As there is no Apple Silicon binary available, we have to build it ourselves.
Clone the Qt5 repo and check out version 5.15:
|
|
Next we need to pull down all the related modules for the build. This will take a while, and is probably the longest step of this whole process:
|
|
Qt5 actually has a missing header we need to add in order for it to compile correctly. This appears to be ignored by Big Sur’s version of the clang compiler (clang 12), but Monterey (clang 13) complains and fails if you try to compile without it. Add this header with:
|
|
Best practice is to build in a different folder than your source code, so the commands below create a new folder and get the stage set for the build:
|
|
Assuming no errors are thrown, we’re ready to build. This will take a bit, but not as long as initiating the repository did. We don’t need to run make install here because we built the libraries in the same location we’ll be using them.
|
|
5. Build qtkeychain for Apple Silicon
Now that Qt5 is done, we need to build qtkeychain. Same deal as above, we need to clone the repo and set up a build folder:
|
|
Then build the binary. We do need to run make install here in order for the libraries to be included in the Qt5 folder.
|
|
6. Build OpenSSL for Apple Silicon
Now that qtkeychain is done, we need to build OpenSSL. We need to clone the repo and switch to the version used by Nextcloud (1.1.1):
|
|
Then build the binary. OpenSSL uses caffinate to build:
|
|
Copy the libraries you want to /usr/local/lib. Alternatively you can run make install, but that’ll install far more files including documentation:
|
|
7. Build Nextcloud Apple Silicon
Now that we have installed the dependencies from Homebrew, and compiled Apple Silicon versions of Qt5, Qtkeychain, and OpenSSL, we’re ready to build the Nextcloud desktop app.
First clone the repo and set up a build folder:
|
|
We need to set up environment variables for the build, these tell the compiler where to find all of the libraries we just compiled such as Qt5 and qtkeychain.
|
|
Now its build time. This will take a little time but nothing too long. We’ll use make install here which will package the application up in the Applications directory.
|
|
8. Start using the native Nextcloud binary!
Go ahead and launch the app and you should be set! If MacOS complains about the app not being from a known developer, hold down the Control button and right click on it, and select “Open”. It will prompt you with a few “are you sure” messages but then you’re set.
9. Optional - Sign the application yourself
If you’re signed up for the developer program and have a certificate, you can sign the app yourself by replacing “YOUR NAME AND DEVELOPER ID” with your organization name and ID, assuming your certificate is installed:
|
|