Bookmark Creation With Security Scope Fails in Xcode Cloud

I have an macOS app, where the user can open/drag a folder so that the contents can be listed and used. The app saves the bookmark data for these folders and restores them the next time the app runs. This works perfect on the development machines and on thousands of users' Macs.

Recently I added UI tests which perform a couple if happy path tests and they are helping a lot. One of the tests adds a folder and tries to use an image which is in the folder. The folder is copied from the test bundle to the Desktop at the beginning of the test. This works both locally (on my Mac) and on two CI "servers" (latest macOS, Xcode Server).

At the moment I try to migrate to Xcode Cloud. Unit tests run fine (after disabling the Hardened Runtime). However, I do not get the UI tests to succeed. They run and add the folder, however, the URL's bookmark data creation fails.

I tried to track the differences during the build and found Xcode Cloud builds always being adhoc-signed. Running the UI tests locally but signing the app (and the tests) adhoc too does not result in the same problem.

Problem in short:

  • user selects folder (using NSOpenPanel or Drag'n'Drop)
  • url.bookmarkData() works locally and in Xcode Cloud
  • url.bookmarkData(options: [.withSecurityScope]) only works locally but not in Xcode Cloud

This is easily reproducible with a very simple project which I can hand-out if needed.

Anybody a hint or idea? Since those folders are essential for the app, not solving this would render Xcode Cloud completely useless for me.

Thanks! Daniel