0

我向我的 React Native iOS 项目添加了一个框架,方法是将它添加到 Frameworks 文件夹并确保它在我们的 Target -> Build Phases -> Link Binary with Libraries 中。我向使用该框架的 AppDelegate 添加了一些代码,一切似乎都可以正确编译和运行。

现在我想在我们创建的自定义本机模块中使用该框架。我们使用 create-react-native-library 创建了库,并使用 yarn 和 pod install 安装它。当我们不尝试在 .swift 文件中导入框架时,该库可以编译并正常工作。但是,一旦我们尝试导入框架,它就无法编译并显示“没有这样的模块 'TheFramework'”。我认为我们需要更改我们的 podspec 才能使其正常工作。

我尝试过的一些方法不起作用:

s.dependency "TheFramework" # can't use the public version, need to use the local one

s.dependency "TheFramework", :path => '../../ios/TheFramework.framework' # fails to pod install - "Podspecs cannot specify the source of dependencies. The `:path` option is not supported. `:path` can be used in the Podfile instead to override global dependencies."

s.vendored_frameworks = "TheFramework.framework" # fails to compile - "No such module 'TheFramework'"

--

更新(并改写):

我有一个私有 .framework 需要在 react native 项目中使用。

我运行create-react-native-module并可以使用 yarn add/pod 安装我的本机模块,但是在向其中添加框架时遇到了麻烦。通常我可以只写s.dependency "LibraryName"在 podspec 中,但在这种情况下这不起作用,因为它不是一个已发布的库。

我通常尝试将框架添加到我的 XCode 项目中,这在一定程度上起作用 - 我能够编译我的代码并将框架导入到我的 AppDelegate 中。但我无法在我的自定义本机模块中引用它。

我从 XCode 项目中删除了它,现在尝试将它包含在 pod/podspec 中,但似乎没有任何效果。我将它添加到 pod 的 XCode 项目中,并添加s.ios.vendored_frameworks = "Frameworks/TheFrameworkName.framework"到了我的 podspec 中,现在我无法将它导入到我的本机模块或我的 AppDelegate 中。

关于如何完成这项工作的任何提示或想法?

--

更新:最终没有为此使用 pod,而是像您通常在它不是 pod 时那样实现了我的本机模块。问题仍然存在。

4

0 回答 0