Reputation: 2328
I need help so bad.
I've been programming with swift for a while here, but I just can't seem to find anyone whose had this problem before.
Let me describe the problem: Whenever I try to run my app, it crashes in the AppDelegate, right on the first line with a "SIGABRT". The council says "'The class PFUser must be registered with registerSubclass before using Parse.'", which has me completely at a loss since I haven't subclassed anything remotely touching the PFUser.
I assume it's something to do with the FacebookSDK (4.something, the newest as of July 2) which I've been trying to integrate, but even when I remove it from the project things remain broken. Could also have something to do with how I just updated Parse to 1.7.5, but I really don't know anymore.
Here's what I've tried
Here's my code:
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)
}
}
and here's my header:
#import <Parse/Parse.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <Bolts/Bolts.h>
#import <GoogleMaps/GoogleMaps.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
Any help would be amazing!
Thanks,
-MacLean
Upvotes: 2
Views: 208
Reputation: 2328
So as it turns out, there was a problem between parse 1.6 and 1.7 that was causing this crash the whole time. I was declaring a PFUser variable incorrectly, and had no idea. Parse 1.7 cares, where 1.6 didn't. I had no idea that there could be a difference, and assumed it had something to do with the facebook SDK (how professional of me).
The code that was the culprit was var currentUser:PFUser = PFUser()
, which I was able to freely edit out. I hope this helps someone out there figure out Parse!
Upvotes: 1
Reputation: 7373
With the newest SDKs, in my experience you don't actually need the bridging headers, and adding the SDKs into there will actually cause issues! So try removing them from the header and using the imports in the class you're using them in.
import Parse
import FBSDKCoreKit
import FBSDKLoginKit
Upvotes: 1