简体   繁体   English

在 flutter 安装原生 iOS pod

[英]Install native iOS pod in flutter

I am facing an error while making a flutter plugin on the iOS side while using pods.我在使用 pod 时在 iOS 端制作 flutter 插件时遇到错误。 The pods are installed successfully then also I am able to import them in the file.吊舱已成功安装,然后我也可以将它们导入文件中。

The pod in my case which I am trying to use is Freshchat iOS SDK我尝试使用的 Pod 是Freshchat iOS SDK

Steps I have followed to install the pod我安装 pod 所遵循的步骤

  1. Start a new Flutter plugin project.启动一个新的 Flutter 插件项目。

  2. In .podspec file add s.dependency 'FreshchatSDK'.podspec文件中添加s.dependency 'FreshchatSDK'

  3. Run pod install in example/ios folder.example/ios文件夹中运行pod install

    I got an error我有一个错误

    The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/nimish/FlutterProjects/freshchat_flutter/freshchat_flutter/example/ios/Pods/FreshchatSDK/FreshchatSDK/libFDFreshchatSDK.a)

  4. I removed use_frameworks!我删除use_frameworks! from podfile following this comment .来自此评论后的podfile

  5. I ran pod install again and the pods were successfully installed and Pods folder was created which had FreshchatSDK folder in it.我再次运行pod install并成功安装了 pod,并创建了Pods文件夹,其中FreshchatSDK文件夹。

Now I need to have use_frameworks!现在我需要use_frameworks! in my project because other plugins are not compiling because of this.在我的项目中,因为其他插件因此没有编译。

  1. I added s.static_framework = true in .podspec and use_frameworks!我在.podspec和 use_frameworks 中添加了s.static_framework = true use_frameworks! in podfile .podfile中。 Now pod install ran successfully,现在pod install运行成功,

  2. After I added the import #import "FreshchatSDK.h" in my Plugin.h file I got the error在我的Plugin.h文件中添加 import #import "FreshchatSDK.h"后,出现错误

    error: include of non-modular header inside framework module

I tried this answer but was not able to resolve it.我尝试了这个答案,但无法解决。

Please help me resolve this.请帮我解决这个问题。 I'll be respectful of your time.我会尊重你的时间。

There is another flutter plugin available here but it has many issues and one unhandled case is making my iOS app crash so I want to make it my own.这里还有另一个 flutter 插件,但它有很多问题,一个未处理的案例导致我的 iOS 应用程序崩溃,所以我想把它变成我自己的。

There may be problems in the PodFile due to unmatched Targets.由于不匹配的目标,PodFile 中可能存在问题。 When this happens to me, I used these simple steps.当我遇到这种情况时,我使用了这些简单的步骤。

  1. Delete Podfile删除 Podfile
  2. Open Terminal at the specific file在特定文件中打开终端
  3. Pod init
  4. Open Podfile and adds Dependencies打开 Podfile 并添加依赖项
  5. Pod install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM