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

Allow turbo-modules with names with @my-org/project-name #127

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

jhugman
Copy link
Owner

@jhugman jhugman commented Oct 15, 2024

Fixes #124

According to The Big O of Code Reviews, this is a O(n) change.

This adds to the tests introduced in #123 to support names with an org name.

@jhugman jhugman requested a review from zzorba October 15, 2024 17:13
Copy link
Collaborator

@Johennes Johennes left a comment

Choose a reason for hiding this comment

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

Thanks a ton for taking this on!

I tested this on https://github.com/unomed-dev/react-native-matrix-sdk using the example app and things work fine for iOS. On Android, the app appears to crash. At least I think it does. When I tap the button to make the native call in the app, it looks as if it goes into the background unexpectedly but then seems to relaunch entirely when I try to foreground it. I haven't seen this behaviour before and I'm not getting any related output on the terminal. 🤔

@@ -40,6 +40,7 @@ assert_eq $(git ls-remote --heads origin | grep refs/heads/releases/v1 | cut -f1
popd

clean_up
exit 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this might be a leftover?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes! That was trying to get the error messages for #126 !

Removed now.

Comment on lines +406 to +430
--force-new-directory \
--keep-directory-on-exit \
--ubrn-config "$config" \
--builder-bob-version 0.35.1 \
--skip-ios \
--skip-android \
--slug @my-org/react-native-dummy-lib \
"$working_dir/@my-org/react-native-dummy-lib"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The lines below use different indentation. Not that it matters at all of course. 😅

Suggested change
--force-new-directory \
--keep-directory-on-exit \
--ubrn-config "$config" \
--builder-bob-version 0.35.1 \
--skip-ios \
--skip-android \
--slug @my-org/react-native-dummy-lib \
"$working_dir/@my-org/react-native-dummy-lib"
--force-new-directory \
--keep-directory-on-exit \
--ubrn-config "$config" \
--builder-bob-version 0.35.1 \
--skip-ios \
--skip-android \
--slug @my-org/react-native-dummy-lib \
"$working_dir/@my-org/react-native-dummy-lib"

@@ -327,7 +327,7 @@ mod files {
templated_file!(PodspecTemplate, "module-template.podspec");
impl RenderedFile for PodspecTemplate {
fn path(&self, project_root: &Utf8Path) -> Utf8PathBuf {
let name = self.config.project.raw_name();
let name = self.config.project.cpp_filename();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It strikes me as slightly odd that the filename for C++ is reused for the podspec. It doesn't really make a huge difference if the value is the same but maybe using a dedicated function would be cleaner?

@zzorba
Copy link
Collaborator

zzorba commented Oct 15, 2024

I'll test out this build on my side @Johennes to see if I get similar results. I don't have a namespaced package like this, but I'm guessing the crash you are seeing is unrelated to that?

@Johennes
Copy link
Collaborator

I'll test out this build on my side @Johennes to see if I get similar results. I don't have a namespaced package like this, but I'm guessing the crash you are seeing is unrelated to that?

Possibly though I'm not entirely sure since the organisation ends up in some generated names but not others. I'll try to also give it some more testing tomorrow.

@zzorba
Copy link
Collaborator

zzorba commented Oct 15, 2024

One thing I noticed here, it seems like it went from src/index.ts to src/index.tsx, so I had to update my package.json slightly.

@Johennes
Copy link
Collaborator

Yeah, I noticed that, too, but already had index without any extension in package.json so didn't have to change anything. I think I'll try running the app from Android Studio later today to see that gives me an actual error message or stack trace.

@jhugman jhugman force-pushed the jhugman/124-org-scoped-name-mangling branch from 788e563 to 99ee45d Compare October 16, 2024 13:16
@jhugman jhugman force-pushed the jhugman/124-org-scoped-name-mangling branch from 99ee45d to 96bb6ae Compare October 16, 2024 13:28
@jhugman
Copy link
Owner Author

jhugman commented Oct 16, 2024

I'll test out this build on my side @Johennes to see if I get similar results. I don't have a namespaced package like this, but I'm guessing the crash you are seeing is unrelated to that?

Possibly though I'm not entirely sure since the organisation ends up in some generated names but not others. I'll try to also give it some more testing tomorrow.

I found it!

The Android crash was due to the library name in System.loadLibrary not matching the one built in CMakeLists.txt.

I think I broke it in #123, but might have broken it in this one.

I've changed this and added a test.

@jhugman
Copy link
Owner Author

jhugman commented Oct 16, 2024

One thing I noticed here, it seems like it went from src/index.ts to src/index.tsx, so I had to update my package.json slightly.

Our new tests check for differences between the generated files. Builder bob was generating an index.tsx file, and ubrn was generating an index.ts file.

@jhugman jhugman force-pushed the jhugman/124-org-scoped-name-mangling branch from 96bb6ae to 579ed8a Compare October 16, 2024 17:20
@zzorba
Copy link
Collaborator

zzorba commented Oct 16, 2024

Confirmed the fix is working!

Copy link
Collaborator

@zzorba zzorba left a comment

Choose a reason for hiding this comment

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

LGTM

@jhugman jhugman merged commit 67bb07b into main Oct 16, 2024
5 checks passed
@jhugman jhugman deleted the jhugman/124-org-scoped-name-mangling branch October 16, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name mangling breaks for iOS in organization-scoped packages
3 participants