React-Native
Packages
Setup
• Run following command in terminal
npm init
• This command create a package file with default configuration.
• Now create folder and file in root folder according to men tioned
folder structure (in next slide)
Folder Structure
• RootFolder
• index.js
• Package.js
• lib
• Publishable JS file
• ios
• Publishable static library
• Android
• Publishable library
• example (React native project)
index.js
• It is entry point for npm package
• Export all accessible classes
import OktaUtil from './lib/oktaUtil'
export default OktaUtil
Package.js
{
"name": "reactoktaauth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC"
}
Package.js
• name:
• Should be small case.
• Contain only alphanumeric character or ‘-’
• version: Current package version
• description: package description
• main: Package entry point (index.js)
• auther: Optional and your name
lib, ios, android, example
• Implement JS code in lib folder, static library in iOS folder, package in
android folder
• Now run following command into package folder
react-native init example
• Open package.json of example project and write your npm package in
dependiencies.
"reactoktaauth": "../"
example
• Now run following command to connect npm package
npm install
• Now link ios and android folder to project.
react-native link
• Open xcode project. You are able to static librarhy into lib folder.
• Now add static library into library binaries setting
• Now you can run your application successfully.
Use pod in static library
• If you want to use pod file into static folder the change your pod file.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!
workspace 'example'
def shared_pods
pod "OktaAuth"
end
target 'example' do
shared_pods
end
target 'OktaAuthRN' do
project './../../ios/OktaAuthRN/OktaAuthRN'
shared_pods
end
Publish package
• Run following command into terminal
npm adduser
• It will ask npm account user name, password, email ID (You must have
npm account)
• Now publish npm with following command
npm publish

5. react native-package

  • 1.
  • 2.
    Setup • Run followingcommand in terminal npm init • This command create a package file with default configuration. • Now create folder and file in root folder according to men tioned folder structure (in next slide)
  • 3.
    Folder Structure • RootFolder •index.js • Package.js • lib • Publishable JS file • ios • Publishable static library • Android • Publishable library • example (React native project)
  • 4.
    index.js • It isentry point for npm package • Export all accessible classes import OktaUtil from './lib/oktaUtil' export default OktaUtil
  • 5.
    Package.js { "name": "reactoktaauth", "version": "1.0.0", "description":"", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC" }
  • 6.
    Package.js • name: • Shouldbe small case. • Contain only alphanumeric character or ‘-’ • version: Current package version • description: package description • main: Package entry point (index.js) • auther: Optional and your name
  • 7.
    lib, ios, android,example • Implement JS code in lib folder, static library in iOS folder, package in android folder • Now run following command into package folder react-native init example • Open package.json of example project and write your npm package in dependiencies. "reactoktaauth": "../"
  • 8.
    example • Now runfollowing command to connect npm package npm install • Now link ios and android folder to project. react-native link • Open xcode project. You are able to static librarhy into lib folder. • Now add static library into library binaries setting • Now you can run your application successfully.
  • 9.
    Use pod instatic library • If you want to use pod file into static folder the change your pod file. # Uncomment the next line to define a global platform for your project platform :ios, '9.0' use_frameworks! workspace 'example' def shared_pods pod "OktaAuth" end target 'example' do shared_pods end target 'OktaAuthRN' do project './../../ios/OktaAuthRN/OktaAuthRN' shared_pods end
  • 10.
    Publish package • Runfollowing command into terminal npm adduser • It will ask npm account user name, password, email ID (You must have npm account) • Now publish npm with following command npm publish