【问题标题】:Import Firebase in dynamic Swift framework (with/without Cocoapods) and import framework into app target在动态 Swift 框架(带/不带 Cocoapods)中导入 Firebase 并将框架导入应用程序目标
【发布时间】:2016-12-24 20:12:08
【问题描述】:

Firebase for iOS 是一个推荐使用 Cocoapods 集成的 Objective-C 框架。这是我尝试设置的方法:

我在 OS X 10.11.6 上运行 Xcode 8b6。该应用使用 iOS 10 SDK 构建,面向 iOS 9。

MyApp 是我想要使用的常规 (Swift) iOS 应用程序。

MyFramework 是一个嵌入动态框架的应用程序,q。我希望将所有 Firebase 代码抽象到框架中,因此将 Firebase 添加到我的Podfile 中的MyFramework 目标:

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

target 'MyApp' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyApp
  target 'MyAppTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

target 'MyApp' do
  pod 'Firebase'
  pod 'Firebase/Database'
  pod 'Firebase/Auth'
end

在运行pod install 时,我可以在MyFramework 中的所有.swift 文件中导入Firebase。但是,在我的应用程序中的任何位置使用 import MyFramework 时,我收到错误 Missing required module Firebase

认为这可能是 Cocoapods 问题,我开始了一个新项目并手动集成了 Firebase,但最终遇到了同样的问题。 这是一个已知的问题?如果是这样,有什么解决办法吗?

【问题讨论】:

  • 同样的问题...
  • 运气好吗?我也面临同样的问题
  • 有人找到解决方案了吗?我从几天以来就面临着同样的问题和挣扎
  • 嗨@fruechtemuesli,看看这个答案stackoverflow.com/a/47904050/5333674

标签: ios swift xcode firebase cocoapods


【解决方案1】:

也许你可以将它包含在你的 podfile 中

//因为你的目标是 iOS 9.0

platform :ios, '9.0'
use_frameworks!

def firebase_pods
 pod 'Firebase'
 pod 'Firebase/Database'
 pod 'Firebase/Auth'
end

target 'MyApp’ do
 firebase_pods

如果这对你不起作用,请告诉我,我可以尝试以其他方式提供帮助

【讨论】:

    【解决方案2】:

    在 MyFramework 的 podspec 中,添加 Firebase pod 的依赖。还将静态框架标志设置为true。这就是您的 podspec 的外观:

    *OTHER METADATA RELATED TO MYFRAMEWORK*
    s.static_framework = true
    s.dependency   'Firebase'
    s.dependency   'Firebase/Database'
    s.dependency   'Firebase/Auth'`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 2016-01-27
      • 2017-02-10
      • 2015-09-14
      • 2018-06-25
      相关资源
      最近更新 更多