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

Prevent cached frameworks from crashing in Previews after deleting derived data #6035

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions Sources/TuistGenerator/Mappers/ResourcesProjectMapper.swift
Expand Up @@ -196,6 +196,17 @@ public class ResourcesProjectMapper: ProjectMapping { // swiftlint:disable:this
// which is located under the derived data directory after building the project.
if let override = ProcessInfo.processInfo.environment["PACKAGE_RESOURCE_BUNDLE_PATH"] {
candidates.append(URL(fileURLWithPath: override))

// Deleting derived data and not rebuilding the frameworks containing resources may result in a state
// where the bundles are only available in the framework's directory that is actively being previewed.
// Since we don't know which framework this is, we also need to look in all the framework subpaths.
if let subpaths = try? FileManager.default.contentsOfDirectory(atPath: override) {
for subpath in subpaths {
if subpath.hasSuffix(".framework") {
candidates.append(URL(fileURLWithPath: override + "/" + subpath))
}
}
}
}

for candidate in candidates {
Expand Down