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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[276] unlock xcodebuild with SPM #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aim2120
Copy link
Contributor

@aim2120 aim2120 commented May 4, 2024

Description

As muter stands today, SPM projects cannot use xcodebuild as a test executable. This is unfortunate, since any SPM projects that targets iOS, watchOS, tvOS, or visionOS must rely on xcodebuild to run tests with an available simulator.

Build Path Changes

The biggest blocker for using xcodebuild in muter's current state is the use of -showBuildSettings to get the build path. This is because -showBuildSettings does not work the same for SPM projects as it does for Xcode projects. It requires a scheme to be passed, and it also does not output the BUILD_DIR line needed to get the build path.

As a solution to the build path issue, I've decided to utilize the ability to pass an explicit build path to xcodebuild with the flag -derivedDataPath. To keep parity, I'm also using --build-path with the swift executable. To allow consumers to specify a custom build path, I've added buildPath as a value in the muter config, defaulting to .build.

With this change, we can now run muter on an SPM project with xcodebuild without issue. 馃帀

SPM Muter Config Init

Since xcodebuild is now available for SPM, I've added configuration generation logic that detects if an SPM project is targeting iOS. If iOS is detected as a platform, then the xcodebuild executable is added, along with the flags necessary to run the correct scheme and simulator.

Since muter only currently supports iOS simulators, I have not added anything related to the other simulators that might be available.

Acceptance Test Additions

I've added two new example repositories for acceptance tests:

  • ExampleiOSPackage
  • ExampleMacOSPackage

The test script runs the same acceptance test on ExampleiOSPackage as is currently run on ExampleApp. It also runs the same acceptance test on ExampleMacOSPackage as is currently run on ExampleMacOSApp.

To be able to differentiate between the output for app vs. package, I've added the suffix spm and xcodeproj to the test output files. This is utilized in the AcceptanceTests suite to verify the output of running the acceptance tests.

I also changed the acceptance tests to run in a temp directory, which to me seems cleaner than running in the AcceptanceTests directory. However, I'm open to undoing this change if the project maintainers prefer the old way, as it's not necessary for this MR.

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