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

Conversation

anlaital-oura
Copy link
Collaborator

This fixes another crash in Previews when using frameworks with resources after deleting derived data.

Short description πŸ“

This crash happens when the framework has never been built from sources by Previews. In this scenario the resource bundles are only contained within the framework that is being previewed. The solution proposal here does shallow enumeration of the contents of PACKAGE_RESOURCE_BUNDLE_PATH and adds all .framework directories to candidates as we don't know which framework is the one being previewed.

The worst case here is that we look into a few unnecessary directories when running Previews.

Hopefully this is the final fix for these obscure crashes. πŸ˜…

How to test the changes locally 🧐

  1. rm -rf ~/Library/Developer/Xcode/DerivedData
  2. cd fixtures/app_with_previews
  3. tuist install
  4. tuist cache
  5. tuist generate PreviewsFramework
  6. Open TestView.swift in Previews and tap the button and it will crash as it cannot find the bundle for ResourcesFramework

Contributor checklist βœ…

  • The code has been linted using run mise run lint:fix
  • The change is tested via unit testing or acceptance testing, or both
  • The title of the PR is formulated in a way that is usable as a changelog entry
  • In case the PR introduces changes that affect users, the documentation has been updated

Reviewer checklist βœ…

  • The code architecture and patterns are consistent with the rest of the codebase
  • Reviewer has checked that, if needed, the PR includes the label changelog:added, changelog:fixed, or changelog:changed, and the title is usable as a changelog entry

@anlaital-oura anlaital-oura changed the title Cached frameworks crash in Previews after deleting derived data Prevent cached frameworks from crashing in Previews after deleting derived data Mar 6, 2024
@fortmarek fortmarek added the changelog:fixed PR will be listed in the Fixed section of CHANGELOG label Mar 6, 2024
@fortmarek fortmarek merged commit 463d11d into tuist:main Mar 6, 2024
8 checks passed
@anlaital-oura anlaital-oura deleted the anlaital/fix-resources-access-in-previews-after-deleting-derived-data branch March 6, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:fixed PR will be listed in the Fixed section of CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants