【问题标题】:cocoapods pod file dependency issue with Firebase, specifically FirebaseUIFirebase 的 cocoapods pod 文件依赖问题,特别是 FirebaseUI
【发布时间】:2017-09-03 19:32:40
【问题描述】:

我正在尝试使用 Firebase Storage 记录的示例代码:

// Reference to an image file in Firebase Storage
let reference = storageRef.child("images/stars.jpg")

// UIImageView in your ViewController
let imageView: UIImageView = self.imageView

// Placeholder image
let placeholderImage = UIImage(named: "placeholder.jpg")

// Load the image using SDWebImage
imageView.sd_setImage(with: reference, placeholderImage: placeholderImage)

在我的应用中像这样适应:

  func setImage(_ picid: Int32){

        let imagesRefs = Constants.FirebaseConfig.storageRef.child("images/thumbs/\(getuid())/thumb_\(picid).jpg");
        let placeholderImage = UIImage(named: "placeholder.jpg")

        profilePicIV.sd_setImage(with: imagesRefs, placeholderImage: placeholderImage)
}

但是 xcode 没有找到 sd_setImage 方法,所以我想我必须使用 pod 'FirebaseUI/Storage' 更新我的 podfile,但是在修改了我的 podfile 之后,我收到了这个错误:

pod update
Update all pods
Updating local specs repositories
  $ /usr/bin/git -C /Users/myname/.cocoapods/repos/master fetch origin --progress
  remote: Counting objects: 18, done.        
  remote: Compressing objects: 100% (14/14), done.        
  remote: Total 18 (delta 12), reused 7 (delta 4), pack-reused 0        
  From https://github.com/CocoaPods/Specs
     24df16553de..7cae8225fce  master     -> origin/master
  $ /usr/bin/git -C /Users/myname/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/myname/.cocoapods/repos/master reset --hard origin/master
  HEAD is now at 7cae8225fce [Add] MixedRealityKit 0.1.6
Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `TwitterCore (~> 2.8.0)` required by `Podfile`
- `TwitterCore (>= 3.0.0)` required by `TwitterKit (3.0.0)`
- `FirebaseUI` required by `Podfile`

Specs satisfying the `FirebaseUI` dependency were found, but they required a higher minimum deployment target.

我的 pods 文件是这样的,尽管我尝试了其他 pod 组合但效果相同或更差:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.3'

# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
  target 'StrengthStandards' do
    #Pods for StrengthStandards
    pod 'Firebase'
    pod 'Firebase/Core'
    #pod 'Firebase/Auth'
    #pod 'FirebaseUI/Google'
    #pod 'Firebase/Crash'
    #pod 'Firebase/RemoteConfig'
    pod 'FirebaseUI'
    pod 'Firebase/Database'
    #pod 'FirebaseUI/Database'
    #pod 'Firebase/Storage'
    pod 'FirebaseUI/Storage'
    pod 'TwitterCore', '~>2.8.0'

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

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

end

我做错了什么?我的 xcode 在我的import FirebaseAuthUI 行上也给出了错误No such module 'FirebaseAuthUI'

在这个问题之前,我的 Firebase 数据库和 Firebase Auth 工作正常。

我在 MacOS 10.12.6 上使用 Xcode 8.3.3 和 Swift 3

谢谢

PS:取得一些进展 - 现在我的 podfile 是:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.3'

# Comment the next line if you're not using Swift and don't want to use dynamic frameworks

  target 'StrengthStandards' do
    use_frameworks!
    #Pods for StrengthStandards
    #pod 'Firebase'
    pod 'Firebase/Core'
    #pod 'Firebase/Auth'
    pod 'FirebaseUI/Auth'

    pod 'FirebaseUI/Google'
      #pod 'FirebaseUI/Google'
    #pod 'Firebase/Crash'
    #pod 'Firebase/RemoteConfig'
    #pod 'FirebaseUI'
      pod 'Firebase/Database'
      #pod 'FirebaseUI/Database'
    #pod 'Firebase/Storage'
    pod 'FirebaseUI/Storage'
    pod 'TwitterCore', '~>2.8.0'
  target 'StrengthStandardsTests' do
    inherit! :search_paths
    # Pods for testing
  end

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

end

但是我不再遇到依赖问题,xcode 现在告诉我方法调用

  profilePicIV.sd_setImage(with: imagesRefs, placeholderImage: placeholderImage)

错了:

/Users/myname/Dev/IOSDev/StrengthStandards/StrengthStandards/Settings.swift:325:40: Cannot convert value of type 'StorageReference' to expected argument type 'URL?'

【问题讨论】:

    标签: cocoapods firebase-storage firebaseui


    【解决方案1】:

    现在似乎可以工作了,尽管我承认我不确定这是否正是它应该完成的方式。对于任何对此感兴趣的人,我目前所拥有的就是: 播客文件:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '10.3'
    
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
    
      target 'StrengthStandards' do
        use_frameworks!
        pod 'Firebase/Core'
        pod 'FirebaseUI/Auth'
        pod 'FirebaseUI/Google'
        pod 'Firebase/Database'
        pod 'FirebaseUI/Storage'
        pod 'TwitterCore', '~>2.8.0'
        pod 'SDWebImage/Core'
      target 'StrengthStandardsTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      target 'StrengthStandardsUITests' do
        inherit! :search_paths
        # Pods for testing
      end
    
    end
    

    这是我的功能:

    import SDWebImage
    func setImage(_ picid: Int32){
    
            let imagesRefs = Constants.FirebaseConfig.storageRef.child("images/thumbs/\(Constants.getUID())/thumb_\(picid).jpg");
    
            imagesRefs.downloadURL { url, error in
                if let error = error {
                    // Handle any errors
                    print("Error getting url for profile pic: \(error)")
                } else {
                    // Get the download URL for 'images/stars.jpg'
                    let placeholderImage = UIImage(named: "placeholder.jpg")
                    self.profilePicIV.sd_setImage(with: url, placeholderImage: placeholderImage)
                }
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 2019-07-14
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多