ios - 在 Flutter iOS 平台特定代码中使用 Cocoapods 库

标签 ios swift flutter cocoapods platform-specific

我正在尝试使用 Cocoapods 库(用于外部 SDK),但我没有找到任何相关文档。我已经将它集成到 Android 部分,只需在 Gradle 文件中添加一行即可。

简单地说,我想创建(或者可能找到)一个podfile,我可以在其中添加我的依赖项并在AppDelegate.swift 文件中使用它。

到目前为止我尝试的是在 ios/ 文件夹中运行 pod init 然后添加我的 pod(例如 pod 'Charts')并运行 pod install 但它说:

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target Runner to Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig or include the Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig in your build configuration (Flutter/Release.xcconfig).

然后当我尝试在 Xcode 上构建时,它给了我这个错误:

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

我认为我的做法是正确的,但我在 Flutter.io 文档上找不到任何可以帮助我的东西。

预先感谢您的帮助!

最佳答案

ios/ 文件夹中运行 pod initpod install 后,添加

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

ios/Flutter/Debug.xcconfig

并添加

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

ios/Flutter/Release.xcconfig

关于ios - 在 Flutter iOS 平台特定代码中使用 Cocoapods 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53630136/

相关文章:

flutter - 没有为该类定义方法 pickImage

flutter - 我如何控制头像大小和它与FilterChip中的标签之间的间距

ios - 由于未捕获的异常 'NSGenericException'终止应用程序,原因: 'Use the ` initWithVideoIdentifier:`方法

ios - UIButton 背景图像以编程方式更改

ios - Xcode (Swift) - 如何在按钮上存储图像文件的名称

swift - 视频不在应用程序中播放

iphone - 有没有办法在iOS模拟器上查看文件系统?

ios - 难以附加到 Swift 中的数组

ios - Swift tableview 找不到接受所提供参数的 'subscript' 重载

flutter - 我无法使用 google_sign_in 在 Flutter 中登录我的 Google 帐户