-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Bridge] Native module inside framework #579
Comments
As of now, this is not possible because React Native looks for all RCT_EXPORT entries in its binary. |
Sometimes developer needs to use native modules inside frameworks. For example, it's required to avoid build problems because of the conflicts between 3rd party libs code and React Native libs. |
Not exactly sure I am following this issue, but I'm interested. Is the question if you can add a new Framework that utilizes react native and exposes functionality? |
@drkibitz yes, if you publish e.g. a keyboard component that has some native code, it currently has to be distributed as a static library. This means you can't write helper code in Swift without splitting it out into a separate framework. So far I've found RCT_EXPORT easy to type and maintain so it would be nice to keep it or something very similar. Maybe it (or a new macro) could generate dummy methods that RCTBridge knows to scan for? |
Alright, I'm currently working on an updated version of |
@a2 That sounds really great. One of the practical benefits of framework support is that you can use CocoaPods containing Swift -- if a pure-ObjC pod (e.g. a React module) depends on a pod with Swift code (e.g. Alamofire, whatever) then CocoaPods builds both as frameworks. |
@a2 sounds good, will be waiting eagerly! |
👍 this is the last thing blocking my WebSockets native extension: https://github.com/tptee/RCTWebSocket This'll help distribution/CocoaPods interop immensely. |
Any news? |
#982 is done, which is awesome, but I'm not sure frameworks work yet. When CocoaPods builds a framework, it spits all of the project's headers into one folder, and a few headers in React Native reference relative paths. This breaks clang modules, which CocoaPods framework support depends on. So while we can write extensions in Swift, we can't deliver them in a clean way yet :/ |
That's true. I'm working on it :-) |
👍 |
As of 0.4.1 I can successfully build a framework linked to React with the new Swift export macros. However, when I import the framework module into a React Native app target, I get the following:
Any ideas? Looks like RCT_EXTERN_MODULE didn't export the class from the framework correctly. |
That's correct, we still don't support modules linked from dynamic libraries yet. That's coming soon. |
Cool, thanks for the update!
|
To update this, as of 0.7.0-rc.2, I was able to define a module in a shared framework and use it from an iOS app target. The new module loading system seems to have done away with embedding strings into the binaries in favor of a registration system based on defining As far as I can tell, things work perfectly. Adding React to an existing project using CocoaPods with |
@yusefnapora thanks for the update! |
@yusefnapora @nicklockwood Has this issue been fixed? Could you please show me the commit? I a m still not able to link dynamic library (.framework) into my RN project. There are many 3rd party solutions to create native UI components using objective-c and we can easily integrate them into a RN project as they target static library. |
Is there a way to implement native module inside framework instead of static library?
The text was updated successfully, but these errors were encountered: