yonaskolb / yonaskolb/XcodeGen

Is it possible to conditionally exclude platforms from a target spec?

Open
#844 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
8.8k
Forks
908
Avg merge
17d 14h
Merged PRs (30d)
2

Description

I have a framework target that is compiled for iOS, tvOS, and watchOS. I would like to create a unit test bundle for this framework and specify it in the target scheme definition. Here are the two targets in the spec:

PlatformDemoKit:
    type: framework
    platform: [iOS, tvOS, watchOS]
    sources:
        - PlatformDemoKit
    scheme:
        testTargets:
            - PlatformDemoKitTests_${platform}

PlatformDemoKitTests:
    type: bundle.unit-test
    platform: [iOS, tvOS]
    sources:
        - PlatformDemoKitTests
    dependencies:
        - target: PlatformDemoKit_${platform}

As you may have already guessed, this spec results in an error in XcodeGen:

Spec validation error: Target "PlatformDemoKit_watchOS" scheme has invalid test "PlatformDemoKitTests_watchOS"

Unfortunately, as of this writing, Xcode does not allow us to make test bundles with watchOS as the base SDK. Ideally, I would like to simply exclude the PlatformDemoKitTests_watchOS target from the testTargets list for watchOS given that it does not exist. Is what I'm trying to do possible in XcodeGen? Is there a more "idiomatic XcodeGen" way of solving this problem?

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.

Research direction

Start by tracing how XcodeGen expands platform-specific target names and validates scheme testTargets for the PlatformDemoKit example. Determine how a watchOS framework scheme can omit the unavailable test target while retaining it for iOS and tvOS, and verify the resulting generated project for all three platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.