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

v0.76: How to integrate with existing iOS apps using a view controller instead of app delegate #4311

Open
MaxAst opened this issue Oct 27, 2024 · 3 comments

Comments

@MaxAst
Copy link

MaxAst commented Oct 27, 2024

Description

Up until v0.76, the guide on how to integrate React Native in existing iOS apps used a view controller instead of an app delegate. With the new app delegate approach in v0.76 it's unclear whether it is still possible to integrate React Native with just a view controller.

What is the problem?

I used to be able to integrate React Native in iOS share extensions using the view controller approach. Since iOS share extensions do not support app delegates, it's unclear how to integrate React Native's new architecture in share extensions.

How can we address it?

Add documentation covering how to integrate v0.76 via just a view controller.

Why is it important?

It's currently not clear how to integrate React Native's new architecture in iOS app extensions.

Who needs this?

I am the author of expo-share-extension and would like to integrate the new architecture.

When should this happen (use version numbers if needed)?

Ideally in a next release

@cipolleschi
Copy link
Contributor

cipolleschi commented Nov 7, 2024

Hi @MaxAst thanks for the question.

Currently there is no easy way to do so. The old architecture only required the RootView and the Bridge to set up React Native and this made it easy to spin up a React Native instance from wherever.

The New Architecture is a bit more complicated and we encapsulated all the required steps in the AppDelegate. We are working on some changes to make it easier to instantiate React native from wherever, decoupling it from the AppDelegate, but it is not ready yet.

As of today, the best way to achieve this is probably to copy some of the implementation in the RCTAppDelegate in your view controller. I can provide more details on how to do it if you start a PR in the repo (Also, I see that the codebase is in Swift, the new architecture is mostly in C++, so we would have to add some Objective-C/Objective-C++ files there).

cc. @okwasniewski which is helping out with the ReactNativeFactory effort.

@MaxAst
Copy link
Author

MaxAst commented Nov 7, 2024

Thanks a lot for the reply @cipolleschi! I've actually already gotten in touch with @okwasniewski after I discovered his PR for ReactNativeFactory - while I wait for him with this, I'll give rewriting the library in Objective-C a try. Will ping you here once I got a PR going 🙏

@cipolleschi
Copy link
Contributor

@MaxAst There is no need to rewrite the whole library in Objective-C! You can just wrap the things you need in an Objective-C layer and keep the Swift implementation!

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

No branches or pull requests

2 participants