Skip to content
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
2 changes: 2 additions & 0 deletions Sources/CreateXCFramework/Command+Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ extension Command {
@Flag(help: .hidden)
var githubAction: Bool = false

@Flag(help: "Skip binary targets for project generation. Useful for creating and distributing a library from one Package.swift")
var skipBinaryTargets: Bool = false

// MARK: - Targets

Expand Down
2 changes: 1 addition & 1 deletion Sources/CreateXCFramework/PackageInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct PackageInfo {

// check the graph for binary targets
let binary = self.graph.allTargets.filter { $0.type == .binary }
if binary.isEmpty == false {
if !options.skipBinaryTargets, binary.isEmpty == false {
errors.append(.containsBinaryTargets(binary.map(\.name)))
}

Expand Down
6 changes: 4 additions & 2 deletions Sources/CreateXCFramework/ProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ struct ProjectGenerator {
extraFiles: [],
options: XcodeprojOptions (
xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { try AbsolutePath(validating: $0) },
useLegacySchemeGenerator: true
useLegacySchemeGenerator: true,
skipBinaryTargets: package.options.skipBinaryTargets
),
fileSystem: localFileSystem,
observabilityScope: self.package.observabilitySystem.topScope
Expand All @@ -97,7 +98,8 @@ struct ProjectGenerator {
extraFiles: [],
options: XcodeprojOptions (
xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { AbsolutePath($0) },
useLegacySchemeGenerator: true
useLegacySchemeGenerator: true,
skipBinaryTargets: package.options.skipBinaryTargets
),
diagnostics: self.package.diagnostics
)
Expand Down
6 changes: 5 additions & 1 deletion Sources/Xcodeproj/generate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ public struct XcodeprojOptions {
/// Reference to manifest loader, if present.
public var manifestLoader: ManifestLoader?

public var skipBinaryTargets: Bool

public init(
flags: PackageModel.BuildFlags = PackageModel.BuildFlags(),
xcconfigOverrides: AbsolutePath? = nil,
isCodeCoverageEnabled: Bool? = nil,
useLegacySchemeGenerator: Bool? = nil,
enableAutogeneration: Bool? = nil,
addExtraFiles: Bool? = nil
addExtraFiles: Bool? = nil,
skipBinaryTargets: Bool? = nil
) {
self.flags = flags
self.xcconfigOverrides = xcconfigOverrides
self.isCodeCoverageEnabled = isCodeCoverageEnabled ?? false
self.useLegacySchemeGenerator = useLegacySchemeGenerator ?? false
self.enableAutogeneration = enableAutogeneration ?? false
self.addExtraFiles = addExtraFiles ?? true
self.skipBinaryTargets = skipBinaryTargets ?? false
}
}

Expand Down
8 changes: 7 additions & 1 deletion Sources/Xcodeproj/pbxproj.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,13 @@ public func xcodeProject(
productType = .framework
case .test:
productType = .unitTest
case .systemModule, .binary, .plugin, .macro:
case .binary:
if options.skipBinaryTargets {
continue
} else {
fallthrough
}
case .systemModule, .plugin, .macro:
throw InternalError("\(target.type) not supported")
}

Expand Down