0

I'm trying to add automated tests to my macOS app on Travis CI, but can't quite figure out code signing.


My (private) GitHub repository is set up to trigger Travis build jobs when I push to master.

For iOS projects, Xcode builds/runs/tests the project for the Simulator platform, so no code signing is required for testing (signing with a distribution identity is necessary to deploy a build, of course. But I just want to run unit tests).

But for macOS apps there is no "Simulator": the code is built and run on the development machine itself.

This article explains how to add distribution code signing artifacts to Travis' machine, so it can build/sign a distribution binary for iOS.

I have modified the steps explained there to use macOS development artifacts instead of iOS Distribution ones. The scripts that decrypt my artifacts and install them on the Travis machine seem to work with no problem.

The Problem

However, unlike for distribution, development provisioning profiles contain a specific list of devices on which builds are allowed to run; in my case, my profile obviously only contains de device ID of my local machine. Obviously there is no way I can get the device ID of the mac that Travis uses, and even if I could, the build obviously runs on a different machine each time.

How Can I Build and Unit-Test macOS Apps on Travis CI?

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189

1 Answers1

0

TL; DR:

I solved the code-signing problem by disabling code-signing altogether (it isn't needed for running unit tests), as explained in this brilliant answer by @robmayoff.

The Details

I still need code-signing for testing my app locally (it uses entitlements to read from/write to user-selected files and folders). So I created a new configuration in Xcode by cloning Debug, named UnitTest.

I disabled code-signing and set Development Team to "none" for this configuration.

Next, I created a dedicated scheme (shared, of course) that uses the UnitTest configuration for build and test. I had to do this in both the App target and the Tests target (I gave up on the UI tests because they require Accessibility enabled to run, and the remote machine does not have those permissions). I had to do this because I couldn't get the xcbuild tool to use the UnitTests configuration.

I haven't quite got my Travis build to successfully complete yet, but I've overcome most obstacles (code-signing included).

Hope this helps someone!

Update

I finally got Travis CI to successfully build and test my app. Off-topic, but my code had the following issues:

  • Deployment target of macOS 10.15 (latest available image on Travis is 10.14)
  • The project was linking against CryptoKit.framework (available only since 10.15!); had to replace it with similar functionality in CommonCrypto.

Somehow the issues above didn't prevent building the app, only running the tests. I was getting an 'image not found' error for CryptoKit.framework.

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189