I have 2 projects, both are developed in iOS 13, in one of the project SVProgressHUD works fine, i.e. shows correctly on the screen in the centre, but on the other app, it shows at the top left corner of the screen.
I had searched and found that this issue was with several users developing in ios 13. But for me it is fine in one project and wrong in the other. I believe it has a separate issue, that i am unaware of!
Here are the pictures of progress attached for both apps:
Correct appearance: (centre)
Wrong appearance: (top left)
p.s. no matter which device i choose, the behaviour is fine for one app, and different for other!!
I also encountered this problem, as I understand it, this problem occurs in projects created using XCode 11 for ios 13
to fix this you need add code at Appdelegate.swift
In func
application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?) -> Bool
Need to add validation of iOS 13 and add this line
window = UIWindow(frame: UIScreen.main.bounds)
This appearance issue is from SVProgressHUD library so, adding below code in Appdelegate.swift file didFinishLaunchingWithOptions function mentioned by #Cr0manty woking fine.
window = UIWindow(frame: UIScreen.main.bounds)
Related
Hi everyone,
I'm building a Swift app using Storyboards. I've been working fine for a few months now, but all of a sudden my app won't load properly. Whenever I open it on a Simulator or my physical iPhone, the launch screen is displayed before a black screen appears.
My Mac is on macOS Big Sur Developer Beta 5 with Xcode 12 Beta 6, and my iPhone is on iOS 14 Developer Beta 5.
This happened all of a sudden and I don't recall doing anything to cause it.
Here's what I've tried so far...
Renaming the storyboard and updating the target's General tab to the new name, as well as doing the same but manually editing Info.plist
Moving the storyboard in and out of "Copy Bundle Resources"
Updating to the latest Xcode 12 beta (I'm on macOS Big Sur)
Clearing Derived Data with DevCleaner
Starting a whole new project and moving all of my code and resources over via drag-and-drop (Interesting observation: when I started a new project, I added a simple label to the default Main.storyboard and ran it on my iPhone. The label wasn't displayed.)
Adding a function to my AppDelegate to load the storyboard manually on launch
Adding various print statements in AppDelegate and my Home View Controller
AppDelegate
I've added
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "Home")
self.window.rootViewController = initialViewController
self.window.makeKeyAndVisible()
print("App launched")
to my AppDelegate. Now, when I run my app, I get
printed. I also added
override func viewDidLoad() {
super.viewDidLoad()
print("Home view loaded")
to my Home View Controller.
Now, when I run my app, I get this printed in Xcode:
2020-08-28 13:11:20.140963+0100 MY-APP[11077:1951343] libMobileGestalt MobileGestaltCache.c:166: Cache loaded with 4536 pre-cached in CacheData and 53 items in CacheExtra.
2020-08-28 13:11:20.759943+0100 MY-APP[11077:1951162] Metal API Validation Enabled
Home view loaded
App launched
Still, nothing on my iPhone. The launch screen appears, fades to black, and that's it. I'm so confused.
If anyone knows how to fix this, or something I can try, please let me know. Thank you in advance!
Make sure there a window like this present in your sceneDelegate and AppDelegate both.
class AppDelegate: UIResponder, UIApplicationDelegate {
// check for this
var window: UIWindow?
// check for this
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
}
}
If you don't want to switch to the Scene API just yet, you can also just set UIApplicationSupportsMultipleScenes to NO in the UIApplicationSceneManifest section which probably recently appeared in your Info.plist. That's what I just did, and it fixed the issue for me.
In latest version, window property is no more available in AppDelegate. Now, it is moved to SceneDelegate.swift . You can try doing as below in func scene willConnectTo:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
if let windowScene = scene as? UIWindowScene {
self.window = UIWindow(windowScene: windowScene)
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyBoard.instantiateViewController(withIdentifier: "Home")
self.window?.rootViewController = initialViewController
self.window!.makeKeyAndVisible()
}
}
Update: Also make your Main Interface under General menu is empty
Also you have to remove the <key>UIMainStoryboardFile</key><string>Main</string> and <key>UISceneStoryboardFile</key> <string>Main</string> from your Info.plist of your project.
I also faced the same issue. The original question says,
"This happened all of a sudden and I don't recall doing anything to cause it."
This is exactly what happened to me and following is how I solved the issue.
In Main.storyboard, there is an entry point to the app which is visually depicted as an arrow pointing to the Navigation Controller. Once the issue showed up, I noticed that this arrow is now somehow missing and Is Initial View Controller checkbox in the View Controller section of the Attribute Inspector tab in the Inspectors pane is now unchecked.
The issue was resolved when I checked the Is Initial View Controller checkbox mentioned above(The arrow in the storyboard navigation controller also reappeared upon checking this). Below is an image of xcode after solving the issue to help get a better understanding.
This is an image showing the Navigation Controller and Inspectors pane after the issue was fixed.
Hope someone finds this useful.
I usually build UI programatically but for some reason after updating to Xcode 11, not able to remove storyboard or remove the reference. It keeps throwing an error saying storyboard missing. Usually I delete the main and go to project settings and remove the Main keyword text as well. I then delete the viewController, add a new viewController like HomeViewController and use the following code in app delegate.
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow()
window?.makeKeyAndVisible()
let nc = UINavigationController(rootViewController: HomeViewController())
window?.rootViewController = nc
return true
}
I follow the exact same steps that I used to follow in previous Xcode versions and it used to work (without deleting the storyboard file itself). As long as I added the above code. Now doesn't seem to be the case. If I delete the default ViewController file and say add a new HomeViewController File and add the above code, throws an error saying storyboard is missing or storyboard does not contain HomeViewController.
You don't say, but I'm assuming you're creating a new project with an iOS 13 target? If not, you can ignore this :-)
In XCode 11 for a new iOS 13+ project they changed the way initiating a UI from code works. It no longer takes place within the AppDelegate but in the SceneDelegate.
After I'd spent far too long working out what was going on I wrote it up in a blog post with the idea it may help someone else. Rather than rehashing it all, I'll link to it:
XCode 11 New Project Without Storyboard
I have a react native app that's running on React Native 0.51.0, Xcode 9.2, exclusively on iOS 11.X (mostly 11.2.5/6) iPad Pros.
After upgrading from 0.38.X to 0.49.X, I started noticing a white screen on loading, like the app wasn't starting to load the React Native bundle. I have since upgraded React Native to 0.51.0, but the problem persists.
To add a bit of color to this issue, one thing I noticed was after successfully seeing the app load to the home screen, there was one particular transition that would immediately lead to a stuck white screen again. The logs for that issue showed an issue with one of the React Native <Animated.View> objects. I noticed that I had added the RCTAnimation.xcodeproj to the parent project, but the libRCTAnimation.a was no longer linked in the Linked Frameworks and Libraries section. After adding the lib back to being linked, that particular white screen went away, and <Animated.View> worked properly.
At this point, I've triple checked that all of my included React Native projects are linked properly. At this point, I'm not quite sure which ones are still 100% required, but the list is as follows (xcodeproj and verified linked lib):
React.xcodeproj > libReact.a
RCTAnimation.xcodeproj > libRCTAnimation.a
RCTActionSheet.xcodeproj > libRCTActionSheet.a
RCTGeolocation.xcodeproj > libRCTGeolocation.a
RCTImage.xcodeproj > libRCTImage.a
RCTLinking.xcodeproj > libRCTLinking.a
RCTNetwork.xcodeproj > libRCTNetwork.a
RCTSettings.xcodeproj > libRCTSettings.a
RCTText.xcodeproj > libRCTText.a
RCTVibration.xcodeproj > lib RCTVibration.a
RCTWebSocket.xcodeproj > libRCTWebSocket.a
RCTCameraRoll.xcodeproj > libRCTCameraRoll.a
RNBlur.xcodeproj > libRNBlur.a
BVLinearGradient.xcodeproj > libBVLinearGradient.a
RNVectorIcons.xcodeproj > libRNVectorIcons.a
BugsnagReactNative.xcodeproj > libBugsnagReactNative.a
ART.xcodeproj > libART.a
Here is my AppDelegate start up code:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
CrashReporter.configureCrashReporting()
// Initialize various objects and connections
self.configureApplication()
window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = self.createRootViewController(launchOptions: launchOptions)
self.window?.makeKeyAndVisible()
return true
}
func createRootViewController(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> UIViewController {
let rootViewController = UIViewController()
rootViewController.view = self.createReactRootView(launchOptions: launchOptions)
return rootViewController
}
func createReactRootView(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> UIView? {
let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", fallbackResource: nil)
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "app", initialProperties: nil, launchOptions: launchOptions)
rootView?.backgroundColor = .white
return rootView
}
Two examples of white screens (this was a long solution...)
White Screen #1:
At some point, React Native no longer allows the <Image> View to have children. When the app hit the state where we add a child to one of our <Image> views, the screen would go white. This was at least followed up with a print statement to the log indicating the problem.
White Screen #2 (The main one):
As of iOS 11, we've noticed a different behavior when calling DispatchQueue.main.async {} from the main thread. It seems like this is ripe for creating deadlock situations (we've literally left the thing running for hours with no progress); maybe this is a bug in Apple's Dispatch Queueing system?
One of our React Native bridge objects was calling DispatchQueue.main.async {} inside of its constructor. This was never completing, blocking the main thread, and so the rest of React Native would not proceed to load (it wouldn't even get to loading the bundle). Nothing would print, and pausing the debugger at this point never produce usable state.
We simply removed the wrapping DispatchQueue.main.async {} and are calling these statements in-line, as it's already on the main thread.
I have updated from Xcode 7 to Xcode 8. I had a project on Swift 2.2 and it works well but when I have updated to Xcode 8 and Swift 3 I only can see a black screen on the simulator.
I have tried using Clean and Clean Build Folder options but the black screen is still being shown. After that, Build option. Also, there is no errors on the console or in Xcode.
Did someone get the same error at updating to Swift 3.0? Or do you know something that I can check and could be the reason of my black screen? I cannot found any similar behaviour on Internet when updating to the new Swift version.
Thank you to #YashTamakuwala because he gave me the clue that made me get the solution.
I have referenced the Initial View Controller as normal and it was linked correctly because it was also connected on Identity Inspector.
What I have to do is to remove the Initial View Controller mark and the navigation controller that was linked to the first View Controller. Then, I have set the Initial View Controller mark again to the View Controller and go to Editor > Embed In > Navigation Controller.
After do that, the project is again being shown on the simulator, without black screens.
In my case, I used xib only but got the same problem.
Then I changed application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
to application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
and it worked :D
Note: You shouldn't copy and paste. Should let Xcode suggest :)
I'm trying to set up the launch screen and initial view of my app. However, I can't get either to show up.
I have this set up:
Am I missing a step? Shouldn't I be seeing a page with "blah" on it as the launch screen? Instead, when I run the simulator it's just black.
Also, I don't understand why my initial view isn't showing up either.
In my AppDelegate.swift file:
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window?.rootViewController = self.rootViewController()
return true
}
private func rootViewController() -> UIViewController {
return MapViewController.init()
}
}
And my MapViewController.swift:
import UIKit
class MapViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
label.center = CGPointMake(160, 284)
label.textAlignment = NSTextAlignment.Center
label.text = "I am a test label"
self.view.addSubview(label)
NSLog("heyyyy!!") // <----------------- doesn't get printed either, so I think I'm missing something again...
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Sorry for the noob questions.
== UPDATE ==
I do get these 2 warnings when I build it:
file:///Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard: warning: Unsupported Configuration: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.
/Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:9: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.
I also struggled with a launchscreen storyboard not showing up. I tried everything fix I could find to no avail. Then I cleared the cache on my Simulator and it worked! Turned out it was a simulator problem. I cleared the cache with this command in terminal: xcrun simctl erase all
It looks like you haven't set up your storyboards with an entry point. Set up the first scene you want to show as the Initial View Controller
sure, this answer is a little late. ;-) Had the some problem but i fortuitous found a quiet simple solution using the Launch Screen.storyboard created with the app automatic.
Open the App-Settings and there App Icons and Launch Images
Select Launch Screen.storyboard in the DropDown-List, even when u think, this is already selected. The display of the screen won´t change after selecting. But when restart the project, the Launch Screen was showed!
BTW to test this tidy, u can set a breakpont in the last line of
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
After trying every other answer here, I finally deleted the LaunchScreen.Storyboard file and created a new one. This was the only thing that fixed the issue for me.
had the same problem with the launchscreen. As mentioned from Abizern, there is no ViewController allowed. If you had one only deleting this one will not be enough some times. The LaunchScreen file could still have some connections to the ViewController which is not available any more. This is a problem, too.
My fix:
Delete ViewController for LaunchScreen
Removed connections in LaunchScreen.storyboard
Removed app from Device
Reinstall
-> Worked :)
What you are missing is that a launch screen is static! It does not need a controller or anything. A controller will not do anything. For the launch screen you can design the UI only using the interface builder, not via code.
Xcode should generally tell you that, if you try to set a custom controller on the launch screen view it results in an error.
So deleting the LaunchScreen.storyboard + LaunchScreenViewController.swift files and adding a Launch Screen.xib file worked in fixing the launch screen. This makes sense to me since the launch screen should be static and not use code.
However the view is still black after the launch screen. I'll make another SO question for that.
i know it is very late but i want to share how i fixed it, if you are checking on real device then try to delete the app first, restart the handset and then reinstall the app. it will be fixed if you have followed all steps like clearing cache and settings in Target - General Tab etc.
In my case, the project navigator file filter was set to "recent". See bottom left of Xcode. I unselected recent, and the file showed up.
Easiest solution is to uninstall and reinstall the app when testing in the simulator. No need to remove and re-create LaunchScreen.Storyboard.