【问题标题】:How to integrate React with cocoapods to my podspec如何将 React 与 cocoapods 集成到我的 podspec
【发布时间】:2017-01-28 15:04:10
【问题描述】:

我想在 iOS 上用 react native 做一些基本的操作,然后上传到 cocoapods,当我编辑 xxx.podspec 时,我无法指定 react 的版本号和源链接。

**

  1. 这是我的 podspec:

**

  s.ios.deployment_target = '8.0'

  s.source_files = 'SCCReactNative/Classes/**/*'

  # s.resource_bundles = {
  #   'SCCReactNative' => ['SCCReactNative/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
  s.dependency 'React', :git => 'https://github.com/facebook/react-native.git', :tag => 'v0.31.0', :subspecs => [
  'Core',
  'RCTImage',
  'RCTNetwork',
  'RCTText',
  'RCTWebSocket',
  'ART',
  'RCTActionSheet',
  'RCTAdSupport',
  'RCTCameraRoll',
  'RCTGeolocation',
  'RCTPushNotification',
  'RCTSettings',
  'RCTVibration',
  'RCTLinkingIOS',
  #'RCTTest',
  ]`enter code here`

**

  1. 这是错误

**

[!] Invalid `SCCReactNative.podspec` file: undefined local variable or method `source' for Pod:Module.


 #  from /Users/huangcheng/Desktop/Project/SCCReactNative/SCCReactNative.podspec:50
 #  -------------------------------------------
 #    s.dependency 'SCCUtil'
 >    s.dependency 'React', source => 'https://github.com/facebook/react-native.git' ,tag => 'v0.31.0' ,subspecs => [
 #    'Core',
 #  

谁能帮帮我?

【问题讨论】:

    标签: objective-c react-native cocoapods podspec


    【解决方案1】:

    据我所知,您无法使用其来源指定依赖项: https://github.com/CocoaPods/CocoaPods/issues/4921

    s.dependency 'React' 应该够了

    【讨论】:

      【解决方案2】:

      现在,我解决了这个问题,所以我分享这个想法。

      首先将这个 React.podspec 克隆到自己的 pod 中,就像这样

      file list

      并将 react-native 标签 v0.31.0 podspec 写入此文件 React.podspec。

      所以我们可以使用

      s.dependency 'React' , '0.31.0'
      

      【讨论】:

        猜你喜欢
        • 2014-07-30
        • 1970-01-01
        • 2013-10-11
        • 2012-12-15
        • 2017-04-10
        • 2019-02-05
        • 2016-05-14
        • 2017-04-06
        • 1970-01-01
        相关资源
        最近更新 更多