前提・実現したいこと
GoogleAdMobを利用し、作ったアプリ内にバナー広告をつけて実行しようとしたところ、表題のエラーが出てしまいました。助けてください。。
発生している問題・エラーメッセージ
Thread 1: signal SIGABRT
該当のソースコード
Swift
1//Appdelegate.swiftのコード 2import UIKit 3import GoogleMobileAds 4 5@UIApplicationMain 6class AppDelegate: UIResponder, UIApplicationDelegate, GADBannerViewDelegate { 7 8 var window: UIWindow? 9 10 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 11 12 GADMobileAds.sharedInstance().start() 13 14 return true 15 } 16 17 func applicationWillResignActive(_ application: UIApplication) { 18 } 19 func applicationDidEnterBackground(_ application: UIApplication) { 20 } 21 func applicationWillEnterForeground(_ application: UIApplication) { 22 } 23 func applicationDidBecomeActive(_ application: UIApplication) { 24 } 25 func applicationWillTerminate(_ application: UIApplication) { 26 } 27} 28 29//ViewController.swiftのコード 30import UIKit 31import GoogleMobileAds 32 33class ViewController: UIViewController,UITextFieldDelegate,GADBannerViewDelegate { 34 35 let TestID = "ca-app-pub-3940256099942544/2934735716" 36 let DEVICE_ID = "" 37 let simulatorTest = true 38 39 @IBOutlet var meisi: UITextField! 40 41 @IBOutlet weak var meisi1: UITextField! 42 43 @IBOutlet var keiyousi1: UITextField! 44 45 override func viewDidLoad() { 46 super.viewDidLoad() 47 48 meisi.delegate = self 49 meisi1.delegate = self 50 keiyousi1.delegate = self 51 52 var admobView = GADBannerView() 53 admobView = GADBannerView(adSize: kGADAdSizeBanner) 54 admobView.frame.origin = CGPoint(x: 0, y: self.view.frame.size.height - admobView.frame.height) 55 56 admobView.frame.size = CGSize(width: self.view.frame.width, height: admobView.frame.height) 57 58 admobView.adUnitID = TestID 59 admobView.delegate = self 60 admobView.rootViewController = self 61 62 let admobRequest = GADRequest() 63 if simulatorTest == true{ 64 admobRequest.testDevices = [kGADSimulatorID] 65 66 }else{ 67 68 admobRequest.testDevices = [DEVICE_ID] 69 70 } 71 admobView.load(admobRequest) 72 self.view.addSubview(admobView) 73 } 74 func textFieldShouldReturn(_ textField: UITextField) -> Bool { 75 76 textField.resignFirstResponder() 77 return true 78 79 } 80 81 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 82 83 meisi.resignFirstResponder() 84 meisi1.resignFirstResponder() 85 keiyousi1.resignFirstResponder() 86 87 } 88 89 @IBAction func button(_ sender: Any) { 90 let items = ["いっぱい入れてるため省略"] 91 let r = Int(arc4random()) % items.count 92 meisi.text = items[r] 93 94 } 95 96 @IBAction func button1(_ sender: Any) { 97 let items = ["いっぱい入れてるため省略"] 98 let r = Int(arc4random()) % items.count 99 meisi1.text = items[r] 100 101 } 102 103 @IBAction func button2(_ sender: Any) { 104 let items = ["いっぱい入れてるため省略"] 105 let k = Int(arc4random()) % items.count 106 keiyousi1.text = items[k] 107 108 } 109 110 override func didReceiveMemoryWarning(){ 111 super.didReceiveMemoryWarning() 112 113 } 114} 115
試したこと
・コネクトが外れてないか確認→外れてない
・Moduleとclassの確認→付いている
・AppDelegate.swiftのInfo.plistにはGADApplicationIdentifierキーを追加し、そこにAdMobAppIDを入れた。
補足情報(FW/ツールのバージョンなど)
Xcode : Version 10.3 (10G8)
Swift : Apple Swift version 5.0.1
デバッグエリアのログ↓
2019-08-17 01:31:56.113151+0900 idea[62244:3150194] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.core2019-08-17 01:31:56.801042+0900 idea[62244:3148999] *** Terminating app due to uncaught exception 'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized without AppMeasurement. Google AdMob publishers, follow instructions here: https://googlemobileadssdk.page.link/admob-ios-update-plist to include the AppMeasurement framework and set the -ObjC linker flag. Google Ad Manager publishers, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist'

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/17 01:56