无法导入使用Cocoapods安装的依赖项

Bra*_*sen 13 xcode ios cocoapods swift flutter

我已经用Cocoapods安装了FBSDK但由于某种原因无法在我的AppDelegate.swift文件中导入它.FBSDK工具包出现在我的Xcode项目中,所以我觉得它应该正常工作. 在此输入图像描述

无论如何我都不是iOS开发人员,我只是想为Flutter SDK编写一个简单的原生插件.有人有想法吗?

- 这是pod文件的样子 -

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
  abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
end

target 'Runner' do
  use_frameworks!

  # Pods for Runner
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'

  # Flutter Pods
  pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']

  if File.exists? '../.flutter-plugins'
    flutter_root = File.expand_path('..')
    File.foreach('../.flutter-plugins') { |line|
      plugin = line.split(pattern='=')
      if plugin.length == 2
        name = plugin[0].strip()
        path = plugin[1].strip()
        resolved_path = File.expand_path("#{path}/ios", flutter_root)
        pod name, :path => resolved_path
      else
        puts "Invalid plugin specification: #{line}"
      end
    }
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

- -编辑 - -

我收到以下错误atm FBSDKCoreKit.framework: No such file or directory:.当我在xCode中打开Frameworks文件夹时,所有文件名都是红色的: 在此输入图像描述 但Finder中的确切文件夹是空的.所以我猜这就是错误显示的原因.问题是如何解决这个问题......

这就是我embedded binarieslinked frameworks and libraries看起来像项目: 在此输入图像描述

Bry*_*den 22

  1. 选择您的项目目标
  2. 转到构建设置.
  3. 搜索标题搜索路径.
  4. 使用递归添加此值$(SRCROOT)/ Pods,然后Xcode将为您解析路径.

在此输入图像描述

  • 在xcode v11中,以下内容对我有用:$(SOURCE_ROOT)/ Pods / ** (2认同)
  • 我已经这样做了仍然不起作用。请帮忙。 (2认同)

Qua*_*ees 11

你是打开.xcodeproj还是.xcworkspace?每次安装 cocoapod 时,请确保它是工作区


S2d*_*ent 5

我会天真地假设你没有use_frameworks!Podfile。如果这是真的,那么您有两种方法可以从这里开始:

  1. 在您Runner-Bridging-Header.h添加#import <FBSDKCoreKit/FBSDKCoreKit.h>,删除import FBSDKCoreKitAppDelegate.swift,只是继续写代码。

  2. 添加use_frameworks!到您的Podfile并运行pod install再次。这可能会带来一些其他问题,但如果可行,我会建议这样做。