2

摘要:我正在构建一个 Flutter 插件,用于我正在开发的多个项目。我没有编写自定义平台特定代码的经验。

我在将 IOS *.Framework 和 *-Resources.bundle 的 SDK 库导入我的插件时遇到问题。

我已经尝试过https://github.com/flutter/flutter/issues/17978中的解决方案

另外,我尝试清理和重新构建应用程序但没有成功,并尝试清理和重新构建示例应用程序但没有成功,我收到以下错误:

*.podspec:

Pod::Spec.new do |s|
  s.name             = 'plugin_name'
  s.version          = '0.0.1'
  s.summary          = 'A new flutter plugin project.'
  s.description      = <<-DESC
A new flutter plugin project.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Your Company' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.public_header_files = 'Classes/**/*.h'
  s.dependency 'Flutter'

  s.ios.deployment_target = '9.0'
end


Pod::Spec.new do |spec|
  spec.name         = "plugin_name"
  spec.version      = "2.3.7"
  spec.summary      = "SDK"
  spec.homepage     = "https://hkhars.com"
  spec.author       = "Hussain Alkhars"
  spec.license          = { :file => '../LICENSE' }
  spec.source           = { :path => '.' }
  spec.ios.deployment_target  = '9.0'
  spec.preserve_paths = 'IOSFLUTTERSDK.framework'
  spec.xcconfig = { 'OTHER_LDFLAGS' => '-framework IOSFLUTTERSDK' }
  spec.vendored_frameworks = 'IOSFLUTTERSDK.framework'
  spec.public_header_files = "IOSFLUTTERSDK.framework/Headers/*.h"
  spec.resource_bundle = { 'IOSFLUTTERSDK-Resources' => './*' }
end

尝试构建时出错flutter build ios --no-codesign

fatal error: 'plugin_name/PluginNamePlugin.h' file not found
    #import <plugin_name/PluginNamePlugin.h>```
4

1 回答 1

2

你已经破坏了你的 Podspec 文件。应该只有一个部分开始Pod::Spec.new do |s|...。如果您想尝试链接的 Github 问题中的方法,您的 Podspec 文件应如下所示:

Pod::Spec.new do |s|
  s.name             = 'plugin_name'
  s.version          = '0.0.1'
  s.summary          = 'A new flutter plugin project.'
  s.description      = <<-DESC
A new flutter plugin project.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Your Company' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.public_header_files = 'Classes/**/*.h'
  s.dependency 'Flutter'
  s.ios.deployment_target = '9.0'
  s.preserve_paths = 'IOSFLUTTERSDK.framework'
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework IOSFLUTTERSDK' }
  s.vendored_frameworks = 'IOSFLUTTERSDK.framework'
  s.resource_bundle = { 'IOSFLUTTERSDK-Resources' => './*' }
end

但是,我之前尝试过但没有成功 - 我需要通过打开项目通过 Xcode 手动链接所有内容:

open example/ios/Runner.xcworksapce

单击顶部的“Runner”项目,然后单击右侧的“Build Phases”项(如果“Build Phases”未显示,请确保选择左侧的文件夹图标,然后您我点击了中间面板中的 Runner Target ,而不是 Runner Project)。

在此处输入图像描述

找到“Link Binary with Libraries”面板,然后单击“+”按钮:

在此处输入图像描述

选择您的 .framework 文件并单击“完成”。在“嵌入框架”下重复相同的操作。

我不是 100% 确定,但我认为你可以在“复制捆绑资源”下做同样的事情。

于 2019-07-19T04:25:32.423 回答