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

Fix runtime crash when using Obj-C dependencies #5929

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

fortmarek
Copy link
Member

Short description 📝

As reported by @freak4pc, the current fix for ObjC dependencies is missing the addition of the -ObjC linker flag. When accessing ObjC code without this flag, the app crashes with an unrecognized selector sent to instance ....

We can add the flag whenever there's a modulemap as that's a good way to tell if a target has an objc dependency.

How to test the changes locally 🧐

Run app_with_spm_dependencies app. Before this PR and with the current changes in AppKit, the app would crash in runtime.

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

@fortmarek fortmarek added the changelog:fixed PR will be listed in the Fixed section of CHANGELOG label Feb 14, 2024
@fortmarek fortmarek changed the title Fix runtime error when using objc dependencies Fix runtime crash when using objc dependencies Feb 14, 2024
Copy link
Sponsor Contributor

@freak4pc freak4pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing ❤️

@pepicrft pepicrft changed the title Fix runtime crash when using objc dependencies Fix runtime crash when using Obj-C dependencies Feb 14, 2024
@pepicrft pepicrft merged commit 9297022 into main Feb 14, 2024
8 checks passed
@pepicrft pepicrft deleted the fix/runtime-crash-objc branch February 14, 2024 14:34
@amarcadet
Copy link

I wonder if the same principle could be applied to add the -all_load flag as well. Some crashes could occur if objc packages contains categories. I had to do it to fix crashes with some Firebase related lib that has categories on NSData.

@freak4pc
Copy link
Sponsor Contributor

I think we need to be careful with auto-loading compiler flags onto the Xcode Projects unless they are an industry standard of obvious. Things like -all_load could be quite problematic and it's better to leave customized. I think it's good to think about it as - if Xcode does it automatically, Tuist probably should too (i.e. when you add ObjC - Xcode will automatically add that flag, bridging etc). Otherwise, it should be manually customized.

thedavidharris added a commit that referenced this pull request Apr 30, 2024
thedavidharris added a commit that referenced this pull request May 2, 2024
thedavidharris added a commit that referenced this pull request May 7, 2024
pepicrft pushed a commit that referenced this pull request May 14, 2024
…ndencies (#6244)

* Revert "Fix runtime error when using objc dependencies (#5929)"

This reverts commit 9297022.

* Update app_with_spm_dependencies fixture to rely on -ObjC flag and document
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

4 participants