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

Added scheme generation for aggregate targets #1250

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Added support for `enableGPUFrameCaptureMode` #1251 @bsudekum

### Fixed

- Fix scheme not being generated for aggregate targets #1250 @CraigSiemens

## 2.32.0

### Added
Expand Down
2 changes: 2 additions & 0 deletions Sources/ProjectSpec/AggregateTarget.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Foundation
import JSONUtilities
import XcodeProj

public struct AggregateTarget: ProjectTarget {
public var name: String
public var type: PBXProductType = .none
public var targets: [String]
public var settings: Settings
public var buildScripts: [BuildScript]
Expand Down
2 changes: 2 additions & 0 deletions Sources/ProjectSpec/ProjectTarget.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Foundation
import XcodeProj

public protocol ProjectTarget: BuildSettingsContainer {

var name: String { get }
var type: PBXProductType { get }
var buildScripts: [BuildScript] { get }
var scheme: TargetScheme? { get }
var attributes: [String: Any] { get }
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/XCProjExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extension Platform {
}
}

extension Target {
extension ProjectTarget {
public var shouldExecuteOnLaunch: Bool {
// This is different from `type.isExecutable`, because we don't want to "run" a test
type.isApp || type.isExtension || type.isSystemExtension || type == .commandLineTool
Expand Down
18 changes: 9 additions & 9 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SchemeGenerator {
xcschemes.append(xcscheme)
}

for target in project.targets {
for target in project.projectTargets {
if let targetScheme = target.scheme {
if targetScheme.configVariants.isEmpty {
let schemeName = target.name
Expand Down Expand Up @@ -95,7 +95,7 @@ public class SchemeGenerator {
return xcschemes
}

public func generateScheme(_ scheme: Scheme, for target: Target? = nil) throws -> XCScheme {
public func generateScheme(_ scheme: Scheme, for target: ProjectTarget? = nil) throws -> XCScheme {

func getBuildableReference(_ target: TargetReference) throws -> XCScheme.BuildableReference {
let pbxProj: PBXProj
Expand Down Expand Up @@ -179,7 +179,7 @@ public class SchemeGenerator {
return XCScheme.ExecutionAction(scriptText: action.script, title: action.name, environmentBuildable: environmentBuildable)
}

let schemeTarget: Target?
let schemeTarget: ProjectTarget?

if let targetName = scheme.run?.executable {
schemeTarget = project.getTarget(targetName)
Expand Down Expand Up @@ -359,15 +359,15 @@ public class SchemeGenerator {
)
}

private func launchAutomaticallySubstyle(for target: Target?) -> String? {
private func launchAutomaticallySubstyle(for target: ProjectTarget?) -> String? {
if target?.type.isExtension == true {
return "2"
} else {
return nil
}
}

private func makeProductRunnables(for target: Target?, buildableReference: XCScheme.BuildableReference) -> (launch: XCScheme.Runnable, profile: XCScheme.BuildableProductRunnable) {
private func makeProductRunnables(for target: ProjectTarget?, buildableReference: XCScheme.BuildableReference) -> (launch: XCScheme.Runnable, profile: XCScheme.BuildableProductRunnable) {
let buildable = XCScheme.BuildableProductRunnable(buildableReference: buildableReference)
if target?.type.isWatchApp == true {
let remote = XCScheme.RemoteRunnable(
Expand All @@ -381,15 +381,15 @@ public class SchemeGenerator {
}
}

private func selectedDebuggerIdentifier(for target: Target?, run: Scheme.Run?) -> String {
private func selectedDebuggerIdentifier(for target: ProjectTarget?, run: Scheme.Run?) -> String {
if target?.type.canUseDebugLauncher != false && run?.debugEnabled ?? Scheme.Run.debugEnabledDefault {
return XCScheme.defaultDebugger
} else {
return ""
}
}

private func selectedLauncherIdentifier(for target: Target?, run: Scheme.Run?) -> String {
private func selectedLauncherIdentifier(for target: ProjectTarget?, run: Scheme.Run?) -> String {
if target?.type.canUseDebugLauncher != false && run?.debugEnabled ?? Scheme.Run.debugEnabledDefault {
return XCScheme.defaultLauncher
} else {
Expand Down Expand Up @@ -420,7 +420,7 @@ enum SchemeGenerationError: Error, CustomStringConvertible {
}

extension Scheme {
public init(name: String, target: Target, targetScheme: TargetScheme, project: Project, debugConfig: String, releaseConfig: String) {
public init(name: String, target: ProjectTarget, targetScheme: TargetScheme, project: Project, debugConfig: String, releaseConfig: String) {
self.init(
name: name,
build: .init(
Expand Down Expand Up @@ -465,7 +465,7 @@ extension Scheme {
)
}

private static func buildTargets(for target: Target, project: Project) -> [BuildTarget] {
private static func buildTargets(for target: ProjectTarget, project: Project) -> [BuildTarget] {
let buildTarget = Scheme.BuildTarget(target: TestableTargetReference.local(target.name))
switch target.type {
case .watchApp, .watch2App:
Expand Down