From c094bd16c1c7a8f3223558ae694f87a8fbc92503 Mon Sep 17 00:00:00 2001 From: Aaron Alexander Date: Thu, 2 Jan 2025 13:13:22 -0800 Subject: [PATCH 1/3] fixed typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e2bee2..95ecfb6 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Because of the low-friction to adding command line options with [swift-argument- ## Packaging for distribution -swift-create-xcframework provides a `--zip` option to automatically zip up your newly created XCFrameworks ready for upload to GitHub as a release artefact, or anywhere you choose. +swift-create-xcframework provides a `--zip` option to automatically zip up your newly created XCFrameworks ready for upload to GitHub as a release artifact, or anywhere you choose. If the target you are creating an XCFramework happens to be a dependency, swift-create-xcframework will look back into the package graph, locate the version that dependency resolved to, and append the version number to your zip file name. eg: `ArgumentParser-0.0.6.zip` From 979f5e6de36d4673bf96e10e4bed460e907d3eaf Mon Sep 17 00:00:00 2001 From: Chris Leonavicius Date: Wed, 26 Mar 2025 18:21:35 -0700 Subject: [PATCH 2/3] Add support for visionOS --- Sources/CreateXCFramework/Platforms.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/CreateXCFramework/Platforms.swift b/Sources/CreateXCFramework/Platforms.swift index b4c1dd5..af6c4ff 100644 --- a/Sources/CreateXCFramework/Platforms.swift +++ b/Sources/CreateXCFramework/Platforms.swift @@ -14,6 +14,7 @@ enum TargetPlatform: String, ExpressibleByArgument, CaseIterable { case maccatalyst case tvos case watchos + case visionos init?(argument: String) { self.init(rawValue: argument.lowercased()) @@ -27,6 +28,7 @@ enum TargetPlatform: String, ExpressibleByArgument, CaseIterable { case .maccatalyst: return "macos" case .tvos: return "tvos" case .watchos: return "watchos" + case .visionos: return "visionos" } } @@ -108,6 +110,21 @@ enum TargetPlatform: String, ExpressibleByArgument, CaseIterable { buildSettings: nil ) ] + case .visionos: + return [ + SDK ( + destination: "generic/platform=visionOS", + archiveName: "visionos.xcarchive", + releaseFolder: "Release-xros", + buildSettings: nil + ), + SDK ( + destination: "generic/platform=visionOS Simulator", + archiveName: "visionsimulator.xcarchive", + releaseFolder: "Release-xrsimulator", + buildSettings: nil + ) + ] } } } From 9bb228b37c06d0f1b1057641b194c1bd08c47200 Mon Sep 17 00:00:00 2001 From: Chris Leonavicius Date: Wed, 26 Mar 2025 18:29:04 -0700 Subject: [PATCH 3/3] Add an option to skip project generation for binary targets (vs throwing an error) --- Sources/CreateXCFramework/Command+Options.swift | 2 ++ Sources/CreateXCFramework/PackageInfo.swift | 2 +- Sources/CreateXCFramework/ProjectGenerator.swift | 6 ++++-- Sources/Xcodeproj/generate.swift | 6 +++++- Sources/Xcodeproj/pbxproj.swift | 8 +++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Sources/CreateXCFramework/Command+Options.swift b/Sources/CreateXCFramework/Command+Options.swift index 551cda9..d528752 100644 --- a/Sources/CreateXCFramework/Command+Options.swift +++ b/Sources/CreateXCFramework/Command+Options.swift @@ -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 diff --git a/Sources/CreateXCFramework/PackageInfo.swift b/Sources/CreateXCFramework/PackageInfo.swift index 5147997..561c286 100644 --- a/Sources/CreateXCFramework/PackageInfo.swift +++ b/Sources/CreateXCFramework/PackageInfo.swift @@ -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))) } diff --git a/Sources/CreateXCFramework/ProjectGenerator.swift b/Sources/CreateXCFramework/ProjectGenerator.swift index dc2b9c8..fd04de3 100644 --- a/Sources/CreateXCFramework/ProjectGenerator.swift +++ b/Sources/CreateXCFramework/ProjectGenerator.swift @@ -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 @@ -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 ) diff --git a/Sources/Xcodeproj/generate.swift b/Sources/Xcodeproj/generate.swift index 6db6cd8..7fe2699 100644 --- a/Sources/Xcodeproj/generate.swift +++ b/Sources/Xcodeproj/generate.swift @@ -45,13 +45,16 @@ 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 @@ -59,6 +62,7 @@ public struct XcodeprojOptions { self.useLegacySchemeGenerator = useLegacySchemeGenerator ?? false self.enableAutogeneration = enableAutogeneration ?? false self.addExtraFiles = addExtraFiles ?? true + self.skipBinaryTargets = skipBinaryTargets ?? false } } diff --git a/Sources/Xcodeproj/pbxproj.swift b/Sources/Xcodeproj/pbxproj.swift index 4f244b7..b59ff91 100644 --- a/Sources/Xcodeproj/pbxproj.swift +++ b/Sources/Xcodeproj/pbxproj.swift @@ -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") }