我一直在收到构建时错误,导致我无法在Xcode中运行我的应用。我收到错误 - 模块' FirebaseDatabase'没有名为' database'的成员。而且我也得到了相同的错误几行,但存储。错误 - 模块' FirebaseStorage'没有名为' storage'
的成员 //Error Below - Module 'FirebaseDatabase' has no member named 'database'
let location = FirebaseDatabase.database().reference().child("users").child(userUid)
location.setValue(userData)
dismiss(animated: true, completion: nil)
}
func uploadImg() {
if usernameField.text == nil {
signUpBtn.isEnabled = false
} else {
username = usernameField.text
signUpBtn.isEnabled = true
}
guard let img = userImagePicker.image, imageSelected == true else {
print("image needs to be selected")
return
}
if let imgData = UIImageJPEGRepresentation(img, 0.2) {
let imgUid = NSUUID().uuidString
let metadata = StorageMetadata()
metadata.contentType = "image/jpeg"
//Error Below - Module 'FirebaseStorage' has no member named 'storage'
FirebaseStorage.storage().reference().child(imgUid).putData(imgData, metadata: metadata) { (metadata, error) in
if error != nil {
print ("did not upload image")
} else {
print("uploaded")
let downlloadURL = metadata?.downloadURL()?.absoluteString
if let url = downloadURL {
self.setUser(img: url)
}
}
}
}
}
答案 0 :(得分:0)
FirebaseStorage.storage()
应该是
Storage.storage()
同样适用于FirebaseDatabase(数据库)。