具有Firebase依赖关系的iOS Dyanmic框架 [英] iOS Dyanmic Framework with Firebase Dependencies

查看:69
本文介绍了具有Firebase依赖关系的iOS Dyanmic框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个框架,该框架依赖于诸如登录,分析等某些Firebase依赖性.一旦我们的框架开发完毕,我们就会将其分发给我们的客户.

We are developing a framework that is dependent on some firebase dependencies like login, analytics, etc. Once our framework is developed we will distribute it to our customers.

需要注意的事情

  1. 代码不应该可见(最好的建议是创建XCFramework)
  2. 如果可能,请创建动态框架而不是静态框架
  3. 可以通过Swift程序包管理器或cocoapods分发

我们尝试过的事情

  1. 我们尝试使用pod创建动态框架,然后创建XCFramework.但是在导入客户端应用程序时,未找到pods模块
  2. 我们创建了静态库,并手动(直接在项目中)添加了Firebase而不是pod,在这种情况下,不会导入XCFramework

我们已尝试创建此处提到的XCFrame Work(用于动态框架)具有Pod依赖关系的XCFramework

We have tried to create XCFrame Work as mentioned here (for dynamic framework) XCFramework with Pods Dependencies

可以使用隐藏的代码伞框架和通用库,但使用firebase时,这种方法很典型,很多地方也没有在Internet上建议使用还有其他/替代方式可以满足我们的要求吗?

To hide code umbrella framework and universal library can be used,but with firebase, this approach is to typical and also not suggested on the internet at many places Is there any other/alternative way where we can fulfill our requirements?

推荐答案

我们现在具有完全相同的设置,并且效果很好.希望对您有所帮助.

We have the exact same setup right now, and it works quite well. Hope that'll also be of help for you.

需要照顾的事情:

  • 这是XCFramework发行版.
  • 它已由CocoaPods分发(尽管在私有Podspec存储库中)
  • 这是一个动态框架.

先决条件:

  • CocoaPods版本> = 1.10.1
  • Xcode版本> = 11.6(虽然可能更低,但不确定)

创建 .xcframework 后,您需要为框架使用 .podspec ,该外观应类似于:

After creating your .xcframework, you need to have a .podspec for your framework, which should look like:

Pod::Spec.new do |s|

  # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  s.name         = "MyAwesomeSDK"
  s.version      = "1.0.0"
  s.summary      = "Best framework ever: MyAwesomeSDK"
  s.description  = <<-DESC
                   "Best framework ever: MyAwesomeSDK"
                   DESC
  s.homepage     = "http://github.com"
  s.license      = "MIT"
  s.author       = { "ItIsI" => "me@myself.com" }

  # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  s.platform = :ios
  s.ios.deployment_target = '11.3'

  # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  s.source = { :http => '<MyAwesomeSDK.zip> (We're storing our zipped .xcframework in a hosted page)' }
  s.vendored_frameworks = 'MyAwesomeSDK.xcframework'

  s.swift_version = "5.0"

  # ――― Dependencies ―――――――――――――――――――――――――――---――――――――――――――――――――――――――――――― #
  s.dependency 'SwiftProtobuf',   '1.12.0'
  s.dependency 'lottie-ios',      '3.1.8'
  # Any other dependency you might need.
end

然后,我们通过Podfile在另一个项目中使用它,如下所示:

Then, we are consuming it in another project via Podfile, that will look like:

platform :ios, '13.0'

# If you're going to have a private Podspec repo, add the source URL here.
# Don't forget to add the original source if you're going to specify another source.
# source 'https://cdn.cocoapods.org/'

target 'Test' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # If you are publishing the SDK publicly or in a private Podspec repository, this is it:
  pod 'MyAwesomeSDK'

  # If not, you should provide the .podspec to your customers, and:
  pod 'MyAwesomeSDK', :podspec => '<path/to/MyAwesomeSDK.podspec>'

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

  target 'TestUITests' do
    # Pods for testing
  end

end

然后就这样!运行 pod install 时,您应该看到:

Then, that's it! When running pod install, you should see:

Analyzing dependencies
Downloading dependencies
Installing MyAwesomeSDK (1.0.0)
# These are our own:
# ---
Installing SwiftProtobuf (1.12.0)
Installing lottie-ios (3.1.8)
# ---
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 3 total pods installed.

P.S:我们还必须在Podfile中添加一个post_install设置,否则将无法正确链接依赖项框架:

P.S: We also had to add a post_install setup in our Podfile, otherwise it'll not properly link the dependency frameworks:

if ["SwiftProtobuf", "lottie-ios"].include? target.name
  target.build_configurations.each do |config|
    config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
  end
end

这篇关于具有Firebase依赖关系的iOS Dyanmic框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆