diff --git a/Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift b/Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift index 0a1a9a8449e..ee3d8995cff 100644 --- a/Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift +++ b/Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift @@ -483,22 +483,23 @@ public final class PackageInfoMapper: PackageInfoMapping { if target.type.supportsDependencies { let linkerDependencies: [ProjectDescription.TargetDependency] = target.settings.compactMap { setting in - do { - let condition = try ProjectDescription.PlatformCondition.from(setting.condition) - - switch (setting.tool, setting.name) { - case (.linker, .linkedFramework): - return .sdk(name: setting.value[0], type: .framework, status: .required, condition: condition) - case (.linker, .linkedLibrary): - return .sdk(name: setting.value[0], type: .library, status: .required, condition: condition) - case (.c, _), (.cxx, _), (_, .enableUpcomingFeature), (.swift, _), (.linker, .headerSearchPath), ( - .linker, - .define - ), - (.linker, .unsafeFlags), (_, .enableExperimentalFeature): - return nil - } - } catch { + let condition = ProjectDescription.PlatformCondition.from(setting.condition) + + // The condition returned only unsupported platforms + if condition == nil, setting.condition != nil { + return nil + } + + switch (setting.tool, setting.name) { + case (.linker, .linkedFramework): + return .sdk(name: setting.value[0], type: .framework, status: .required, condition: condition) + case (.linker, .linkedLibrary): + return .sdk(name: setting.value[0], type: .library, status: .required, condition: condition) + case (.c, _), (.cxx, _), (_, .enableUpcomingFeature), (.swift, _), (.linker, .headerSearchPath), ( + .linker, + .define + ), + (.linker, .unsafeFlags), (_, .enableExperimentalFeature): return nil } } @@ -1216,14 +1217,10 @@ extension PackageInfoMapper { } extension ProjectDescription.PlatformCondition { - struct OnlyConditionsWithUnsupportedPlatforms: Error {} - /// Map from a package condition to ProjectDescription.PlatformCondition /// - Parameter condition: condition representing platforms that a given dependency applies to /// - Returns: set of PlatformFilters to be used with `GraphDependencyRefrence` - /// throws `OnlyConditionsWithUnsupportedPlatforms` if the condition only contains platforms not supported by Tuist (e.g - /// `windows`) - fileprivate static func from(_ condition: PackageInfo.PackageConditionDescription?) throws -> Self? { + fileprivate static func from(_ condition: PackageInfo.PackageConditionDescription?) -> Self? { guard let condition else { return nil } let filters: [ProjectDescription.PlatformFilter] = condition.platformNames.compactMap { name in switch name { @@ -1244,11 +1241,6 @@ extension ProjectDescription.PlatformCondition { } } - // If empty, we know there are no supported platforms and this dependency should not be included in the graph - if filters.isEmpty { - throw OnlyConditionsWithUnsupportedPlatforms() - } - return .when(Set(filters)) } } diff --git a/fixtures/app_with_spm_dependencies/Tuist/Package.resolved b/fixtures/app_with_spm_dependencies/Tuist/Package.resolved index e35405f475b..d8da3f7022c 100644 --- a/fixtures/app_with_spm_dependencies/Tuist/Package.resolved +++ b/fixtures/app_with_spm_dependencies/Tuist/Package.resolved @@ -36,6 +36,15 @@ "version" : "3.8.4" } }, + { + "identity" : "collectionconcurrencykit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git", + "state" : { + "revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95", + "version" : "0.2.0" + } + }, { "identity" : "combine-schedulers", "kind" : "remoteSourceControl", @@ -45,6 +54,15 @@ "version" : "1.0.0" } }, + { + "identity" : "cryptoswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/krzyzanowskim/CryptoSwift.git", + "state" : { + "revision" : "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c", + "version" : "1.8.1" + } + }, { "identity" : "cwlcatchexception", "kind" : "remoteSourceControl", @@ -171,6 +189,15 @@ "version" : "8.20.0" } }, + { + "identity" : "sourcekitten", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jpsim/SourceKitten.git", + "state" : { + "revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56", + "version" : "0.34.1" + } + }, { "identity" : "svprogresshud", "kind" : "remoteSourceControl", @@ -180,6 +207,15 @@ "version" : "2.3.1" } }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531", + "version" : "1.2.3" + } + }, { "identity" : "swift-case-paths", "kind" : "remoteSourceControl", @@ -275,8 +311,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-syntax.git", "state" : { - "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", - "version" : "509.1.1" + "revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036", + "version" : "509.0.2" + } + }, + { + "identity" : "swiftlint", + "kind" : "remoteSourceControl", + "location" : "https://github.com/realm/SwiftLint", + "state" : { + "revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee", + "version" : "0.54.0" } }, { @@ -288,6 +333,24 @@ "version" : "1.2.1" } }, + { + "identity" : "swiftytexttable", + "kind" : "remoteSourceControl", + "location" : "https://github.com/scottrhoyt/SwiftyTextTable.git", + "state" : { + "revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3", + "version" : "0.9.0" + } + }, + { + "identity" : "swxmlhash", + "kind" : "remoteSourceControl", + "location" : "https://github.com/drmohundro/SWXMLHash.git", + "state" : { + "revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f", + "version" : "7.0.2" + } + }, { "identity" : "xctest-dynamic-overlay", "kind" : "remoteSourceControl", diff --git a/fixtures/app_with_spm_dependencies/Tuist/Package.swift b/fixtures/app_with_spm_dependencies/Tuist/Package.swift index 32f5930cb7d..a0a9ac7f3b2 100644 --- a/fixtures/app_with_spm_dependencies/Tuist/Package.swift +++ b/fixtures/app_with_spm_dependencies/Tuist/Package.swift @@ -24,6 +24,7 @@ let package = Package( .package(url: "https://github.com/google/GoogleSignIn-iOS", .upToNextMajor(from: "7.0.0")), .package(url: "https://github.com/getsentry/sentry-cocoa", .upToNextMajor(from: "8.20.0")), .package(url: "https://github.com/realm/realm-swift", .upToNextMajor(from: "10.46.0")), + .package(url: "https://github.com/realm/SwiftLint", exact: "0.54.0"), .package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack", .upToNextMajor(from: "3.8.4")), .package(url: "https://github.com/facebook/zstd", exact: "1.5.5"), .package(url: "https://github.com/microsoft/appcenter-sdk-apple", .upToNextMajor(from: "5.0.4")),