Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xcodeproj] Sort targets and their groups in manifest definition order #2092

Closed

Conversation

matthewseaman
Copy link
Contributor

@matthewseaman matthewseaman commented Apr 12, 2019

[SR-8204] Sort targets and their groups in the following order:

  1. Root Aggregate Products
  2. Root Targets
  3. Root Test Targets
  4. Dependency 1 Aggregate Products
  5. Dependency 1 Targets
  6. Dependency 1 Test Targets
  7. (Repeated for dependencies in alphabetical order)
  8. Root Package Description
  9. Dependency Package Descriptions (in alphabetical order by package)

Within each category, targets are sorted in manifest definition order.

Resolved targets are received from the PackageGraph unordered due to the implementation of the package graph. Rather than mess with how packages are collected, a TargetSortDescriptor type is introduced that stores a number of mappings (to achieve O(n) sort) and follows the rules for the ordered list above.

This way, the implementation of this feature does not add complexity outside of the Xcodeproj module. Additionally, using a separate sort descriptor prevents us from needing to modify the order that targets are added when building the Project model, as the building logic relies on targets being added in a certain order.

Note: The old behavior is preserved with --sort-targets-alphabetically

[SR-8204] Sort targets and cooresponding groups in order of declaration
in the manifest. Rather than mess with the order of the package graph
itself, we introduce a TargetSortDescriptor that is internal to the
Xcodeproj model and can sort package targets and Xcode targets using
the same logic.
[SR-8204] Allow generate-xcodeproj --sort-targets-alphabetically
to preserve the old behavior of sorting targets and their groups
in alphabetical order.
@matthewseaman
Copy link
Contributor Author

I need to fix a few tests, and possible add another.

@matthewseaman
Copy link
Contributor Author

Hmm…this seems to have broken a few Xcodeproj FunctionalTests. In particular, Dependency targets in the "SystemModuleUser" and "SwiftCMixed" projects are not built in the Release directory.

@matthewseaman matthewseaman changed the title [Xcodeproj] Sort targets and their groups in manifest definition order [DNM] [Xcodeproj] Sort targets and their groups in manifest definition order Apr 12, 2019
[SR-8204] `xcodebuild -alltargets` does not properly build any targets listed
after the package description target, most likely due to its quite different
build settings.
@matthewseaman
Copy link
Contributor Author

It seems that xcodebuild -alltargets doesn't build targets correctly if they come after the PackageDescription target in the PBXProject target list. Although this doesn't seem to matter when schemes are used, this is a problem when using xcodebuild on the command line. This PR always places PackageDescription targets last to avoid this issue, but more investigation may be warranted.

@matthewseaman matthewseaman changed the title [DNM] [Xcodeproj] Sort targets and their groups in manifest definition order [Xcodeproj] Sort targets and their groups in manifest definition order Apr 15, 2019
[SR-8204] Update documentation now that package descriptions are ordered last
in the pbxproj.
@matthewseaman
Copy link
Contributor Author

@aciidb0mb3r Would it be correct to assume that this is no longer relevant since we're switching to Swift Packages in Xcode? If so, I can file a Radar on Xcode for this one and we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant