I am trying to have users login to facebook with parse but am receiving the compiler error "Use of unresolved identifier" for PFFacebookUtils, Parse, FBAppCall, and an invalid DidBecomeActive
This question has been posted before and the solution was to add the parsefacebookutils framework into your project and import it into the header file. However, I have already added the framework to my project and imported it into my header file by adding the following to the my header.
#import <Parse/Parse.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <FacebookSDK/facebookSDK.h>
I am still getting the error. The following is the code from my appdelegate file:
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
PFFacebookUtils.initializeFacebook()
Parse.setApplicationId("parseAppId", clientKey:"parseClientKey")
}
return true
}
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String,
annotation: AnyObject?) -> Bool {
return FBAppCall.handleOpenURL(url, sourceApplication:sourceApplication,
withSession:PFFacebookUtils.session())
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBAppCall.handleDidBecomeActiveWithSession(PFFacebookUtils.session())
}
Could you please take a look at my code above? Not sure what the solution is.
Figured it out. You have to go into the Build Settings - Objective C Header and then type the path to your header in the debug name. For example ProjectName/HeaderName.h as according to where I had my file within my project. Normally you wouldn't have to do this, but it didn't populate for me when I created the header.
Related
I have a standard AppDelegate file in my Xcode project, I'm experimenting with Firebase and as soon as I imported it & added
FirebaseApp.configure()
I was flagged with purple warnings: Click me
The whole AppDelegate looks as follows
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
These warnings never appeared whilst using Xcode 8, as a novice I am unsure on how to fix this, I have read that adding a DispatchQueue.main.async can fix it but I'm not sure where to add this.
Thanks!
I am trying to integrate FacebookLogin SDK 4 into my IOS app using Swift 3. I added the following 3 frameworks: Bolts, FBSDKCoreKit and FBSDKLoginKit. I changed my Info.plist according to Facebook documentation, created the Bridging header file, and added its path to my Build Settings.
Once I add the following line in my AppDelegate.swift file, I am getting:
Apple Mach-O Linker Error:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
I tried the options provided here: Apple Mach-O Linker Error when compiling for device
None of them helped (unless I am missing something). Has anyone else had a similar problem? Please help.
Have u added this method in app delegate
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
-> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: [:])
}
also this one in willResignActive method
func applicationWillResignActive(_ application: UIApplication)
{
FBSDKAppEvents.activateApp()
}
So I made a project that included lots of extra code so I could try out different things, and I am slowly copy-pasting the files from textedit into my new project.
I created a new Firebase account, added the google plist file, initialized and installed the pods needed (also changed the iOS version to 10.0 on the pod file)... yet it's still wanting me to use FirebaseApp.configure() instead of FIRApp.configure().
Should I just delete the whole thing and try again? I just created a new Xcode project, so if I had to delete it right now that would be fine.
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init() {
super.init()
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
return true
}
There hasn't been much code written, but I can't figure out what could have made this happen... especially since I just started the new project.
FirebaseApp.configure() is correct. I checked out the documentation just now and FIRApp.configure() has been renamed FirebaseApp.configure(). I also ran pod update on one of my projects just to confirm, and my project had me change to using FirebaseApp.configure(). So no need to rebuild!
I can confirm that FIRApp.configure() can be changed to FirebaseApp.configure()
In firebase it suggest to add the following to app delegate:
"
import UIKit import Firebase
#UIApplicationMain class AppDelegate: UIResponder,
UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
-> Bool {
FirebaseApp.configure()
return true } }
"
This includes the FirebaseApp.configure() command
I have updated the Crashlytics but still I am getting this error on launch:
Error: *** Terminating app due to uncaught exception 'FABException',
reason: '[Fabric] It appears that "Crashlytics" is not a valid Fabric
Kit. Please make sure you only pass Fabric Kits to [Fabric with:].'
Here is my code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
Fabric.with([Crashlytics.self])
return true
}
I was having a crash on the same line, and it was because I called it BEFORE FirebaseApp.configure().
For anyone having the same issue, make sure you call them in this order:
FirebaseApp.configure()
Fabric.with([Crashlytics.self])
After spending 7 hours, I am able to solve the problem. Problem is: there are 2 Crashlytics files are in my code which are causing this problem. To solve the problem, I have deleted the older file and again integrate the Crashlytics.
Try this:-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self])
return true
}
Try below code snippet, it may help:
For Swift:
//import related frameworks
import Fabric
import Crashlytics
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
Fabric.with([Crashlytics()])
//... your initialization code
return true
}
For Objective-C:
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Fabric with:#[CrashlyticsKit]];
//... your initialization code
return YES;
}
Is anyone else having issues running a simple Cocos2d v3.1 on Swift with the xcode 6 beta 5?
#UIApplicationMain class AppDelegate : CCAppDelegate, UIApplicationDelegate {
override func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool
{
setupCocos2dWithOptions([CCSetupShowDebugStats: true])
return true
}
override func startScene() -> (CCScene)
{
return HelloWorldScene()
}
I'm having the issue with my own project, but I found a sample project on github with the same issue:
https://github.com/chunkyguy/Cocos2dSwift
The didFinishLaunchingWithOptions function has the error:
Overriding method with selector 'application:didFinishLaunchingWithOptions:' has incompatible type '(UIApplication!, NSDictionary!) -> Bool'
Changing the function signature to:
override func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool
fixes the compiler errors but the app crashes with EXC_BAD_ACCESS on the AppDelegate.
Has anyone come across this issue or can suggest a fix?
So I wasn't clearly reading the error message in detail. I was missing out exclamation marks because I copied and pasted the UIApplicationDelegate swift generated headers. I should have entered:
override func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]!) -> Bool
Command clicking on UIApplication delegate does show:
protocol UIApplicationDelegate : NSObjectProtocol {
...
optional func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool
i.e. without the '!'s