Ios 使用Swift解析/FaceBookSDK崩溃
我非常需要帮助 我已经在这里用swift编程一段时间了,但我似乎找不到以前有过这个问题的人 让我描述一下问题: 每当我尝试运行我的应用程序时,它都会在AppDelegate中崩溃,就在第一行有一个“SIGABRT”。委员会说“类PFUser必须在使用Parse之前向registerSubclass注册”,这让我完全不知所措,因为我没有对任何远程涉及PFUser的类进行子类化 我认为这与我一直试图集成的FacebookSDK(4.5秒,7月2日的最新版本)有关,但即使我将其从项目中删除,它仍然是坏的。也可能与我刚刚将Parse更新为1.7.5有关,但我真的不知道了 这是我试过的Ios 使用Swift解析/FaceBookSDK崩溃,ios,swift,parse-platform,facebook-sdk-4.0,Ios,Swift,Parse Platform,Facebook Sdk 4.0,我非常需要帮助 我已经在这里用swift编程一段时间了,但我似乎找不到以前有过这个问题的人 让我描述一下问题: 每当我尝试运行我的应用程序时,它都会在AppDelegate中崩溃,就在第一行有一个“SIGABRT”。委员会说“类PFUser必须在使用Parse之前向registerSubclass注册”,这让我完全不知所措,因为我没有对任何远程涉及PFUser的类进行子类化 我认为这与我一直试图集成的FacebookSDK(4.5秒,7月2日的最新版本)有关,但即使我将其从项目中删除,它仍然是坏
import UIKit
import iAd
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var UIiAd: ADBannerView = ADBannerView()
func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]!) -> Bool {
Parse.setApplicationId("2NFm7aqXQIdO0JCaxH8bwveJhRhV5iEGQWDVpDgO", clientKey: "jIhPRyAXdUVnKuFh7ka7OAQjp2pcVi0LB2WWNXcg")
PFAnalytics.trackAppOpenedWithLaunchOptionsInBackground(launchOptions, block: nil)
GMSServices.provideAPIKey("AIzaSyAM5ff80Oc-1n9UJV1wZjX6ElFP-6PD2eI")
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
FBSDKLoginManager.renewSystemCredentials { (result:ACAccountCredentialRenewResult, error:NSError!) -> Void in }
PFPurchase.addObserverForProduct("kinkstrtext.addevent") {
(transaction: SKPaymentTransaction?) -> Void in
println("purchased");
}
let notificationTypes:UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
if application.respondsToSelector("isRegisteredForRemoteNotifications")
{
// iOS 8 Notifications
let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories:nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
}
else
{
// iOS < 8 Notifications
application.registerForRemoteNotificationTypes(.Badge | .Sound | .Alert)
}
var navigationBarAppearace = UINavigationBar.appearance()
var btnColor:UIColor
btnColor = UIColor(red: 0.99, green: 0.99, blue: 1, alpha: 1)
var barColor:UIColor
barColor = UIColor(red: 0.706, green: 0.506, blue: 0.678, alpha: 1.0)
var titleColor:UIColor
titleColor = UIColor(red: 0.99, green: 0.99, blue: 1, alpha: 1)
UIApplication.sharedApplication().statusBarStyle = .LightContent
navigationBarAppearace.tintColor = btnColor // Back buttons and such
navigationBarAppearace.barTintColor = barColor // Bar's background color
navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:titleColor] // Title's text color
return true
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
UIApplication.sharedApplication().registerForRemoteNotifications()
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let currentInstallation:PFInstallation = PFInstallation.currentInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.saveInBackground()
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
println(error.localizedDescription)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
NSNotificationCenter.defaultCenter().postNotificationName("getMessage", object: nil)
}
func applicationWillResignActive(application: UIApplication) {
}
func applicationDidEnterBackground(application: UIApplication) {
}
func applicationWillEnterForeground(application: UIApplication) {
}
func applicationDidBecomeActive(application: UIApplication) {
FBSDKAppEvents.activateApp()
}
func applicationWillTerminate(application: UIApplication) {
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
导入UIKit
导入iAd
@UIApplicationMain
类AppDelegate:UIResponder、UIApplicationLegate{
变量窗口:UIWindow?
var UIiAd:ADBannerView=ADBannerView()
func应用程序(应用程序:UIApplication,didFinishLaunchingWithOptions启动选项:[NSObject:AnyObject]!)->Bool{
Parse.setApplicationId(“2NFm7aqXQIdO0JCaxH8bwveJhRhV5iEGQWDVpDgO”,客户端键:“jIhPRyAXdUVnKuFh7ka7OAQjp2pcVi0LB2WWNXcg”)
PFAnalytics.TrackAppOpenedWithLaunchOptions InBackground(launchOptions,block:nil)
GMS服务提供密钥(“AIzaSyAM5ff80Oc-1n9UJV1wZjX6ElFP-6PD2eI”)
FBSDKApplicationDelegate.sharedInstance().application(应用程序,didFinishLaunchingWithOptions:launchOptions)
FBSDKLoginManager.renewSystemCredentials{(结果:ACAccountCredentialRenewResult,错误:NSError!)->在中无效}
PFPurchase.addObserverForProduct(“kinkstrtext.addevent”){
(交易:SKPaymentTransaction?->中的作废
println(“购买”);
}
让NotificationType:UIUserNotificationType=UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
if application.respondsToSelector(“isRegisteredForRemoteNotifications”)
{
//iOS 8通知
让notificationSettings:UIUserNotificationSettings=UIUserNotificationSettings(FORTYPE:notificationTypes,categories:nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
}
其他的
{
//iOS<8通知
application.RegisterForRemotionTificationTypes(.Badge |.Sound |.Alert)
}
var navigationBarAppearace=UINavigationBar.appearance()
var btnColor:UIColor
btnColor=UIColor(红色:0.99,绿色:0.99,蓝色:1,阿尔法:1)
var barColor:UIColor
barColor=UIColor(红色:0.706,绿色:0.506,蓝色:0.678,阿尔法:1.0)
可变标题颜色:UIColor
titleColor=UIColor(红色:0.99,绿色:0.99,蓝色:1,阿尔法:1)
UIApplication.sharedApplication().statusBarStyle=.LightContent
navigationBarAppearace.tintColor=btnColor//后退按钮等
navigationBarAppearace.barTintColor=barColor//Bar的背景色
navigationBarAppearace.titleTextAttributes=[NSForegroundColorAttributeName:titleColor]//标题的文本颜色
返回真值
}
func应用程序(应用程序:UIApplication,didRegisterUserNotificationSettings notificationSettings:UIUserNotificationSettings){
UIApplication.sharedApplication().registerForRemoteNotifications()
}
func应用程序(应用程序:UIApplication,DidRegisterForRemotionTificationswithDeviceToken deviceToken:NSData){
让currentInstallation:PFInstallation=PFInstallation.currentInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.saveInBackground()
}
func应用程序(应用程序:UIApplication,DIDFailToRegister for RemoteNotifications,错误:N错误){
println(错误。本地化描述)
}
func应用程序(应用程序:UIApplication,DidReceiveMemoteNotification用户信息:[NSObject:AnyObject]){
NSNotificationCenter.defaultCenter().postNotificationName(“getMessage”,对象:nil)
}
func应用程序WillResignActive(应用程序:UIApplication){
}
func应用程序标识符背景(应用程序:UIApplication){
}
func应用程序将进入前台(应用程序:UIApplication){
}
func ApplicationIDBecMeactive(应用程序:UIApplication){
FBSDKAppEvents.activateApp()
}
func应用程序将终止(应用程序:UIApplication){
}
func应用程序(应用程序:UIApplication,openURL:NSURL,sourceApplication:String?,注释:AnyObject?->Bool{
返回FBSDKApplicationDelegate.sharedInstance().application(应用程序,openURL:url,sourceApplication:sourceApplication,批注:批注)
}
}
这是我的标题:
#import <Parse/Parse.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <Bolts/Bolts.h>
#import <GoogleMaps/GoogleMaps.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#导入
#进口
#进口
#进口
#进口
#进口
任何帮助都将是惊人的
谢谢
-MacLean根据我的经验,对于最新的SDK,您实际上不需要桥接头,将SDK添加到其中实际上会导致问题!因此,请尝试从标题中删除它们,并在使用它们的类中使用导入
import Parse
import FBSDKCoreKit
import FBSDKLoginKit
结果表明,parse 1.6和1.7之间存在一个问题,导致了整个过程中的崩溃。我错误地声明了一个PFUser变量,对此我一无所知。解析1.7关心,而1.6不关心。我不知道会有什么不同,并认为这与facebook SDK(我多么专业)有关
罪魁祸首是
var currentUser:PFUser=PFUser()
,我可以自由编辑它。我希望这能帮助外面的人找到解析 还是不走运,不过非常感谢!!!还在拿着带着“'