【问题标题】:Firebase for iOS inside frameworkFirebase for iOS 内部框架
【发布时间】:2018-11-27 23:14:53
【问题描述】:

我有一个项目需要firebase 进行登录和...

所以我决定在我的工作区中创建一个项目(Cocoa Touch Framework)来处理所有的firebase操作。

通过链接框架和库

添加到主应用的 firebase 框架

我也用cocoa pods

我的 pod 文件是这样的:

platform :ios, '10.0'
inhibit_all_warnings!

def firebase
    # Firebase
    pod 'Firebase/Core'
    pod 'FirebaseUI/Auth'
    pod 'FirebaseUI/Google'
    pod 'FirebaseUI/Facebook'
    pod 'FirebaseUI/Phone'
    pod 'Firebase/Storage'
    pod 'FBSDKLoginKit'
end

target 'RKFirebaseModule' do
    use_frameworks!
    workspace 'Main'
    project 'RKFirebaseModule/RKFirebaseModule.xcodeproj'

    firebase
end

target 'App' do
  use_frameworks!
  workspace 'Main'
  project 'App.xcodeproj'

  rx_swift
  rx_cocoa

end

此时如果我运行该应用程序,我将收到此错误:

dyld: Library not loaded: @rpath/Bolts.framework/Bolts
  Referenced from: /.../RKFirebaseModule
  Reason: image not found

所以我尝试通过将firebase依赖项添加到主应用程序(在pod文件中)来解决这个问题:

target 'App' do
  use_frameworks!
  workspace 'Main'
  project 'App.xcodeproj'

  rx_swift
  rx_cocoa
  firebase

end

现在我收到一堆与此类重复实现有关的错误:

Class FIRAIdentifiers is implemented in both /.../RKFirebaseModule.framework/RKFirebaseModule and /.../App.app/App. One of the two will be used. Which one is undefined.

那么我该如何解决这个问题呢?

任何帮助或建议将不胜感激。 tnx

编辑 1: 类似案例在这里找到,但没有提到的方法对我有用。

1.Duplicate symbols when framework target has a static dependency

2.Duplicate classes warnings at runtime when multiple targets are contained in the same project

编辑 2: 第一个问题是正常的,正是由于这个事实,cocoa pods 不会将依赖项捆绑到框架中,所以我必须使用主应用程序的相同依赖项。

第二个问题是由一些firebase静态框架引起的,所以我的框架有一个firebase static frameworks的副本,主应用也有一个副本,所以这里预计会出错。

我必须删除重复的静态框架。怎么样?

【问题讨论】:

  • 同样的问题,你设法让它工作@mehdok吗?
  • @JoanCardona,不,我将所有 firebase 操作移至主项目而不是框架。

标签: ios swift firebase firebase-authentication cocoapods


【解决方案1】:

我在使用自己构建的框架时遇到了类似的问题,并且该框架也用于使用 firebase 的项目中。我遇到的解决方法是使用 cocoapods。我使用 cocoapods 将我的框架构建为静态框架(检查下面的 .podspec):

  s.static_framework = true
  s.dependency 'Firebase'
  s.dependency 'Firebase/Core'

我正在开发的示例应用程序也通过 cocoapods 导入了我的框架

use_frameworks!
pod 'gameballSDK', :path => "~/Documents/Libraries/gameballSDK"

【讨论】:

  • 你现在用的是同样的方法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多