Feature Request: An `xcodeproj_test` rule to test configured `xcodeproj` running the installer and then executing select `xcodebuild` actions against the generated Xcode project

Open
#461 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
ios, swift

Research direction

Start with the xcodeproj_test usage described in the issue and the examples/ios_app configuration. Trace how the xcodeproj target is installed, then determine how the default runner should invoke xcodebuild for the selected scheme and build_actions. Done means the generated project and scheme can be exercised, with support for a custom runner as described.

Written by the indexing model from the issue text.

Description

feature request

Goals

  • Provide assurances to rules_xcodeproj contributors that changes to the underlying rules work.
  • Allow clients of rules_xcodeproj to test the schemes for configured projects.
    • Execute a build command for a scheme.
    • Execute a test command for a scheme.

Design/Usage

  • Provide xcodeproj_test that handles the test setup and Xcode project installation.
  • Provide a default test runner that executes xcodebuild commands against the Xcode project.
  • Allow clients to provide their own test runner.

Details

The idea is that we want to exercise the generated project/scheme. The following example is based upon examples/ios_app.

XCODEPROJ_TARGETS = [
    "//Example",
    "//ExampleTests",
    "//ExampleObjcTests",
    "//ExampleUITests",
]

XCODEPROJ_SCHEMES = [
    xcode_schemes.scheme(
        name = "ios_app",
        launch_action = xcode_schemes.launch_action("//Example"),
        test_action = xcode_schemes.test_action(
            "//ExampleTests",
            "//ExampleObjcTests",
            "//ExampleUITests",
        ),
    ),
]

xcodeproj(
    name = "xcodeproj",
    project_name = "iOS App",
    tags = ["manual"],
    top_level_targets = XCODEPROJ_TARGETS,
    schemes = XCODEPROJ_SCHEMES,
)

We want to be sure that the generated project and scheme work properly.

# This test will run the installer for `:xcodeproj`, then run the following:
#   xcodebuild -project iOS\ App.xcodeproj -scheme ios_app \
#      -sdk iphonesimulator \
#      -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.3' \
#      test archive
# If the the command succeeds, the test passes. If the command does not, the test fails.
xcodeproj_test(
    name = "ios_app_scheme_test",
    xcodeproj = ":xcodeproj",
    scheme = "ios_app",
    # The `xcodebuild -help` lists these as `buildaction`. The interesting ones are `build`, 
    # `archive`, and `test`.
    build_actions = ["test", "archive"],
)

Alternative Design

You may want to separate the test from the runner. The test would take a reference to an xcodeproj target. It would prepare the test and run the installer. The runner would execute the xcodebuild command. The benefit would be that other runners could be used instead of an xcodebuild runner.

Dominant language
Swift
Stars
626
Forks
124
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MobileNativeFoundation/rules_xcodeproj

All issues in MobileNativeFoundation/rules_xcodeproj

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.