2016-12-25 253 views
5

我開始了一個空白的Xcode項目,我所做的只是通過Cocoapods添加Firebase框架並在Appdelegate和viewcontroller中導入。當我添加FIRApp.configure()didFinishLoadingWithOptions我得到那個錯誤。如果我刪除該行,但仍然導入框架,它運行沒有錯誤。這發生在一個空白項目中,故事板中沒有任何內容,也沒有viewcontroller.swift。導致「線程1:信號SIGABRT」的Firebase

在它說控制檯的libC++ abi.dylib:與類型NSException的未捕獲的異常 (11分貝)結束

的Xcode 8.2,迅速3

import UIKit 
import Firebase 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

var window: UIWindow? 


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    // Override point for customization after application launch. 
FIRApp.configure() 

    return true 
} 

func applicationWillResignActive(_ application: UIApplication) { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
} 

func applicationDidEnterBackground(_ application: UIApplication) { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

func applicationWillEnterForeground(_ application: UIApplication) { 
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
} 

func applicationDidBecomeActive(_ application: UIApplication) { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 

func applicationWillTerminate(_ application: UIApplication) { 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 

}

Podfile

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

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

     # Pods for dur2 

pod 'Firebase/Core' 
pod 'Firebase/AdMob' 
pod 'Firebase/Messaging' 
pod 'Firebase/Database' 
pod 'Firebase/Invites' 
pod 'Firebase/DynamicLinks' 
pod 'Firebase/Crash' 
pod 'Firebase/RemoteConfig' 
pod 'Firebase/Auth' 
pod 'Firebase/Storage' 
pod 'SDWebImage' 

end

+0

你加googleplist文件? – Ro4ch

+0

您是否爲Firebase添加.plist文件? –

+0

是的,我做了@ Ro4ch – Henry

回答

2

讓我們來試一下。

按照Firebase網站上的說明創建一個新項目,確保您將GoogleService-Info.plist添加到您的項目中。

,在您創建一個POD文件的步驟中,確保你在你的項目文件夾,並用這樣的文字:

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

target 'your-project-name' do 
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 
    use_frameworks! 

    # Pods for Firesearch 
    pod ‘Firebase/Core’ 
end 

和到位的您的項目名稱

把你的項目名稱

保存文件,然後做一個

pod install 

然後打開項目name.xcworkspace並構建它。

+0

好吧,我做到了這一點,並在我的設備上運行了它,並且沒有出現錯誤,我的Firebase控制檯確認應用程序安裝。從這我只能認爲我安裝的額外豆莢導致了錯誤,有什麼想法? – Henry

+0

如何刪除我以前的項目安裝的附加窗格? – Henry

+0

@亨利嗯,你可以試試[自動化的應用](https://github.com/CocoaPods/cocoapods-deintegrate),這可能會有所幫助。除此之外,他們必須手動刪除。您也可以嘗試從您的podfile中刪除該窗格,然後再次運行窗格安裝。 – Jay

1

如果您還沒有,

轉到您的firebase項目並下載google.plist文件並將其添加到您的項目並運行。

2

就職於Xcode的9

如果沒有解決方案的工作了,你試試這個:

  1. 關閉的Xcode
  2. 在Finder:

    • 刪除.xcworkspace文件
    • 刪除Podfile。鎖定文件
    • 刪除文件夾
  3. 在終端(項目文件夾中):吊艙安裝

  4. 確保GoogleService-Info.plist中被添加到您的目標併爲您的BUNDLE_ID生成。

不知什麼原因,當您同時使用「火力地堡/ AdMob廣告」「火力地堡/芯」豆莢的Xcode可以搞砸了工作區,併產生不好的構建,如果您嘗試在運行時會崩潰調用FirebaseApp.configure()GADMobileAds.configure(withApplicationID: 「APP_ID」)