本地本机模块不能为空

时间:2019-12-18 03:35:14

标签: ios react-native react-native-ios

我正在本地构建本机模块。 为了测试我对本机模块所做的更改,我使用了一个依赖于本地模块的本地应用程序。 我面临的问题是,每当我尝试运行ios应用程序时,都会收到一条错误消息,提示“本地模块不能为空”

本机模块:

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文件:

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';

AwesomeProject的Podfile

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

尝试了本机反应链接,但是那也不起作用。

0 个答案:

没有答案