I’m playing around with some potential mechanisms to deliver a React-Native app as a framework. Specifically, this will have three parts:
- RN App – this has a module that I want to expose via a helper in the framework for use in the client app.
- Framework (iOS Native Swift) – this wraps the bundle.js from the RN app inside of a Framework.
- Client App (iOS Native Swift) – Adds the Framework and uses the helper in the Framework to get the React Native module (in this case, a View) to be used in the Client App UI.
So, this means that the framework pulls in React Native via Cocoapods because it is directly interfacing with the React Native components. This is currently done like this:
target 'TestAppFramework' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:fabric_enabled => true,
:ios_folder => 'TestAppFramework'
)
The use_react_native method maps back to react_native_pods.rb inside of the react project. This is where the pods actually get pulled in. There are approximately 50 of them.
Potential static solution
By default, RN pulls stuff in statically. I’m not using use_frameworks! inside the Podfile. My expectation based off of this would be that pod dependencies would be built into the framework. When I drop this framework into my client project, it fails to compile because a generated -Swift.h header cannot find react in @import React;.
However, if I add React Native to the client app’s Cocoapod — it works (although you see dozens upon dozens of warnings in the console because each time RN is called it finds duplicate dependencies).
Potential Static Solution Question
- The client code is not talking to RN directly. Given this, I was under the impression that having RN and all it’s pods delivered in the Framework would work without weird visibility issues. Is this a visibility issue or something more sinister?
Potential Dynamic Solution
I was hoping that I could NOT bundle the RN Pods into the framework, delivering only the bundle.js and Swift interface code in the framework. My understanding was that “use_frameworks!” in the Podfile would accomplish that. I have not found that to be the case. When I do this, the client app behaves exactly as when I leave “use_frameworks!” off. IE: the dependency pods still appear to be in the framework.
Potential Dynamic Solution Questions
- Is there a way to make this work so the framework doesn’t have the dependency pods and the client is responsible for providing them?
Potential Cocoapods Solution
Another potential path is to deliver this as a cocoapod instead of a framework. Given the number of dependencies and the amount of magic inside of react_native_pods.rb that I would lose, this seems impractical.
Potential Cocoapods Solutions Question
- Is there a way to essentially accomplish the same thing that the use_react_native method is doing in the Podfile in a Podspec?
Thanks for any advice!




