【问题标题】:How to install extensions on React Native installed with Cocoapods?如何在使用 Cocoapods 安装的 React Native 上安装扩展?
【发布时间】:2015-11-16 09:00:40
【问题描述】:

我刚刚按照此处的说明安装了 React Native: http://facebook.github.io/react-native/docs/embedded-app-ios.html#content

但是,我不知道如何安装第三方扩展,例如 react-native-icons。到目前为止,我尝试的是 npm install react-native-icons 在 ReactComponent 目录中。但是当我运行该应用程序时,它显示错误说 react-native-icons 不能需要 react-native,这是可以理解的,因为 react-native 不在 node_modules 中。那么当 React Native 与 Cocoapods 一起安装时,安装扩展的正确方法是什么?任何提示表示赞赏!

【问题讨论】:

  • 我遇到了同样的问题。你有什么发现吗?
  • 不...我放弃了 react native 并转向了真正的原生应用程序。
  • 有人想出这个吗?

标签: ios npm cocoapods react-native


【解决方案1】:

如果您要使用的扩展程序没有,您需要为它创建一个 Podspec。您可以从扩展的 package.json 文件中复制大部分信息。

一个示例 podspec,取自 https://github.com/fraserxu/react-native-couchbase-lite/blob/master/ReactNativeCouchbaseLite.podspec

# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = "ReactNativeCouchbaseLite"
  s.version          = "0.2.2"
  s.summary          = "couchbase lite binding for react-native"
  s.license          = 'MIT'
  s.platform     = :ios, '7.0'
  s.requires_arc = true
  s.authors      = "Fraser Xu <xvfeng123@gmail.com>"
  s.homepage     = "https://github.com/fraserxu/react-native-couchbase-lite.git"
  s.source       = { :git => 'https://github.com/fraserxu/react-native-couchbase-lite.git' }
  s.source_files = 'ios/**/*.{h,m}'
  s.dependency 'couchbase-lite-ios'
  s.dependency 'couchbase-lite-ios/Listener'
end

一旦你确认它的工作,继续向作者发送一个包含 Podspec 文件的拉取请求,就像我做的那样:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-07
    • 2021-07-11
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 2014-01-12
    • 2019-09-22
    相关资源
    最近更新 更多