参考元URL
iPhoneアプリにバナー広告を貼れるようにしたいと思っています。
↑の参考ページの手順通りにしているのですが
AppDelegate.swiftの41行目で下記のようなエラーが発生します。
自分なりに調べてみたのですが知識不足で原因がイマイチ分からずこちらに質問させて頂きました。
どうかよろしくお願い致しますm(_ _)m
Xcode11.3 swift -version5.1.3
エラーコード
Swift
1'=' must have consistent whitespace on both sides 2Insert ' ' 3'lazy' must not be used on an already-lazy global 4Replace 'lazy ' with '' 5Use of undeclared type 'NSPersistentContainer'
AppDelegate.swift
Swift
1import UIKit 2import Firebase // ★←追記 3 4@UIApplicationMain 5class AppDelegate: UIResponder, UIApplicationDelegate { 6 7 var window: UIWindow? 8 9 10 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 11 // Override point for customization after application launch. 12 13 // Use Firebase library to configure APIs ★←追記 14 FirebaseApp.configure() // ★←追記 15 16 // Initialize Google Mobile Ads SDK, application IDを設定 ★←追記 17 GADMobileAds.configure(withApplicationID:"") 18 19 return true 20 } 21 22 23 } 24 25 // MARK: UISceneSession Lifecycle 26 27 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 28 // Called when a new scene session is being created. 29 // Use this method to select a configuration to create the new scene with. 30 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 31 } 32 33 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 34 // Called when the user discards a scene session. 35 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 36 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 37 } 38 39 // MARK: - Core Data stack 40 41lazy var persistentContainer: NSPersistentContainer ={ 42 43 let container = NSPersistentContainer(name: "TTTEST") 44 container.loadPersistentStores(completionHandler: { (storeDescription, error) in 45 if let error = error as NSError? { 46 // Replace this implementation with code to handle the error appropriately. 47 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 48 49 /* 50 Typical reasons for an error here include: 51 * The parent directory does not exist, cannot be created, or disallows writing. 52 * The persistent store is not accessible, due to permissions or data protection when the device is locked. 53 * The device is out of space. 54 * The store could not be migrated to the current model version. 55 Check the error message to determine what the actual problem was. 56 */ 57 fatalError("Unresolved error (error), (error.userInfo)") 58 } 59 }) 60 return container 61 }() 62 63 // MARK: - Core Data Saving support 64 65 func saveContext () { 66 let context = persistentContainer.viewContext 67 if context.hasChanges { 68 do { 69 try context.save() 70 } catch { 71 // Replace this implementation with code to handle the error appropriately. 72 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 73 let nserror = error as NSError 74 fatalError("Unresolved error (nserror), (nserror.userInfo)") 75 } 76 } 77 } 78 79
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/17 13:42