Swift concurrency on macOS 11 with Hardened Runtime throws SIGABRT

Test Environment: Xcode version: 13.2.1 (13C100), macOS version: 11.7.2 (20G1020) and 11.6, mac: Macbook Air M1 and Macbook Pro 13" Late 2013

How to reproduce: Just create new macOS App in Xcode and add following code to the ViewController.viewDidLoad():

print("\(TaskPriority.self)") OR Task { print("This is a test") }

Run the app, it will run fine. Enable Hardened Runtime and run the app, it crashes at above lines with signal SIGABRT. Disable Library Validation in Hardened Runtime or remove Hardened Runtime and it will run fine.

I have used Swift Concurrency in my upcoming macOS Appstore App version, and want to support macOS 11 without disabling library validation. Please let me know how this can be done. Or if this is know bug in my Xcode version, and known to be fixed later. Going to update to macOS Monterey, Xcode 13.4/14 after testing on BigSur is complete.

Answered by shelehs in 741805022

Thanks Quinn for looking into this, I tested with Xcode 14 and same results when running built app on macOS 11.7.2. I was using "Sign to run locally", if I sign it with even Development Team certificate it works fine.

For anyone interested in more details of root cause:

  • Xcode includes libswift_Concurrency.dylib lib in Frameworks folder of built App if deployment target is < macOS 12 as it is not shipped on macOS 11.
  • "Sign to run locally" signatures are invalid for library validation in Hardened Runtime, so it doesn't load libswift_Concurrency.dylib on macOS 11 and fails.

You shouldn’t need to disable library validation to use Swift concurrency. Library validation ensures that all code loaded in your process is either:

  • Signed by you (with the same Team ID as the main executable)

  • Signed by Apple

I just ran through your test on my machine (Intel, macOS 13.0.1, Xcode 14.1, running on macOS 11.6.5 VM) and it worked as expected. Given that, I think that updating to Xcode 14 is your best path forward here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Thanks Quinn for looking into this, I tested with Xcode 14 and same results when running built app on macOS 11.7.2. I was using "Sign to run locally", if I sign it with even Development Team certificate it works fine.

For anyone interested in more details of root cause:

  • Xcode includes libswift_Concurrency.dylib lib in Frameworks folder of built App if deployment target is < macOS 12 as it is not shipped on macOS 11.
  • "Sign to run locally" signatures are invalid for library validation in Hardened Runtime, so it doesn't load libswift_Concurrency.dylib on macOS 11 and fails.
Swift concurrency on macOS 11 with Hardened Runtime throws SIGABRT
 
 
Q