iOS 15 Beta keyWindow not available in viewDidLoad - viewdidload

We have a lot of logs to Crashlytics where the keyWindow ist nil after app startup in viewDidLoad of the first viewController show on screen. Anyone else having problems to access UIApplication.shared.keyWindow?.rootViewController on app startup with the current iOS 15 betas (19A5337a)?
As we are still supporting iOS 12 (will change after the iOS 15 release), we do not use the UISceneDelegate to hangle lifecycle events (UIApplicationDelegate
is used).
iOS 14 or below if working fine.
Any ideas or hints how to fix this? Maybe it is sill "early" beta and it will disappear when we can submit builds for iOS 15 with the GM version of Xcode...
Thank you :)

Related

Difference between "didBecomeActive" and "willResignActive" method pairs for UISceneDelegate and UIApplicationDelegate?

My main task is to overlap the screen with non-transparent view to hide info when app enters background. The official solution is described here.
The problem is it sometimes doesn't work on iOS 13.
I found this article:
It explains how sceneDidBecomeActive(_:) and sceneWillResignActive(_:) work. But new projects have AppDelegate+SceneDelegate, old ones have AppDelegate only. Could I just use applicationDidBecomeActive(_:) and applicationWillResignActive(_:)? Or should I somehow migrate the project to use UISceneDelegate (which is not supported in iOS 12 and earlier versions)?
If you have an app created prior to Xcode 11 then it has no support for scenes. As long as you don't add anything related to scenes (which Apple may disallow in the future), then your app's lifecycle will continue to work under iOS 13 just as it always has under iOS 12 and earlier. Just continue to use the UIApplicationDelegate methods.
If you have an app that supports iOS 12 and iOS 13 and you are using scenes in iOS 13, then you must implement both applicationWillResignActive (in support of iOS 12 and earlier) and sceneWillResignActive (in support of iOS 13 and later).
In fact, in an app that supports both iOS 12 and 13 you basically need to implement both sets of UIApplicationDelegate and UISceneDelegate/UIWindowSceneDelegate methods. The methods of UIApplicationDelegate will be called when your app runs on a device with iOS 12 or earlier and the UISceneDelegate/UIWindowSceneDelegate methods will be called when your app runs on a device with iOS 13 or later.
Just remember that under iOS 13, if you support multiple windows/scenes, the scene delegate methods are associated with a specific scene.

NSUserDefaults in iOS10 not working on device

My app uses NSUserDefaults and it is running as expected in the simulator on Xcode 8 with an iOS10 option selected.
I have an old iPhone 5 I use for testing and I have upgraded this to the iOS10 GM and my NSUserDefaults are not working.
The app does not crash but it just does not save any information when I set an NSUserDefault.
Any idea why this might be happening?
Sorry I have found the problem, it is with my UISwitch
All of the NSUserDefault code is working fine.
The switch was what set the UserDefault and I have found that if you slide the switch it does not register but if you tap the switch it does.
I have found that this bug started in iOS 7 so when I updated my app for iOS 10 and the Development Target moved up to iOS 8 the bug started.
So in the simulator the switch responded to a tap but on the device if I slide my finger across the switch it didn't register even though the switch changed state.
Thanks for the suggestions anyway.
in Xcode 8 / iOS10, NSUserDefaults is now UserDefaults, and standardUserDefaults() is now standard() - Try updating your code to this new name scheme and see if that fixes it.
Here is the Apple documentation on the dropping of the NS prefix: https://github.com/apple/swift-evolution/blob/master/proposals/0086-drop-foundation-ns.md

iOS 9.1 Simulator problems

I developed an iOS app on Xcode 6.3 with iOS 8.3 .
Now I update Xcode to 7.1 with iOS 9.1 .
My app work perfectly on iPad with iOS 9.1
and all the views work perfectly in iPhone with iOS 9.1 expect one view .
With iphone 4s , 5 the problem is (lldb) with EXC_BAD_ACCESS(Code = 2 ,)
With iphone 5s , 6 , 6 plus , 6s , 6s plus no error message but the simulators hung all the time with max cpu and ram usage.
note : the implementation of view that causes the problem the same with iPad but in iPad work perfectly .
Please what the true analysis for the problem ?
There is a bug in Xcode 7.1 with UITextView , this is stupid bug.
You don't need to ensure that the UITextView holds at least 10 characters. Just adding a default of at least 10 characters to the UITextView in Interface Builder will fix the problem. Then, you can empty the UITextView using code.
this issue comes sometimes if u migrate from xcode 6 to xcode 7.. clean the code and check if the base sdk is proper.
sometimes this issue also comes in simulator. try running the app in real device.
Also, see if xcode 6 and 7 are not running simultaneously. run only one at a time.
Hope this helps u

XCode and App hangs while debugging

Briefing:
Application View Controller Stack:
Navigation Controller > RootViewController > TabbarController
Where RootViewController is a basic UIViewController (like a menu) and lets user to select the starting tab (UIViewController) for the upcoming UITabbarController.
Occurance:
occurs on iPhone 4S, iOS 5
not occurs on iPhone 5, iOS 6
not occurs on any simulator (iOS 5, 6)
After I navigate to UITabbarController (which consists 4 UIViewControllers) if I try to change between tabs, App itself and XCode hangs for an indefinite time (between 5 to 60 seconds). I have disabled all background threads, all network traffic, every singleton. Yet it still hangs while debugging.
This happens once per runtime, only on first change of tabs.
The tricky part is if I disconnect my device from XCode and start app without debugging, there is no such behaviour. I tried to identify where this "hang" occurs. But I was unable to catch the thread/process which is causing it.
Looks like my app chokes during that period and viewDidLoad,viewDidAppear,viewDidDisappear messages starts to flow back in after hang is gone.
How can I address this problem, find out what is causing this?
I am using XCode 4.6.1, iOS base SDK 6.1. I have started this app on XCode 4.3.2, iOS base SDK 5.1. Then upgraded to XCode 4.6.1 and this issue arised.
I also profiled the app for possible leaks, there is no leak and suspiciously app does not hang while profiling.
I am trying to address this issue for days now, it is getting a bit frustrating. I can provide any other details if requested.

iOS 5 SDK issue

I have a working application on iOS 4.
I have migrated to SDK 5, and now, on simulator and on devices the application just freeze.
There is no error or crash, just UI totaly freeze.
That occur only on the following case.
I have table view with FetshResultController that have list of object (Managed Objects).
Click on one of the list pushViewController with details.
For each list controller update i call tableView reloadData for the details view.
on iOS 4 there is no problem, but on iOS 5 after some time (can be minute or even few seconds) the entire UI freeze without any error. I need to forcly close the reopen the application.
Why is that issue on iOS 5 ? What can i do ?
(Compiling on iOS 4 is enabled to run on iOS 5, but i try to compile on iOS 5, so i will be able to debug it. iOS 4 SDK cannot "see" iOS 5)