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

Make react-native-image-picker compatible with use_frameworks #2242

Conversation

cipolleschi
Copy link
Contributor

Thanks for submitting a PR! Please read these instructions carefully:

  • Explain the motivation for making this change.
  • Provide a test plan demonstrating that the code is solid.
  • Match the code formatting of the rest of the codebase.
  • Target the main branch, NOT a "stable" branch.

Motivation (required)

react-native-image-picker is not compatible with React Native 0.72, when use_frameworks! is enabled.
It fails to load a module, because it is mixing Swift and Objective-C import styles

Given that React Native is a C++ project and Swift and C++ do not like each other, the current setup is dangerous and can break easily.
This PR updates the podspec introducing the install_modules_dependencies function when defined to relieve the burden of properly handling the React Native internals from the library.
It also adds the dependency to the Apple's MobileCoreServices, so that we ca import it using the proper Objective-C syntax.
And then uses the right syntax to import the module.

Test Plan (required)

The example app is on 0.71, so the test is limited.

You can run the test by:

cd example
yarn
cd ios
NO_FLIPPER=1 USE_FRAMEWORKS=static pod update hermes-engine --no-repo-update
open example.xcworkspace

and then build and run from Xcode. You'll see the app building successfully.

I also created a new app using React Native 0.72, installed the library with yarn add react-native-image-picker and run the same commands.
Before applying the patch in this PR, it was failing.
After the patch, it was building successfully.

s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
if defined?(install_modules_dependencies) != nil
install_modules_dependencies(s)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function has been defined in 0.70 and allows library maintainers not to care about the internals of React Native. We are going to handle all the dependencies on the internal pods ourselves and, as long as you use this function, you don't have to care about them.

Johan-dutoit
Johan-dutoit previously approved these changes Nov 23, 2023
@eidan66
Copy link

eidan66 commented Dec 4, 2023

Can someone approve this PR? This solution works. (check on my local project)

@Johan-dutoit Johan-dutoit merged commit 6cb36f4 into react-native-image-picker:main Dec 4, 2023
1 check passed
Johan-dutoit pushed a commit that referenced this pull request Dec 4, 2023
# [7.1.0](v7.0.3...v7.1.0) (2023-12-04)

### Features

* add use_frameworks compatibility  ([#2242](#2242)) ([6cb36f4](6cb36f4))
@Johan-dutoit
Copy link
Collaborator

🎉 This PR is included in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants