【问题标题】:CocoaPods not updating Firebase SDK to Version 4.0.0CocoaPods 未将 Firebase SDK 更新到版本 4.0.0
【发布时间】:2017-10-29 22:42:58
【问题描述】:

我正在尝试使用 CocoaPods (as suggested by the documentation) 将我的 Swift 项目更新为 Firebase's new SDK Version 4.0.0,但即使我关注 steps in the documentation,更新的 SDK 似乎也没有安装。

谁能帮助我理解为什么这不起作用以及我可以做些什么来更新到新的 Firebase SDK?

我的 Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '9.2'
# Uncomment this line if you're using Swift
use_frameworks!


target 'myProject' do

pod 'Firebase'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Firebase/Crash'
pod 'Firebase/Messaging'


pod 'Alamofire', '~> 4.4'

end

当我运行 pod install 时,我得到了这个看似有希望的输出(除了它不是版本 4,我认为它应该是):

Analyzing dependencies
Downloading dependencies
Using Alamofire (4.4.0)
Installing Firebase 3.17.0 (was 3.17.0)
Using FirebaseAnalytics (3.9.0)
Using FirebaseAuth (3.1.1)
Using FirebaseCore (3.6.0)
Using FirebaseCrash (1.1.6)
Using FirebaseDatabase (3.1.2)
Using FirebaseInstanceID (1.0.10)
Using FirebaseMessaging (1.2.3)
Using FirebaseStorage (1.1.0)
Using GTMSessionFetcher (1.1.9)
Using GoogleToolboxForMac (2.1.1)
Using Protobuf (3.3.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 8 dependencies from the Podfile and 13 total pods installed.

我可以说它也没有更新到最新的 SDK,因为新的 firebase 文档与我的项目中的功能不匹配。我的项目是用 Swift 编写的,例如:

作品

FIRApp.configure()

不起作用 (but is suggested by documentation)

FirebaseApp.configure()

我也尝试过这些解决方案:

【问题讨论】:

  • 你有什么版本的 CocoaPods?,检查版本使用命令:“pod --version”。您应该使用最新版本!
  • @DiegoQ 我有 1.2.1 版(虽然想法不错;需要文档说明 CocoaPods 1.0.0 或更高版本,因此我可以看到在其他情况下这是一个问题)
  • 也许 - pod repo 更新和重试
  • @PaulBeusterien 刚刚尝试了 pod repo update 并重新运行了 pod install。不走运,但无论如何感谢您的建议
  • 在控制台运行“pod update”,然后再次“pod install”

标签: ios swift firebase sdk cocoapods


【解决方案1】:

类似于 Alamofire 在我的原始 podfile 中声明我想要的版本,为 firebase 这样做使其更新到版本 4.0.0 并且适当的 firebase 功能现在可以工作。

例如:

更改(针对每个):

pod 'Firebase/Auth'

收件人:

pod 'Firebase/Auth', '~> 4.0.0'

我的新 podfile 的完整示例以及运行pod install 后的输出如下。

正确的 Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '9.2'
# Uncomment this line if you're using Swift
use_frameworks!


target 'myProject' do

pod 'Firebase', '~> 4.0.0'
pod 'Firebase/Auth', '~> 4.0.0'
pod 'Firebase/Core', '~> 4.0.0'
pod 'Firebase/Storage', '~> 4.0.0'
pod 'Firebase/Database', '~> 4.0.0'
pod 'Firebase/Crash', '~> 4.0.0'
pod 'Firebase/Messaging', '~> 4.0.0'


pod 'Alamofire', '~> 4.4'

end

输出

Analyzing dependencies
Downloading dependencies
Using Alamofire (4.4.0)
Using Firebase (4.0.0)
Using FirebaseAnalytics (4.0.0)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.0)
Using FirebaseCrash (2.0.0)
Using FirebaseDatabase (4.0.0)
Using FirebaseInstanceID (2.0.0)
Using FirebaseMessaging (2.0.0)
Using FirebaseStorage (2.0.0)
Using GTMSessionFetcher (1.1.10)
Using GoogleToolboxForMac (2.1.1)
Using Protobuf (3.3.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 8 dependencies from the Podfile and 13 total pods installed

【讨论】:

  • 这可以完成但不是必需的,并且需要在每个新的 pod 版本发布时更新文件。请查看 Paulo Mattos 的回答:如果您想保留所有 pod 的最新版本(未指定版本),只需运行“pod update”
  • 目前运行良好,但我认为这不是我们真正想要的正确解决方案。
【解决方案2】:

您原来的Podfile 没有任何问题;)您只是将pod installpod update 混淆了——您运行的是前者,但您应该使用后者。一个简单的概述来澄清事情:

pod 安装。当您运行 pod install 时,它解析尚未在 Podfile.lock 中列出的 pod 的依赖关系。对于Podfile.lock 中的 pod,它会下载那里列出的显式版本,而不检查是否有更新的版本可用——我相信这种(预期的)行为导致了你的问题。

pod 更新。如果你运行pod update,CocoaPods 会将你的Podfile 中列出的每个 pod 更新到可能的最新版本。当然,尊重您在Podfile 中声明的版本限制(如果有)。

有关更多信息,请务必同时查看pod install vs. pod update 指南。

【讨论】:

  • @Alper 仔细检查您的 Podfile 是否包含硬编码/显式 Firebase 版本(例如,pod 'Firebase', '3.0.5' 等)。
  • 我通过用全名 FirebaseFoo 替换 pod 的子规范版本 Firebase/Foo 来修复它。
【解决方案3】:

即使在运行run pod repo remove masterpod installpod update 之后,我也遇到了类似的问题并且卡在以下输出:

Using AmazonAd (2.2.15)
Using Firebase (3.17.0)
Using FirebaseAnalytics (3.9.0)
Using FirebaseCore (3.6.0)
Using FirebaseInstanceID (1.0.10)
Using Google (3.1.0)
Using Google-Mobile-Ads-SDK (7.19.1)
Using GoogleToolboxForMac (2.1.1)

我一直在 pod update 命令输出中看到注释:

[!] Google has been deprecated

所以我从 podfile 中删除了 Google:

 pod Google

然后我又跑了:

 pod update

并收到:

Using AmazonAd (2.2.15)
Installing Firebase 4.3.0 (was 3.17.0)
Installing FirebaseAnalytics 4.0.4 (was 3.9.0)
Installing FirebaseCore 4.0.8 (was 3.6.0)
Installing FirebaseInstanceID 2.0.4 (was 1.0.10)
Installing Google-Mobile-Ads-SDK 7.24.1 (was 7.19.1)
Using GoogleToolboxForMac (2.1.1)
Installing nanopb (0.3.8)

【讨论】:

  • 这是我的问题。我的 podfile 中有“GoogleAnalytics”。当我删除此 Firebase 时已正确更新。然后,我能够将“GoogleAnalytics”放回去,并且 Firebase 没有降级。你知道为什么会这样吗?
  • 为我工作。我发现一个关键点是删除收到此弃用警告的“Google”的使用。实际上,我的 podfile 中有一个旧的 pod 'Google/Analytics'。通过删除或更新到较新的“GoogleAnalytics”窗格来解决。之后,所有 Firebase pod 都更新到最新版本。
【解决方案4】:

我遇到了同样的问题,只是通过将 pod subsec 更改为 pod 的全名来解决它,如下所示:

-    pod 'Firebase/Core'
-    pod 'Firebase/RemoteConfig'
+    pod 'FirebaseCore', '4.0.9'
+    pod 'FirebaseRemoteConfig', '2.0.3'

很奇怪,这种混乱一开始就发生了,但至少这解决了它。

【讨论】:

    【解决方案5】:
    Podfile
    
    platform :ios, '10.0'
    # ignore all warnings from all pods
    inhibit_all_warnings!
    use_frameworks!
    
    def pods
      pod 'Firebase/Core'
    end
    
    Terminal
    
    pod --version
    1.3.1
    pod update
    CocoaPods 1.5.3 is available.
    To update use: `sudo gem install cocoapods`
    
    For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.3
    
    sudo gem install cocoapods
    Password:
    Fetching: cocoapods-core-1.5.3.gem (100%)
    Successfully installed cocoapods-core-1.5.3
    Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
    Successfully installed cocoapods-deintegrate-1.0.2
    Fetching: cocoapods-downloader-1.2.1.gem (100%)
    Successfully installed cocoapods-downloader-1.2.1
    Fetching: molinillo-0.6.6.gem (100%)
    Successfully installed molinillo-0.6.6
    Fetching: cocoapods-1.5.3.gem (100%)
    Successfully installed cocoapods-1.5.3
    Parsing documentation for cocoapods-core-1.5.3
    Installing ri documentation for cocoapods-core-1.5.3
    Parsing documentation for cocoapods-deintegrate-1.0.2
    Installing ri documentation for cocoapods-deintegrate-1.0.2
    Parsing documentation for cocoapods-downloader-1.2.1
    Installing ri documentation for cocoapods-downloader-1.2.1
    Parsing documentation for molinillo-0.6.6
    Installing ri documentation for molinillo-0.6.6
    Parsing documentation for cocoapods-1.5.3
    Installing ri documentation for cocoapods-1.5.3
    Done installing documentation for cocoapods-core, cocoapods-deintegrate, cocoapods-downloader, molinillo, cocoapods after 8 seconds
    5 gems installed
    
    pod install
    
    Installing Firebase (5.5.0)
    Installing FirebaseAnalytics (5.1.0)
    Installing FirebaseCore (5.1.0)
    Installing FirebaseInstanceID (3.2.0)
    Installing GoogleAppMeasurement (5.1.0)
    Installing GoogleUtilities (5.2.2)
    Installing nanopb (0.3.8)
    

    【讨论】:

      【解决方案6】:

      Ionic 和 Capacitor 也有同样的问题,来自这个指令: https://firebase.google.com/docs/dynamic-links/custom-domains

      看起来您缺少 FirebaseDynamicLinkCustomDomains,您应该将其更新到您的 ios 项目: 例如,如果您的网址是:

      encodedLink = https://yourtargetlink.com(你应该把它编码成这个https%3A%2F%2Fyourtargetlink.com

      dynamiclink = https://yourfirebasedynamiclink.com/link/?link=${encodedLink}&apn=com.example&isi=1449448875&ibi=com.example

      您应该将此密钥添加到您的 ios 项目中

      // Info.plist
      <dict>
        <key>FirebaseDynamicLinksCustomDomains</key>
        <array>
          <string>https://yourtargetlink.com</string>
          <string>https://yourfirebasedynamiclink.com/link</string>
        </array>
      </dict>
      
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多