仅在归档时才会出现iOS swift编译错误

时间:2016-09-21 15:56:37

标签: xcode smooch swift2.3

我得到以下错误

  

AppDelegate.swift:152:30:'(appToken:String!) - > SKTSettings'不是   可转换为'(appToken:String!) - > SKTSettings'!

     

AppDelegate.swift:167:23:'(writeKey:String!) - >   SEGAnalyticsConfiguration'不能转换为'(writeKey:String!) - > SEGAnalyticsConfiguration'!

违规行

  

让smoochSettings = SKTSettings(appToken:" xxxxx")   let config = SEGAnalyticsConfiguration(writeKey:" xxxx")

任何线索,我都不明白......

有关代码的更多上下文

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    setupToast()

    //setup rollbar
    let rollbarConfig: RollbarConfiguration = RollbarConfiguration()

    #if RELEASE
        rollbarConfig.environment = "production"
    #elseif ADHOC
        rollbarConfig.environment = "adhoc"
    #else
        rollbarConfig.environment = "development"
    #endif

    Rollbar.initWithAccessToken("xxx", configuration: rollbarConfig, enableCrashReporter: false)

    AFNetworkReachabilityManager.sharedManager().startMonitoring()
    AFNetworkReachabilityManager.sharedManager().setReachabilityStatusChangeBlock { status in
        switch status {
        case .NotReachable:
            self.SHOW_ERROR("La connexion internet semble interrompue", completion: nil)
            break
        default:
            CRToastManager.dismissAllNotifications(true)
            break
        }
    }

    ParseManager.initParse()
    LBStripeManager.initStripe()
    loadAppearances()
    //FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
    FBSDKProfile.enableUpdatesOnAccessTokenChange(true)

    GMSServices.provideAPIKey("xxx")
    GMSPlacesClient.provideAPIKey("xxx")
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AppDelegate.loadAppearances), name: "switchUserType", object: nil)
    let branch = Branch.getInstance()
    branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler: { params, error in

        if params["fromUserId"] != nil {
            let senderId = params["fromUserId"]!
            SEGAnalytics.sharedAnalytics().track("Refferal", properties: ["branchFromUser": senderId])
        }

        if params["adId"] != nil {
            let adId = params["adId"] as! String
            NSNotificationCenter.defaultCenter().postNotificationName("adCreated", object: nil)
            AdManager.sharedInstance.showAdToBabysitterFromRemoteNotification(adId, presentingController: self.window!.rootViewController!)
        }

        if (error == nil) {
            DeepLinkManager.handleDeepLinkWithParams(params)
            DeepLinkManager.sharedInstance.alreadyGotANetworkError = false
        } else if !DeepLinkManager.sharedInstance.alreadyGotANetworkError && DeepLinkManager.sharedInstance.isLoadingDataFromBranchServer {
            DeepLinkManager.sharedInstance.alreadyGotANetworkError = true
            UIWindow.topViewController().hideHUD(false)
            var errorMessage = PFConfig.stringForKey("inviteNoInternetAlertMessage")
            if errorMessage.isEmpty {
                errorMessage = "Vous n'êtes actuellement pas connecté à Internet. Le parrainage reprendra automatiquement dès qu'Internet sera disponible."
            }
            UIWindow.topViewController().showAlert(message: errorMessage)
        }
    })

    initSiren()

    // fabric
    Crashlytics().debugMode = false
    Fabric.with([Crashlytics.self])
    logUserInFabric()

    // smooch
    let smoochSettings = SKTSettings(appToken: "xxxxx")

    smoochSettings.userId = PFUser.currentUser()?.objectId
    Smooch.initWithSettings(smoochSettings)

    // intercom
    Intercom.setApiKey("xxx", forAppId: "xxxx")
    AppDelegate.phoneForCurrentUser()

    if needToSendSmoochLastOpenTag() {
        SKTUser.currentUser().addProperties(["DELTA_USAGE": "true"])
    }

    NSUserDefaults.standardUserDefaults().setObject(NSDate().timeIntervalSince1970, forKey: "LastOpen")


    var config = SEGAnalyticsConfiguration(writeKey: "xxx")
    #if RELEASE
    config.flushAt = 15
    #else
    config.flushAt = 1
    #endif
    SEGAnalytics.setupWithConfiguration(config)

    return true
}

1 个答案:

答案 0 :(得分:2)

更新将SDK更新到版本5.0.1将解决此问题

正如所讨论的here,在更新到XCode 8之后,Swift编译器无法正确确定这些值是否是可选的。将可空性说明符添加到Smooch头文件应该可以解决问题。具有可空性说明符的构建正在开发中,应尽快发布。