Xcode-8.1 (8B62): Xcode considers unit test bundle to be of framework product type

Originator:jp
Number:rdar://29407087 Date Originated:28-Nov-2016 01:25 PM
Status:Closed Resolved:06-Dec-2016 02:43 PM
Product:Developer Tools Product Version:Xcode-8.1 (8B62)
Classification:Other Bug Reproducible:Always
 
Summary:
A `com.apple.product-type.bundle.unit-test` product type is considered by Xcode's scheme UI to actually be of type `com.apple.product-type.framework`. This leads tools that rely on Xcode's interpretation of product types to have incorrect results. Such as Carthage: https://github.com/Carthage/Carthage

Steps to Reproduce:
1. Download Realm.xcodeproj: https://github.com/realm/realm-cocoa.
2. Notice that the `ObjectServerTests` target has a product type entry of `com.apple.product-type.bundle.unit-test` in its `project.pbxproj` file: https://github.com/realm/realm-cocoa/blob/v2.1.0/Realm.xcodeproj/project.pbxproj#L1745-L1765
3. Open Realm.xcodeproj in Xcode.
4. Notice that the "Object Server Tests" scheme has the same icon as framework schemes.

Expected Results:
Scheme should be considered by Xcode to be a unit test bundle product type.

Actual Results:
Scheme was considered by Xcode to be a framework product type.

Regression:
N/A

Notes:
This causes Carthage to build Realm's Object Server Tests unit test bundle as if it was a framework, causing Carthage's build time to grow beyond reasonable expectation. I only reference Carthage and Realm as real-world manifestations of this Xcode bug, not that Apple is responsible for the maintenance of those projects.

Comments

Response from Apple on Dec 6

Engineering has provided the following feedback regarding this issue:

You should be able to achieve both of these behaviors by navigating to the “Build” page in the scheme editor and checking the boxes in the “Run” and “Profile” columns for each of the “ObjectServerTests” and “TestHost” targets.

My response on Nov 30

I see. That's understandable. However, the motivation for making this scheme buildable was twofold:

1) Hitting ⌘+B in Xcode with a unit test scheme selected fails, presenting a modal dialog stating that "The scheme 'Object Server Tests' is not configured for Running.".

2) To make unit test schemes profilable via Instruments.app.

Should I file new radars to track making these improvements?

See https://github.com/realm/realm-cocoa/pull/4392 for details.

Response from Apple on Nov 30

Please know that our engineering team has determined that this issue behaves as intended based on the information provided.

Xcode doesn’t have a concept of mapping a scheme to a product type. A scheme has a collection of targets which have products, but, generally speaking, there’s not a “primary target” or “primary product” computed for a scheme. The logic for selecting the scheme icon is (roughly) to first look at the “Executable” product selected for the Run action, or fall back to the first target in the list under “Build”.

In this particular case, we believe you will get the results that you need if you remove the “Realm” framework target from the “Object Server Tests” scheme. The framework will still be built as necessary because it is a target dependency of the “ObjectServerTests” test bundle target in the scheme. If you make this change, you will see the scheme icon change to use the bundle icon, and we believe Carthage will then disregard the scheme as well.


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!