when I start my application from Xcode, the application works properly, but if I close and then open the app again, it goes into the background automatically without control. How can I fix this bug ?
There are some crash types those will not be happening when running the app via Xcode.
For example:
If the app launch takes too long, that app will be crashed. Basically it’s not a crash, but app needs to be launched quickly without delay which is expected by operating system.
So You need to make sure that you are not doing any heavy operations on Main Thread during app launch especially on below methods in AppDelegate
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Avoid heavy loads on main thread here
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Avoid heavy loads on main thread here
return true
}
Also I received a crash a few years back when I tried to add an objective c struct to my NSObject class without allocating memory of struct variable. But this crash was unable to reproduce when I was running my app via Xcode and only happened when I launch the app without Xcode. So I made that struct variable as a pointer and did memory allocation as like (BoothStructure*)malloc(sizeof(BoothStructure) * count), after that there was no crash.
So please analyze your crash using crash logs as well and check if it meets any one of above scenario.
To check crash log of development build:
Open Xcode -> Connect your iOS device which has/had the crashed app -> Window -> Devices and Simulators -> View Device Logs
To check crash log of production build(you should add your developer account in Xcode that is used to publish your app):
Open Xcode -> Window -> Organizer -> Select your app from the list of apps -> Select crashes tab in segmented controller at top -> Select your build version.
Related
I'm trying to transition my iOS app from Crashlytics to Firebase, since Crashlytics is going to be shut down in a month. I went through the steps described here:
https://firebase.google.com/docs/crashlytics/get-started-new-sdk
It all looked great until I tried my first test distribution. I added a piece of code that would crash the app on a button tap to test that I get the crashes from distributed apps. However, it didn't work. The app crashes, but I see no crash reports. I do see that Crash-free users percentage is going down though. So something is getting registered, but the actual crashes are not there.
My fists couple of test distributions were missing DSYMs. And under DSYMs tab I could even see the crash count. However, when I did upload the DSYMs the crashes still didn't appear.
Now I'm using a script that does the DSYM upload on archive, but crashes are not showing up still.
When I do a build using Xcode and force crash everything works as expected. It's only the distributed AdHoc builds don't show any crashes in the portal.
Any kind of help is highly appreciated.
If your forced crash didn't crash, crashed before you wanted it to, or you're experiencing some other issue with Crashlytics, you can enable Crashlytics debug logging to track down the problem.
To enable debug logging on your development device, specify the following command line argument in Xcode:
Crashlytics 3.11.1+
-FIRDebugEnabled
Previous versions
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Initialize Firebase service.
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}
Boom, after hours of trying and searching.
https://github.com/firebase/firebase-ios-sdk/issues/2901
Disabling bitcode for AdHoc builds fixed it for me.
When iOS 13 released, I opted out of using the new SceneDelegate through the normal procedures.
- SceneDelegate.swift does no longer exist
- There are no Scene related methods in AppDelegate
- Application Scene Manifest is removed from .plist
This worked great, and is how I've been running since (iOS 11.0 target, Xcode 11.2.1).
Last week I ran a build with deployment target as 13.0, then swapped back to 11.0.
Since then, the application delegate methods are no longer being called, such as.
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
The only thing that happens, that I can see is a log in console
Can't end BackgroundTask: no background task exists with identifier 15 (0xf), or it may have already been ended
I've triple checked all the settings above, but I can't get it to work like it used to.
The only thing that might be different is that the storyboards now defaults to 'automatic' (iOS 13.0, *) presentation mode, but I'm not sure how it was before.
Since automatic is only available from iOS 13+, it seems like something is messed up.
Does anyone have a clue?
Following up on the response in this thread:
applicationDidBecomeActive
applicationWillEnterForeground
etc are actually called.
I've tried cleaning the build, restarting Xcode, the mac, the device, clearing derived data etc.
So, I finally found the answer.
Turns out it's a good old
Instance Method Nearly Matches
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
That Xcode completely ignored to report, and somehow managed to break in between building for iOS 11 > iOS 13 > iOS 11.
It's also strange because I verified them a couple of days ago with the documentation, both Apples & Firebase, and there was no difference between them.
In the end, it works now, yay.
If you don't need want to use the SceneDelegate then add below property in the AppDelegate file.
var window: UIWindow?
Add this line above didFinishLaunchingWithOptions function
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
return true
}
I'm trying to get the url for my contrainer ID but the method keeps returning nil.
I've done the following:
Enabled iCloud Key-value storage in Xcode capabilities.
testing on a physical device.
iCloud, and iCloud Drive turned on in the physical device.
Made sure that iCloud Key-Value Store is added to the entitlements file.
My code is:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Override point for customization after application launch.
let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(cloudURL as Any)
return false
}
I have looked for almost all of the questions that are related to this issue and tried the answers but it's not working.
For Xcode 9.2, checking this option worked:
iOS10.3
I had same problem, fix it by following steps:
1.go to physical device's setting -> iCloud. turn off iCloud Drive and turn it on again, find your app in iCloud Drive, turn off and turn on.
2.shut down your device, and restart it.
Then it worked, I'm not sure which part make it worked, hope for help.
Try this :
Inside the Settings app, under the 'iCloud' menu. I noticed that 'Documents & Data' was set to Off.
Solution was to change ('Documents & Data' to 'On'.
I am working on an iPad app that does not use a .storyboard interface. My AppDelegate has the following code (in Xcode 8.2.1):
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = MyViewController()
return true
}
I've cleared the Main Interface field from the target as shown below:
However, upon running the app, I receive the following crash message:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Could not find a storyboard
named 'Main' in bundle NSBundle
It seems that upon Building/Running the app, the Main Interface field is automatically repopulated with "Main". I've been able to remove this on universal apps, but this is my first, and unsuccessful attempt with an iPad only project. I've tried both pressing Return on the keyboard and clicking outside the field in hopes of saving my Main Interface text field changes, but still have the same result.
My question is: How can I remove the Main Interface from the target and thus avoid this error message?
Check your Info.plist. There should be an entry for the Main storyboard file base name. Delete it there and you should be good to go!
I installed XCode 7.1 and 7.2 to update my app for iOS 9.1 and 9.2 respectively, but each time I run the app on simulators or devices the app crashes on the AppDelegate's class declaration as shown below. However, I have also XCode 7.0 and when I run my app on iOS 9.0 it works fine without any issue !.
The problem even if I compile the app for iOS 9.0 it would crashes on any device running iOS 9.1 or 9.2, I tried to change the initial view controller to be a simple plain one but it seems that it never reaches the point of loading view controllers and never reaches the beginning of func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool.
It seems that Apple did something with iOS 9.1 & 9.2. The app is written in swift, I enabled NSZombie and breakpoints to catch exceptions but I get no clue from the logs.
Debug Navigator:-
AppDelegate Class Declaration
That happens to me almost every time in new versions of Xcode/Swift/iOS. When I have had this problem I have erased that line and written it again.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
This happens when you have not set you variable types correctly. Check how you declare them. In my case i was trying to access a Bool as UIColor.
I've generally had this happen when there is a storyboard problem. For example, an error in:
storyboard.instantiateController(withIdentifier: "FooView")
Try putting breakpoints around controllers that are being loaded around where you are crashing to see if that's the problem.