Thread 1: "-[UITableViewController loadView] loaded the \"Bf3-ih-lsC-view-YnG-aC-da7\" nib but didn't get a UITableView." - swift5

import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Model.shared.loadXMLFile(date: nil)
Model.shared.parseXML()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
}

When you create a UITableViewController in your storyboard, its main view must be a UITableView. This error often happens when some other controller type is changed to a UITableViewController but with its old main view still in place.

Related

Identify application restart by camera and audio permission change swift

I have a video calling application now issue is that if the user declines the permission and once the user grants the camera access permission then the iOS application restarts then how I can know the application restart due to permission change?
Is there any method called from appdelegate before restart or after restart?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return orientationLock
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
}
func applicationDidEnterBackground(_ application: UIApplication) {
}
func applicationDidBecomeActive(_ application: UIApplication) {
}
func applicationWillTerminate(_ application: UIApplication) {
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
}

GIDSignIn.sharedInstance : sharedInstance not a function?

In this code, when I type GIDSignIn.sharedInstance, for some reason sharedInstance is not a function, which means I can't acces clientID. I cannot find a solution for this anywhere.
import UIKit
import GoogleSignIn
#main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "clientID"
return true
}
In latest version of GoogleSignIn SDK. Removed this method.
Now in new follow this link or below code.
https://developers.google.com/identity/sign-in/ios/sign-in
#IBAction func clkLoginWithGmail(_ sender: UIButton) {
let signInConfig = GIDConfiguration.init(clientID: "clientID-XYZ")
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
}
}

New delegates for carPlay

I am devleoping navigation app for CarPlay and in iOS 12 there were two methods from CPApplicationDelegate to detect if CarPlay is on:
func application(_ application: UIApplication, didConnectCarInterfaceController interfaceController: CPInterfaceController, to window: CPWindow)
and
func application(_ application: UIApplication, didDisconnectCarInterfaceController interfaceController: CPInterfaceController, from window: CPWindow)
In iOS 13 these methods are deprecated and Apple gave new delegate: CPTemplateApplicationSceneDelegate
I have tried to connect this new delegate CPTemplateApplicationSceneDelegate to my service that provides all actions for CarPlay but only function I see that can help me is:
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration
So my question is how to detect if CarPlay is connected and how to provide action for CarPlay launched in one window of new iOS 13 CarPlay.
---------------------------EDIT------------------------
In general target's settings check "Supports multiple windows". Then in Info.plist add configuration to your carPlay scene role (CPTemplateApplicationSceneSessionRoleApplication), like this:
And voilĂ !
Your delegate will invoke at
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow)
where you can configure your CarPlay controller.
---------------------------END ------------------------
I will try something like this:
func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
if connectingSceneSession.role == UISceneSession.Role.carTemplateApplication {
if let carPlayScene = connectingSceneSession.scene as? CPTemplateApplicationScene {
carPlayScene.delegate = self
}
}
and then in your delegate's method you should setup your interface like in iOS12
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow)
Don't know if it works, because my CarPlay simulator crashes...

Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]

How do I rewrite the code snippet according to this;
Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UIApplication.shared.statusBarStyle = .lightContent
return true
}
This is the new method for status bar styles
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

Facebook login + Firebase + Xcode 8 & Swift 3. ERROR

Xcode keeps complaining about an ambigous reference I've made in the AppDelegate. I'm trying to integrate Facebook Login with Firebase in my Xcode project using this tutorial.
Error:
Ambiguous reference to member
'application(_:didFinishLaunchingWithOptions:)'
Code:
import UIKit
import CoreData
import Firebase
import FBSDKLoginKit
#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()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
private func application(_ app: UIApplication, open url: URL, options: UIApplicationOpenURLOptionsKey) -> Bool {
var handled = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey], annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) // Error happens here
// Add any custom logic here.
return handled
}
I'm not sure what what this error means (still new to iOS programming). I've highlighted where it happens in the code with a comment.
import UIKit
import Firebase
import CoreData
import FBSDKCoreKit
import FBSDKLoginKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, _: NSURL, sourceApplication: String, annotation: AnyObject) -> Bool {
let handled: Bool = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
return handled
}