ios - 在动态 Swift 框架(带/不带 Cocoapods)中导入 Firebase 并将框架导入应用程序目标

标签 ios swift xcode firebase cocoapods

Firebase for iOS 是一个 Objective-C 框架,推荐使用 Cocoapods 进行集成。以下是我尝试设置它的方式:

我在 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,但最终遇到了同样的问题。 这是一个已知的问题?如果是这样,是否有任何修复方法?

最佳答案

在 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'`

关于ios - 在动态 Swift 框架(带/不带 Cocoapods)中导入 Firebase 并将框架导入应用程序目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39009004/

相关文章:

ios - 如何在其他类中使用导入的HealthKit样本

ios - 额外参数错误

ios - Swift - 使用哪些类型? NSString 或字符串

ios - 如果检测到超出范围,则禁用平移手势

ios - Swift/如何使用 Root View Controller /页面 View Controller 隐藏导航栏。屏幕顶部的小缝隙

ios - SearchBar 的 UITextField 填充?

ios - 无法将条形按钮项目添加到 Xcode 中的导航 Controller

ios - 绕过 "Sign in with Apple"

ios - CoreData 类的自定义方法

ios - 密码不保存