Reputation: 670
I have a react native component written in Swift, and I want to extract it as a framework so other project/people can use it easily.
First I created a new iOS project Foo
, added a framework target,
then added source files. Finally, I built it.
It failed because:
Bar.swift:[lineNumber]: Use of unresolved identifier 'RCTConvert' RNBarManager.swift:[lineNUmber]: Use of undeclared type 'RCTViewManager'
I ran react-native link
, but nothing changed.
React.xcodeproj
to Foo
project and add libReact.a
to Link
Binary With Libraries
.$(SRCROOT)/../node_modules/react-native/React
to Header Search Paths
.But it doesn't work. The error still remains.
I was thinking maybe Swift doesn't recognize these files.
So I added Foo-Bridging-Headers.h
like I did in a React-Native App, which contains the following code:
#import "React/RCTBridge.h"
#import "React/RCTViewManager.h"
#import "React/RCTUIManager.h"
#import "React/UIView+React.h"
#import "React/RCTBridgeModule.h"
I also added Foo-Bridging-Headers.h
to Build Settings->Swift Compiler - General->Object-C Bridging Header
,
Still I got an error.
using bridging headers with framework targets is unsupported
It seems bridging headers are not allowed here.
I tried to add these imports to Foo.h
,
but got an error again.
Foo.h:21:9: Include of non-modular header inside framework module 'Foo'
Upvotes: 39
Views: 3546
Reputation: 21
This seems like an issue with the cocoa pods required for linking React to your project.
Try running pod install
in your project directory using terminal and then try to build.
Upvotes: 2
Reputation: 16242
The linking happens in the hosting app, and not in the framework you've made. That will just need the headers.
Upvotes: 0