1

我很快就会为此失去理智,但它就是这样:-)

我想RevenueCat/react-native-purchases在我的项目中使用,但是一旦我导入

import Purchases from 'react-native-purchases';

我收到消息“本机模块不能为空”

我有一个裸项目的测试仓库,我也无法让它工作

您可以在 repo 中看到 package.json 和 Podfile - 我正在使用 yarn 将它们放在一起。

libRNPurchases.a我已经在 Xcode中添加到我的项目中,并且我已经多次重做这些说明:-$

为了快速参考这里是我的 package.json 文件

{
  "scripts": {
    "postinstall": "jetify",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "expo": "^35.0.0",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "0.59.10",
    "react-native-gesture-handler": "~1.3.0",
    "react-native-purchases": "^2.4.1",
    "react-native-reanimated": "~1.2.0",
    "react-native-screens": "1.0.0-alpha.23",
    "react-native-unimodules": "~0.5.4",
    "react-native-web": "^0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.6.0",
    "babel-jest": "24.9.0",
    "jest": "24.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "0.56.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "private": true
}

PodFile 是:

platform :ios, '11.0'

require_relative '../node_modules/react-native-unimodules/cocoapods'

target 'IAPTEST2' do
  # Pods for IAPTEST
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  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'
  pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  pod 'RNReanimated', :podspec => '../node_modules/react-native-reanimated/RNReanimated.podspec'
  pod 'RNScreens', :path => '../node_modules/react-native-screens'

  use_unimodules!

  pod 'RNPurchases', :path => '../node_modules/react-native-purchases'

  pod 'Purchases', '~> 2.6'

end

由于 expo,我正在使用 React-Native "0.59.10" - 所以它仍然使用旧的 pod 文件格式。

有什么想法我需要做什么吗?

4

0 回答 0