Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

React Native development production module workflow

Tanguy Antoine edited this page May 18, 2016 · 4 revisions

Develoment workflow for creating a React Native module

MusicControl is the module name (replace it with yours)

1/ Create a library with React Native cli

react-native new-library MusicControl

This will create a MusicControl folder into RN Library folder.

Location: node_modules/react-native/Library/MusicControl

2/ Version this Module

Go to this created folder then version it

3/ Using development module (Library)

iOS


  1. Remove previous reference of this 5 Removing module reference
  2. Open your XCode project
  3. Add MusicControl.xcodeproj (node_modules/react-native/Library/MusicControl) under Library folder of your RN app project
  4. Add libMusicControl.a, into app settings : Build Phases > Link Binary With Libraries click + then search and add libMusicControl. (If you forget this step your component will not be loaded into NativeModules of React Native)

Android


react-native-music-control seems to be an arbitrary name but keep it during all config phase

app/build.gradle

 compile project(':react-native-music-control')

MainActivity.java

import com.tanguyantoine.react.MusicControlPackage;

settings.gradle (:warning: use node libary package folder)

include ':react-native-music-control'

// note the projectDir

project(':react-native-music-control').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/Library/MusicControl/android')

4/ Using production module (node_modules)

NB : here react-native-music-control is the npm package name

iOS


Same as development workflow but you should use the MusicControl.xcodeproj located under node_modules/react-native-music-control/ios folder

Android


Same as development workflow but change you settings.gradle to this

settings.gradle (use node module package folder)

project(':react-native-music-control').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-music-control/android')

5/ Removing module reference

iOS


  1. remove reference of MusicControl.xcodeproj into XCode interface
  2. remove libMusicControl.a from Build Phases > Link Binary With Libraries

Android


Remove added lines in app/build.gradle, MainActivity.java and settings.gradle files