podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Tx' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Tx
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod ‘Firebase/Database’
pod 'Firebase/Storage'
pod 'Firestore', :podspec => 'https://storage.googleapis.com/firebase-preview-drop/ios/firestore/0.7.0/Firestore.podspec.json'
end
的AppDelegate:
import UIKit
import Firebase
import Firestore
import FirebaseAuth
import FirebaseDatabase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
Auth.auth().signIn(withEmail: "1tester1@gmail.com", password: "1tester1")
{ (user, error) in
if let error = error
{
print ("Login failed \(error.localizedDescription)")
}else{
print ("Successful login")
}
}
return true
}
查看控制器:
import UIKit
import Firebase
import Firestore
import FirebaseDatabase
import FirebaseStorage
class ViewController: UIViewController {
@IBOutlet weak var ptImage: UIImageView!
var db : Firestore! //Firestore
let storage = Storage.storage()
var dbRef : DatabaseReference! //FireBase
override func viewDidLoad() {
super.viewDidLoad()
fetchPtPic()
}//---------------
func fetchPtPic()
{
let TxPtID = "JJ"
db = Firestore.firestore()
dbRef = Database.database().reference()
let storageRef = storage.reference()
let ptImagesRef = storageRef.child("PtImages/\(TxPtID).jpg")
}
在执行任何操作之前,它使用SIGABRT构建和崩溃。 如果我注释掉这些内容:
//let storage = Storage.storage()
//var dbRef : DatabaseReference! //FireBase
和这些:
//dbRef = Database.database().reference() //points to the whole /
//let storageRef = storage.reference()
//let ptImagesRef = storageRef.child("PtImages/\(TxPtID).jpg")
...然后它编译并执行干净。
连连呢?我已经尝试了很多事情和其他建议2周,我很难过。
答案 0 :(得分:0)
确保Firebase存储规则允许您进行读写。
或
这是根Firebase存储参考:
let storageRef = FIRStorage.storage().reference()
尝试以上一行。