@johndhammcodes/react-native-swift-library-template
v1.1.2
Published
A React Native library to implement Swift native code in NativeModules
Downloads
4
Readme
react-native-swift-library-template
Getting started
$ npm install react-native-swift-library-template --save
Mostly automatic installation
$ react-native link react-native-swift-library-template
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-swift-library-template
and addRNSwiftLibraryTemplate.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNSwiftLibraryTemplate.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.RNSwiftLibraryTemplatePackage;
to the imports at the top of the file - Add
new RNSwiftLibraryTemplatePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-swift-library-template' project(':react-native-swift-library-template').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-swift-library-template/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-swift-library-template')
Windows
- In Visual Studio add the
RNSwiftLibraryTemplate.sln
innode_modules/react-native-swift-library-template/windows/RNSwiftLibraryTemplate.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Swift.Library.Template.RNSwiftLibraryTemplate;
to the usings at the top of the file - Add
new RNSwiftLibraryTemplatePackage()
to theList<IReactPackage>
returned by thePackages
method
Usage
import RNSwiftLibraryTemplate from 'react-native-swift-library-template';
// TODO: What to do with the module?
RNSwiftLibraryTemplate;