xcodebuild: Misleading "No applicable devices found" error

Originator:rob
Number:rdar://31389725 Date Originated:4/1/2017
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 8.3
Classification:Enhancement Reproducible:Always
 
Summary:
When using xcodebuild or xcrun to export an archive with the new export APIs, it will return a very misleading error message if any other kind of error happens during the export process.

Steps to Reproduce:
1. Create an archive successfully
2. Try to create an export to an IPA, but cause an error during the process (such as via codesigning or bitcode mismatches)

Sample command using new export APIs

xcodebuild \
    -exportArchive \
    -archivePath "MyApp/build/MyApp.xcarchive" \
    -exportOptionsPlist "MyApp/build/export.plist" \
    -exportPath "MyApp/build/MyApp.ipa"

We had two different errors that manifested themselves as "No available devices found:

First error: I chose `enterprise` for the export method, but I didn't have any certificates to match
Second error: I had a static lib within a framework that was built with bitcode, but I was archiving/exporting without bitcode

Others have had many other kinds of errors manifest themselves this way: https://github.com/fastlane/fastlane/issues/8737

Expected Results:
A correct error message should be surfaced from the lower level bundler interface so that the user is aware of exactly *why* the archive failed and how to fix it.

This was the error message shown from the command line where we ran the xcodebuild export command:

2017-03-30 21:47:09.855 xcodebuild[78957:9114437] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/s1/0h7d0scx6xqdthft328yfk0m0000gn/T/MyApp-Internal_2017-03-30_21-47-09.854.xcdistributionlogs'.
1.2.840.113635.100.1.61
1.2.840.113635.100.1.61
2017-03-30 21:47:14.702 xcodebuild[78957:9114437] [MT] IDEDistribution: Step failed: <IDEDistributionThinningStep: 0x7fc3218d0b60>: Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo={NSLocalizedDescription=No applicable devices found.}
error: exportArchive: No applicable devices found.

Actual Results:
Currently, people have to dig into the *.xcdistributionlogs files in order to understand there was actually a *different* error that caused the higher level "No applicable devices found" error message to be shown.

It's misleading and confusing to have this red herring error be thrown.

This was the *actual* error that was happening under the hood, only visible by knowing to dig into the *.xcdistributionlogs files:

2017-03-31 16:49:06 +0000 Validating IPA structure...
2017-03-31 16:49:06 +0000 error: Failed to verify bitcode in opus.framework/opus:
error: Bundle only contains bitcode-marker /var/folders/s1/0h7d0scx6xqdthft328yfk0m0000gn/T/IDEDistributionThinningStep.KRt/Payload/Viv.app/Frameworks/opus.framework/opus (armv7)

As soon as we correct that error, the export worked successfully.

Version:
Xcode 8.3 (8E162)

Notes:
List of other errors that also caused this high level error to be thrown: https://github.com/fastlane/fastlane/issues/8737

Configuration:
Xcode 8.3 CLI tools using latest xcodebuild export APIs

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!