首页 > 解决方案 > 自定义 React Native 库中的 CocoaLumberjack 依赖项

问题描述

我们的团队为 IOS 创建了一个 SDK,我已将其导入我的 react native 自定义库中。SDK 还依赖于 Swift Package CocoaLumberjack。

我在我的 podspec 中添加了“ s.dependency 'CocoaLumberjack', '~> 3.7.0' ”。当我将我的库添加到反应本机应用程序并运行pod install时,我收到如下错误:

The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `react-native-sdk` depends upon `CocoaLumberjack`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

我的应用程序 pod 文件如下:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'SdkExample' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  pod 'react-native-sdk', :path => '../..'

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.80.0' })
  post_install do |installer|
    flipper_post_install(installer)
  end
end

我的自定义库的 podspec 是这样的:

require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
  s.name         = "react-native-sdk"
  s.version      = package["version"]
  s.summary      = package["description"]
  s.homepage     = package["homepage"]
  s.license      = package["license"]
  s.authors      = package["author"]

  s.platforms    = { :ios => "11.0" }
  s.source       = { :git => "https://github.com/ankushss/react-native-sdk.git", :tag => "#{s.version}" }

  s.source_files = "ios/**/*.{h,m,mm,swift}"

  s.dependency "React-Core"
  s.dependency 'CocoaLumberjack', '~> 3.7.0'
  s.vendored_framework = 'ios/CustomFramework.framework'
end

请帮助我。

标签: swiftreact-nativecocoapodsreact-native-iospodspec

解决方案


推荐阅读