Parse setApplicationID - Xcode 6.3/iOS 8.3 - ios

Parse.setApplicationId("****", clientKey: "****") {
getting an error saying "expected declaration"... didn't have this issue on an earlier version of Xcode

All you have to do is
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Parse.setApplicationId("Your_application_id",
clientKey: "Your_Client_Key")
return true
}
And import in your bridging header:
#import <Parse/Parse.h>

Related

Firebase Crashlytics integration not detecting or reporting crashes

I have integrated Crashlytics , here are the changes i have done.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.with([Crashlytics.self()])
Crashlytics.sharedInstance().debugMode = true
Have you added a key like.
"${PODS_ROOT}/Fabric/run" ed9c83ee83d41dc717a07531450c480895e41264 b6cc34ec354a4f96ab160958b4s2a01cc321be62acaa6116983376a5113c9s36

UIApplicationLaunchOptionsKey not found

UIApplicationDelegate method - application(_:didFinishLaunchingWithOptions:) showing an error with Swift 4.2 (Xcode 10).
UIApplicationLaunchOptionsKey not found
What is replacement of UIApplicationLaunchOptionsKey in Swift 4.2?
'UIApplicationLaunchOptionsKey' has been renamed to 'UIApplication.LaunchOptionsKey'. Replace 'UIApplicationLaunchOptionsKey' with 'UIApplication.LaunchOptionsKey'.
Click on error hint, will show you solution:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
}
Xcode would fix-it but UIApplicationLaunchOptionsKey is replaced by a nested type UIApplication.LaunchOptionsKey.
It should be UIApplication.LaunchOptionsKey, Please find following apple documentation
I have tried the below snippet of the code and worked for me.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication: Any]? = nil) -> Bool {
}
Just provide UIApplication in launchOptions.
Hopes it will work for you as well. :)

iOS (Fabric): Crashlytics crashing app on launch

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;
}

'AnyObject' is not identical to '[NSObject : AnyObject]'

I am finding this error in my AppDelegate.swift file and it appears in the AppDidFinishLaunchingWithOptions function. It is raising the error on a line of code that is from the Parse framework.
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
The error is appearing on the launchOptions parameter. I will post the whole function to show that it should be correct. Also when I comment out the line of code the error disappears, but I still really want to be able to use the function and track the analytics. Here is the whole function:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: AnyObject!) -> Bool
{
// Override point for customization after app launches
Parse.setApplicationId("removed on purpose", clientKey: "removed on purpose")
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
PFFacebookUtils.initializeFacebook()
return true
}
I can't seem to find anything that relates to this error. If anyone has some insight I would really appreciate it!
Since Xcode 6 beta 7, when you want to call application:didFinishLaunchingWithOptions:, you have to replace:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
/* ... */
}
with the following code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
/* ... */
}
The last parameter of this method is no more a NSDictionary but a Dictionary of type [NSObject: AnyObject]?. Therefore, you must update your code (including your trackAppOpenedWithLaunchOptions: parameter type).
The launchOptions parameter should be declared as NSDictionary! instead of AnyObject!:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// ...
}

cocos2d CCAppDelegate issue with swift and didFinishLaunchingWithOptions

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

Resources