Description
Motivation:
Currently, react-native link
supports only Objective-C libraries. Therefore, some great libraries (like native-navigation) can't be linked with it. I'd like to make a proposal for supporting Swift modules in react-native link
.
Linkage process for Swift modules:
First of all, we need to detect a type of module we want to link. One of the approaches we can take there is to check package.json
for a special flag ("isSwiftModule": true
? false
by default) in rnpm
section. If flag is set to true
, use a special linkage process described below.
Swift modules for React Native will always depends on React. As far as React is implemented in Objective-C, we need to add a <ProjectName>-Bridging-Header.h
if it doesn't exist yet (this file contains Objective-C headers, required by the Swift module). Module developer can specify required headers in the rnpm
section of his package.json.
Once file is composed / patched, Swift modules needs to be added to the project. My current assumption is that we can re-use logic we have in place for Objective-C modules (right, @grabbou?).
Theoretically, it should be it for most of react-native modules.
wdyt, @grabbou?