developermike developermike - 1 month ago 20
iOS Question

Adding AdMob from Firebase with Segmentation fault:11 error

There is a question about

Command failed due to signal: Segmentation fault: 11
, but no answer applies to my situation.

I am using Swift3, Xcode 8.0 to add AdMob with Firebase and got this error:

Error:

1. While loading members for 'CategoryVC' at <invalid loc>
2. While deserializing decl #92 (PATTERN_BINDING_DECL)
3. While deserializing decl #3 (VAR_DECL)

Command failed due to signal: Segmentation fault: 11


Code:

import UIKit
import Firebase
import GoogleMobileAds

class ViewController: UIViewController {

@IBOutlet weak var bannerView: GADBannerView!

override func viewDidLoad() {
super.viewDidLoad()

bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
bannerView.rootViewController = self
bannerView.load(GADRequest())
}

}



import UIKit
import Firebase
import GoogleMobileAds

class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

FIRApp.configure()

GADMobileAds.configure(withApplicationID: "ca-app-pub-xxxxxxxxxx")

return true

}
}

Answer

I finally figured out! All problems happened after installing Firebase/Admoband adding bannerViewcode. The CategoryVCmentioned in #1 is the only ViewControllerI added bannerView. Because when I installed pod fileusing terminalit mentioned my Cocoapodsis not up to date. So I updated Cocoapodsto see any good luck. Steps:

 1. open your terminal. input: 

    'sudo gem install cocoapods'

 2. navigate to your project folder and open your pod file. Make changed if 
    necessary, or just save and exit.

 3. run:
    'pod update'

It may not apply to your situation. Good luck!