I am building a native module locally.
To test the changes I make to the native module I am using a local app which has a dependency on the local module.
The problem I am facing is the whenever I try to run the ios app, I get an error saying "Native Module can not be null"
Native Module:
package.json:
"name": "my-package-name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "jest --coverage"
},
"keywords": [
"react-native"
],
"author": "AwesomeAuthor",
"peerDependencies": {
"react": "^16.8.6",
"react-native": "^0.60.0"
},
"devDependencies": {
"babel-jest": "23.0.1",
"babel-preset-react-native": "4.0.0",
"jest": "23.1.0",
"jshint": "^2.9.5",
"react": "16.8.6",
"react-native": "0.60.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native",
"coverageDirectory": "coverage",
"collectCoverageFrom": [
"**/*.{js,jsx}",
"!**/coverage/**/*.{js,jsx}"
],
"collectCoverage": true,
"coverageThreshold": {
"global": {
"lines": 95
}
}
}
}
Podspec file:
Pod::Spec.new do |s|
s.name = "MyPackageName"
s.version = "0.0.1"
s.summary = "MyPackageName"
s.description = <<-DESC
MyPackageName
DESC
s.homepage = "https://www.mypackagename.com"
s.platform = :ios, "8.0"
s.source_files = "MyPackageName/**/*.{h,m}"
s.requires_arc = true
s.authors = { 'Some Author' => 'someauthor@gmail.com' }
s.source = { :http => 'file:' + __dir__ + '/MyPackageName.zip' }
s.dependency "React"
end
AwesomeProject
package.json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.6",
"react-native": "0.60.0",
"my-package-name": "file:../my-package-name",
"react-native-reanimated": "1.4.0",
"react-native-segmented-control-tab": "^3.4.1",
"react-native-uuid-generator": "6.1.1"
},
"devDependencies": {
"@babel/core": "7.7.5",
"@babel/runtime": "7.7.6",
"@react-native-community/eslint-config": "0.0.3",
"babel-jest": "24.9.0",
"eslint": "6.7.2",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
App.js
import {
Platform,
StyleSheet,
Text,
View,
Button,
TextInput,
ScrollView,
Switch,
FlatList,
TouchableOpacity,
Alert,
} from 'react-native';
import SegmentedControlTab from 'react-native-segmented-control-tab';
import MyPackageName from 'my-package-name';
Podfile for AwesomeProject
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'AwesomeProject' do
# Pods for AwesomeProject
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
target 'AwesomeProjectTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'AwesomeProject-tvOS' do
# Pods for AwesomeProject-tvOS
target 'AwesomeProject-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Tried react-native link but that did not work too.