Hi all,
I have a command-line tool that I need to notarize.
Well, actually, notarizing is the easy part. The tool is used inside an installer package, which is inside a dmg, and when we notarize the dmg, everything inside the dmg gets notarized transparantly, which is quite nice.
Except that for notarizing to pass, the tool needs secure timestamps and hardened runtime enabled.
Okay, so far so good. Documentation says that Xcode does this for us. When in debug mode, Xcode enables get-task-allow, and we can debug the tool. When in production mode (via archive/export), Xcode enables secure timestamps and removes get-task-allow.
Except, I'm having trouble exporting the tool for production. I can archive using `xcodebuild archive -scheme mytool -archivePath mytool`, and I get an Xcode Archive bundle that looks a lot like one would expect:
$ find mytool.xcarchive
mytool.xcarchive
mytool.xcarchive/Products
mytool.xcarchive/Products/usr
mytool.xcarchive/Products/usr/local
mytool.xcarchive/Products/usr/local/bin
mytool.xcarchive/Products/usr/local/bin/mytool
mytool.xcarchive/dSYMs
mytool.xcarchive/dSYMs/mytool.dSYM
mytool.xcarchive/dSYMs/mytool.dSYM/Contents
mytool.xcarchive/dSYMs/mytool.dSYM/Contents/Resources
mytool.xcarchive/dSYMs/mytool.dSYM/Contents/Resources/DWARF
mytool.xcarchive/dSYMs/mytool.dSYM/Contents/Resources/DWARF/mytool
mytool.xcarchive/dSYMs/mytool.dSYM/Contents/Info.plist
mytool.xcarchive/Info.plist
But then when I try to export, I get:
$ xcodebuild -exportArchive -archivePath mytool.xcarchive -exportPath prod-mytool -exportOptionsPlist mytool_codesigning_options.plist
** EXPORT FAILED **
2020-02-13 06:05:23.453 xcodebuild[54323:1508625] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/mz/kgcq5n9j7yn2s9v0ch850tz80000gq/T/mytool_2020-02-13_06-05-23.453.xcdistributionlogs'.
2020-02-13 06:05:23.474 xcodebuild[54323:1508625] [MT] IDEDistributionMethodManager: -[IDEDistributionMethodManager orderedDistributionMethodsForTask:archive:]: Error = Error Domain=IDEDistributionMethodManagerErrorDomain Code=2 "Unknown Distribution Error" UserInfo={NSLocalizedDescription=Unknown Distribution Error}
error: exportArchive: exportOptionsPlist error for key 'method': expected one of {}, but found developer-id
Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {}, but found developer-id" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {}, but found developer-id}
Google says that the error is caused by the Xcode Archive not containing a normal app, and that you can't export a tool.
Can I export this tool?
If not, then is it still possible to take advantage of Xcode's automatic debug/production switching behavior even though I need secure timestamps and the hardened runtime turned on in production?