Nothing appears in my demo - ios

What does this error mean and how can i fix it ? I have actually chosen an empty tampelet to do my app from the scratch my self but some one told me that there is such method in deligate that is supposed to be deleted but it seems that it more than just that ;)

Just replace didFinishLaunchingWithOptions method with this method:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
Which will remove your error and I can see a break point at line 17 in your screen shot which is looks like:
so remove it and run your project again.

Related

How to create Custom Launch Screen with delay of actual App Loading Time in Swift?

How to create Custom Launch Screen with delay of actual App Loading Time in Swift ?
Can somebody please tell me, how to do that?
I create Custom Launch Screen using Storyboard, but i dont know how to calculate the Application Loading Time.
If I understand your question you can set a delay with thread.sleep in the AppDelegate class:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Thread.sleep(forTimeInterval: 3.0)
// Override point for customization after application launch.
return true
}
Michele

How to speed up UI tests in Xcode (when using a storyboard)?

I am trying to speed up the execution of UI tests in Xcode 8. I tried following the solution presented in the following stackoverflow post:
How to speed up UI test cases in Xcode?
However, using that solution did not work in my case, I think because I am using a storyboard.
So instead of writing:
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool{
if NSProcessInfo.processInfo().arguments.contains("UITests") {
UIApplication.sharedApplication().keyWindow?.layer.speed = 100
}
}
I wrote:
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool{
if NSProcessInfo.processInfo().arguments.contains("UITests") {
UIApplication.shared.delegate.window??.layer.speed = 100
}
}
The change is in the 4th line. From what I understand, because I am using a storyboard the optional keyWindow is not ever being set. So I tried setting the speed of the window property of delegate, but unfortunately that didn't work either.
Can anyone point me in the right direction as to how I can speed up UI tests if I am using a storyboard?

Private func didFinishLaunchingWithOptions not being called? (Swift 3)

Isn't didFinishLaunchingWithOptions supposed to be called when the app starts running for the first time? I set a breakpoint at this method and when I run the app in the simulator the breakpoint doesn't get hit, which means the method doesn't get called. I'm trying to load some data from UserDefaults whenever the app launches, but it's being completely ignored. One thing I noticed is that it's by default a private func instead of a func. If I get rid of the private, I receive a warning that "there's an almost similar optional requirement in the UIApplicationDelegate". Can someone explain to me what this means and whether or not the private func has anything to do with the method being ignored? Is that method even supposed to be called when I run my app in the simulator? If not, how can I test if data is being retrieved after my app launches? All the other methods in the AppDelegate do get called normally (for example, the applicationDidEnterBackground method works perfectly fine).
Remove your method signature and have Xcode autocomplete it
I also had the problem that my didFinishLaunchingWithOptions method in AppDelegate would not be called. My function was also marked private and looked like this
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
The problem is that this is the old syntax! Apparently for me when I converted my project from Swift 2.x to Swift 3 Xcode did not convert the methods in AppDelegate. The new syntax looks like this
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
Swift 4.2:
func application( _ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
for Swift ~3.0 Replace didFinishLaunchingWithOptions with
follwing signature
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
}
Have you implemented the didFinishLaunchingWithOptions in one of your ViewControllers? One will not get a call to the custom implementation of this method. This method is defined in the ApplicationDelegate and it will always be called once the app is launched. If you haven't defined the method again in any ViewController and the one in AppDelegate is not being called, then try resetting the simulator. From the simulator menu Simulator -> Reset content and settings.
If compiler prompts to make the didFinishLaunchingWithOptions method private then the parameter of the method might be causing the error.
The parameter of the application(_:didFinishLaunchingWithOptions:) delegate method is now bridged to Swift as a [UIApplicationLaunchOptionsKey: Any]?, rather than an [NSObject : AnyObject]?. So modify the method signature as shown.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ...
}
This method is defined in the ApplicationDelegate and it will always be called once the app is launched. If you have not defined the method again in any ViewController and the one in AppDelegate is not being called, then try resetting the simulator.
Open simulator - > menu Simulator -> Reset content and settings.
-(BOOL)application(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//..
}
Update for Swift 4.2:
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool
Delete app from device and restart Xcode worked for me here

application(_:didFinishLaunchingWithOptions:)' nearly matches optional requirement

After installing Xcode 8 beta 6, I'm getting a warning saying:
Instance method 'application(_:didFinishLaunchingWithOptions:)' nearly matches optional requirement 'application(_:didFinishLaunchingWithOptions:)' of protocol 'UIApplicationDelegate'
in my App Delegate.
There are 2 suggested fixits to silence the warning:
Mark the method as private
Add #nonobjc to the method
Doing either silences the warning. But why does this need to be done?
iOS 12 SDK Update
In the iOS 12 SDK (that ships with Xcode 10), UIApplicationLaunchOptionsKey has now been renamed to the nested type UIApplication.LaunchOptionsKey, so you'll want:
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// ...
}
iOS 10 and 11 SDKs (Xcode 8 and 9)
This warning is due to the fact that the didFinishLaunchingWithOptions: parameter of the application(_:didFinishLaunchingWithOptions:) delegate method is now bridged to Swift as a [UIApplicationLaunchOptionsKey: Any]?, rather than an [NSObject : AnyObject]?.
Therefore you'll need to update your implementation to reflect this change:
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
// ...
}
Note that neither of Xcode's suggested fixes will actually fix the problem, they'll only conceal your implementation of application(_:didFinishLaunchingWithOptions:) from Objective-C – meaning that it'll never actually get called.
the first parameter passed into the function no longer has an external name. This is really just a minor detail since you don’t call this method directly, and it’s a quick fix to make the compiler happy. You can either manually edit that first parameter name to _, or just let Xcode handle this for you.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool
or the New Syntax
func application(_ application:UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool // or remove = nil and try
you can get the latest Documentation from apple and sample link in here

'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 {
// ...
}

Resources