Skip to content

Commit

Permalink
Fix generation of SPM packages when some resources are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek committed Mar 4, 2024
1 parent c65bcc3 commit 7d86d0a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,18 @@ extension ResourceFileElements {
return try handleProcessResource(resourceAbsolutePath: resourceAbsolutePath)
}
}
.filter {
switch $0 {
case let .glob(pattern: pattern, excluding: _, tags: _, inclusionCondition: _):
// We will automatically skip including globs of non-existing directories for packages
if !FileHandler.shared.exists(try AbsolutePath(validating: String(pattern.pathString)).parentDirectory) {
return false
}
return true
case .folderReference:
return true
}
}

// Add default resources path if necessary
// They are handled like a `.process` rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ final class PackageInfoMapperTests: TuistUnitTestCase {
]
)

XCTAssertEqual(
XCTAssertBetterEqual(
project,
.testWithDefaultConfigs(
name: "Package",
Expand Down
1 change: 1 addition & 0 deletions fixtures/app_with_spm_dependencies/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ let project = Project(
.external(name: "libzstd"),
.external(name: "NYTPhotoViewer"),
.external(name: "SVProgressHUD"),
.external(name: "AirshipPreferenceCenter"),
],
settings: .targetSettings
),
Expand Down
9 changes: 9 additions & 0 deletions fixtures/app_with_spm_dependencies/Tuist/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@
"version" : "2.0.0"
}
},
{
"identity" : "ios-library",
"kind" : "remoteSourceControl",
"location" : "https://github.com/urbanairship/ios-library.git",
"state" : {
"revision" : "53040c77617a2acc5d9a7b69cf5bbbf36f94ad4b",
"version" : "17.7.3"
}
},
{
"identity" : "nimble",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions fixtures/app_with_spm_dependencies/Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ let package = Package(
.package(url: "https://github.com/Quick/Quick", exact: "7.4.0"),
.package(url: "https://github.com/Quick/Nimble", exact: "13.2.0"),
.package(url: "https://github.com/SVProgressHUD/SVProgressHUD", exact: "2.3.1"),
// Has missing resources
.package(url: "https://github.com/urbanairship/ios-library.git", .exact("17.7.3")),
.package(path: "../LocalSwiftPackage"),
.package(path: "../StringifyMacro"),
]
Expand Down

0 comments on commit 7d86d0a

Please sign in to comment.