1

我收到以下错误

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

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

违规行

让 smoochSettings = SKTSettings(appToken: "xxxxx") 让配置 = 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
}
4

1 回答 1

2

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

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

于 2016-09-21T18:45:00.927 回答