3

我创建了一个 React Native 库,它是在 React Native 项目中使用原生 iOS 框架的包装器。早些时候我使用.framework并且工作正常。现在我在使用这个库时遇到了一个问题.xcframework而不是.framework

我将此库添加为项目的依赖项,然后在运行pod install时出现以下错误:

[!] [Xcodeproj] 生成重复的 UUID:

当我打开项目并尝试构建它时,它为设备成功构建,但在模拟器上失败。

下面是我在库项目中使用的 Podspec 文件:

Pod::Spec.new do |s|
  s.name         = "react-native-myLibrary"
  s.version      = "1.0.0"
  s.summary      = "react-native-myLibrary"
  s.description  = <<-DESC
                    react-native-myLibrary
                   DESC
  
  s.homepage     = "https://github.com/geektimecoil/react-native-onesignal"
  s.license      = "MIT"
  s.author       = { "author" => "author@domain.cn" }
  s.platform     = :ios, "10.0"
  s.source       = { :http => 'file:' + __dir__ + '/' }

  s.source_files = "**/*.{h,m,swift}"
  s.requires_arc = true
  s.vendored_frameworks = 'MyLibrary.xcframework'

  s.dependency "React"
end

在搜索解决方案时,我发现此错误是由s.source_files = "**/*.{h,m,swift}". 所以,我评论了这一行并pod install再次运行。错误消失了,但没有将依赖项添加到 Project 目标中。谁能给我提供用于React Native Library中本地.xcframework的Podspec文件。提前致谢!

4

2 回答 2

3

我能够使用以下方法解决此问题:

s.source_files = "ios/*.{h,m,swift}"
s.vendored_frameworks = 'ios/Frameworks/MyLibrary.xcframework'

并且还通过将框架搜索路径从构建设置更新为$(inherited)

于 2021-05-08T07:13:12.040 回答
0

尝试这个:

s.preserve_paths =  'MyFraemwork.xcframework/*'
s.source_files = 'MyFraemwork.xcframework/ios-arm64_armv7/PicUPSDKv3.framework/Headers/*.{h,m,swift}'

于 2021-03-21T14:14:22.957 回答