升级Firebase打破了我的iOS项目 [英] Upgrading Firebase broke my iOS project

查看:179
本文介绍了升级Firebase打破了我的iOS项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我从来没有更新我的pod,整个项目充满了错误,一个具体的错误是在下面的照片,我无法修复它,我准备提交我的应用程序到App Store现在看来就像一切都毁了。最重要的是,这让我抹去了一堆可选项。




  func uploadData(user:User){
let changeRequest = user.createProfileChangeRequest( )
changeRequest.displayName = self.nameUser.text!
changeRequest.commitChanges(completion:nil)

let imageRef = self.userStorage.child(\(user.uid).jpg)

let data = UIImageJPEGRepresentation(self.imageView.image !, 0.5)

let uploadTask = imageRef.put(data !, metadata:nil,completion:{(metadata,err)in
if err != nil {
print(err!.localizedDescription)
}

imageRef.downloadURL(完成:{(url,er)in
if er!= nil {
print(er!.localizedDescription)
}


如果让url = url {



让userInfo:[String:Any] = [age:self.ageUser.text!,
location:self.location.text!,
name:self.nameUser.text !,
image:url.absoluteString,
bio:self.bioViewTwo.text !,
contact:self.contactUser.text!

$ b $ self.ref.child(SJ)。child(user.uid).setValue(userInfo)

}



$)
$ b $ uploadTask.resume()
}


解决方案

看起来您刚刚升级到Firebase版本4;)这个新版本包含许多重大更改(一些很好的东西)for Swift
基于项目。



您应该按照他们的迁移指南来解决您的问题。例如,在 StorageReference 类中突出显示的错误可以很容易地通过将冒犯的 put 方法重命名为 putData 等等。顺便说一下, Objective-C SDK没有改变命名。


I wish I had never updated my pod, the entire project was full of errors, one specific error is in the photo below, I can't fix it and I was ready to submit my app to the App Store now it seems like its all ruined. On top of this, it made me erase a bunch of optionals.

 func uploadData(user: User) {
    let changeRequest = user.createProfileChangeRequest()
    changeRequest.displayName = self.nameUser.text!
    changeRequest.commitChanges(completion: nil)

    let imageRef = self.userStorage.child("\(user.uid).jpg")

    let data = UIImageJPEGRepresentation(self.imageView.image!, 0.5)

    let uploadTask = imageRef.put(data!, metadata: nil, completion: { (metadata, err) in
        if err != nil {
            print(err!.localizedDescription)
        }

        imageRef.downloadURL(completion: { (url, er) in
            if er != nil {
                print(er!.localizedDescription)
            }


            if let url = url {



                let userInfo: [String : Any] =  ["age" : self.ageUser.text!,
                                                 "location" : self.location.text!,
                                                 "name" : self.nameUser.text!,
                                                 "image" : url.absoluteString,
                                                 "bio" : self.bioViewTwo.text!,
                                                 "contact" : self.contactUser.text!
                ]

                self.ref.child("SJ").child(user.uid).setValue(userInfo)

            }

        })

    })

    uploadTask.resume()
}

解决方案

Looks like you just upgraded to Firebase version 4 ;) This new version contains many breaking changes (and some good stuff too!) for Swift based projects.

You should follow their migration guide to fix your issues. For instance, the error you highlighted, on the StorageReference class, can easily be fixed by renaming the offending put method to putData, and so on.

By the way, no naming changes have been made to the Objective-C SDK.

这篇关于升级Firebase打破了我的iOS项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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