Ios 启动新屏幕时,Xcode w/Swift中的线程错误

Ios 启动新屏幕时,Xcode w/Swift中的线程错误,ios,swift,amazon-web-services,Ios,Swift,Amazon Web Services,一旦用户登录到我的应用程序,我设置窗口,设置rootViewController和makeKeyAndVisible,当我这样做时,我得到一个线程9:signal SIGABRT错误。FWIW,当设置self.window=UIWindow(frame:UIScreen.main.bounds)时,我得到一个紫色警告-[UIWindow initWithFrame:]只能从主线程使用。请参阅下面的代码以查看我的设置 代码就在这里死了,并且出现了错误-self.window!。makeKeyAnd

一旦用户登录到我的应用程序,我设置窗口,设置rootViewController和makeKeyAndVisible,当我这样做时,我得到一个
线程9:signal SIGABRT
错误。FWIW,当设置
self.window=UIWindow(frame:UIScreen.main.bounds)
时,我得到一个紫色警告
-[UIWindow initWithFrame:]只能从主线程使用。请参阅下面的代码以查看我的设置

代码就在这里死了,并且出现了错误-
self.window!。makeKeyAndVisible()
在AppController.swift中的
启动窗口(aWindow:UIWindow?
函数中

AppDelegate.swift

//
//AppDelegate.swift
导入UIKit
导入AWSCognitoAuth
导入AWSSN
导入AWSCognitoIdentityProvider
导入用户通知
导入ESTabBarController\u swift
导入AWSMobileClient
@UIApplicationMain
类AppDelegate:UIResponder、UIApplicationLegate、UNUserNotificationCenterDelegate{
变量窗口:UIWindow?
var navigationController:UINavigationController?
var故事板:UIStoryboard?
var loginViewController:loginViewController?
var pool=AWSCognitoIdentityUserPool.init(forKey:“UserPool”)
func应用程序(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplication.launchOptions键:任意]?)->Bool{
AppController.sharedInstance.enableCognitoClientWithAuthentication()
//设置日志记录
//pool.delegate=self
//AWSDDLog.sharedInstance.logLevel=.verbose
//让credentialsProvider=AWSCognitoCredentialsProvider(regionType:.USEast1,
//identityPoolId:Constants.apikees.AWSIdentityPoolID)
//
////设置服务配置
//让serviceConfiguration=AWSServiceConfiguration(区域:AWSRegionType.USEast1,credentialsProvider:credentialsProvider)
//
////创建池配置
//让poolConfiguration=AWSCognitoIdentityUserPoolConfiguration(clientId:Constants.apikees.AWSClientID,
//clientSecret:Constants.APIKeys.AWSSecret,
//poolId:Constants.apikees.AWSPoolID)
//AWSServiceManager.default().defaultServiceConfiguration=serviceConfiguration
////初始化用户池客户端
//AWSCognitoIdentityUserPool.register(使用:serviceConfiguration,userPoolConfiguration:poolConfiguration,forKey:“UserPool”)
//
//pool.currentUser()?.getSession()
//获取我们在上述步骤中初始化的用户池客户端
//let pool=AWSCognitoIdentityUserPool(forKey:“UserPool”)
让signedIn=AWSMobileClient.sharedInstance().isSignedIn
self.navigationController=UINavigationController()
如果!签名{
导航信息技术()
}
//}其他{
//AppController.sharedInstance.ShowLoggedInstance和返回(true)
//        }
//pool.delegate=self
self.window=UIWindow(框架:UIScreen.main.bounds)
AppController.sharedInstance.launchInWindow(aWindow:self.window)
返回真值
}
func应用程序(uApp:UIApplication,打开url:url,选项:[UIApplication.openUrlOptions:Any]=[:])->Bool{
导航信息技术()
返回真值
}
func NavigationIt(){
让loginViewController=loginViewController()
self.navigationController!.pushViewController(loginViewController,动画:false)
}
//标记:推送通知
func应用程序(application:UIApplication,DidRegisterForRemotionTificationswithDeviceToken deviceToken:Data){
///将设备令牌附加到用户默认值
var token=“”
对于0中的i..AnyObject?in
如果task.error!=nil{
打印(“错误:\(字符串(描述:task.Error)))
}否则{
让createEndpointResponse=task.result!作为AWSSNSCreateEndpointResponse
如果让endpointArnForSNS=createEndpointResponse.endpointArn{
打印(“endpointArn:\(endpointArnForSNS)”)
Settings.setPushArn(endpointArnForSNS)
NotificationCenter.default.post(名称:NSNotification.name(rawValue:“RegisteredForPush”),对象:nil
}
}
归零
})
}
func应用程序(application:UIApplication,DidReceiveMemoteNotification用户信息:[AnyHashable:Any],fetchCompletionHandler completionHandler:@escaping(UIBackgroundFetchResult)->Void){
让可见=窗口?.visibleViewController()
如果让data=userInfo[“aps”]作为?[AnyHashable:Any]{
如果让路由=数据[“路由”]作为字符串{
道岔进路{
案例“请求匹配”:
var projectd=“”
如果让项目=数据[“projectId”]作为字符串{
projectd=项目
}
var matchId=“”
如果让match=data[“matchId”]作为字符串{
matchId=match
}
让projectMatches=MatcheRequestedViewController(带NotificationPayload:projectId,matchId:matchId)
可见?.navigationController?.pushViewController(项目匹配,动画:true)
案例“项目详情”:
var projectd=“”
如果让项目=数据[“projectId”]作为字符串{
projectd=项目
}
让projectMatches=ProjectDetailsViewController(使用project:TERMyProject(),或projectd:projectd)
可见?.navigationController?.pushViewController(项目匹配,动画:true)
案例“匹配”:
var projectd=“”
如果
    func launchInWindow(aWindow: UIWindow?){

        self.window = aWindow

        self.initializeSDKs()
        self.globalCustomization()

        self.AWSUnAuthedClient.apiKey = Constants.APIKeys.AWSAPIKey


        self.window!.rootViewController = self.showLoggedInStateAndReturn(true)
        self.window!.makeKeyAndVisible()

    }

    func initializeSDKs() {

        // Google places
        GMSPlacesClient.provideAPIKey(Constants.APIKeys.GooglePlaces)
    }

    func globalCustomization() {
        self.styleNavigationBar()
    }

    @discardableResult func showLoggedInStateAndReturn(_ shouldReturn: Bool) -> UIViewController? {

        //AppController.sharedInstance.enableCognitoClientWithAuthentication()
        //self.registerForPush()

        self.tabBarController = ESTabBarController()
        //tabBarController.delegate = delegate
        self.tabBarController?.title = "Irregularity"
        self.tabBarController?.tabBar.shadowImage = UIImage.image(with: UIColor("FFFFFF", alpha: 0.0)!)
        self.tabBarController?.tabBar.backgroundImage = UIImage.image(with: UIColor("2A2A27")!)
        self.tabBarController?.shouldHijackHandler = {
            tabbarController, viewController, index in
            if index == 1 {
                return true
            }
            return false
        }

            self.tabBarController?.didHijackHandler = {
            [weak tabBarController] tabbarController, viewController, index in

            DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
                let newProjectNavCon = UINavigationController(rootViewController: NewProjectViewController())
                newProjectNavCon.hero.isEnabled = true
                newProjectNavCon.setNavigationBarHidden(true, animated: false)
                newProjectNavCon.hero.navigationAnimationType = .fade
                tabBarController?.present(newProjectNavCon, animated: true, completion: nil)
            }
        }

        let centerVC = UINavigationController(rootViewController: HomeViewController())

        let v1 = centerVC
        let v2 = BaseViewController()
        let v3 = UINavigationController(rootViewController: ProfileViewController())

        v1.tabBarItem = ESTabBarItem.init(TabBarBouncesContentView(), title: "Projects", image: UIImage(named: "tabBar"), selectedImage: UIImage(named: "tabBar"))
        v2.tabBarItem = ESTabBarItem.init(TabBarIrregularityContentView(), title: nil, image: UIImage(named: "tabBarPlusButton"), selectedImage: UIImage(named: "tabBarPlusButton"))
        v3.tabBarItem = ESTabBarItem.init(TabBarBouncesContentView(), title: "Profile", image: UIImage(named: "tabBarProfile"), selectedImage: UIImage(named: "tabBarProfile"))

        self.tabBarController?.setViewControllers([v1, v2, v3], animated: true)

        if shouldReturn {
            return self.tabBarController
        } else {
            self.window?.rootViewController = self.tabBarController
            return nil
        }

    }
func launchInWindow(aWindow: UIWindow?){
    self.window = aWindow
    self.initializeSDKs()
    self.globalCustomization()
    self.AWSUnAuthedClient.apiKey = Constants.APIKeys.AWSAPIKey

    DispatchQueue.main.async {
        self.window!.rootViewController = self.showLoggedInStateAndReturn(true)
        self.window!.makeKeyAndVisible()
    }
}
self.window = UIWindow(frame: UIScreen.main.bounds) //-- Purple warning here
AppController.sharedInstance.launchInWindow(aWindow: self.window)

return true