Why am I getting two different screen dimensions in different projects (Swift)?

I just finished a very rough draft of my first app whilst learning Swift. So I decided to remake the app so that my code would be cleaner/more compliant, etc.

I don't use storyboards, I launch from GameViewControler, both apps are set for a minimum iOS of 13.5, and both are run on the iPhoneX simulator...as well as my iPhoneX itself.

But for some reason in each different app, I am getting different screen sizes! Am going to assume I did something different when I "created" the new project, but am unable to distinguish what that is.

Here is my entire GameViewController.swift file and have included a photo of the different screen sizes. I break right after I get both the bounds and native bounds.

The two different sizes are:

In the 1st project I get

wPixels 1125
hPixels 2436
wPoints 375
hPoints 812



and the 2nd

wPixels 960
hPixels 1440
wPoints 320
hPoints 480




Code Block
import UIKit
import SpriteKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
var wPix = UIScreen.main.nativeBounds.width
var hPix = UIScreen.main.nativeBounds.height
var wPoi = UIScreen.main.bounds.width
var hPoi = UIScreen.main.bounds.height
var scene : GameScene!
DispatchQueue.main.async { [self] in
scene = GameScene(size: CGSize(width: wPoi, height: hPoi))
scene.anchorPoint = CGPoint(x: 0.0, y: 0.0)
scene.backgroundColor = .red
scene.scaleMode = .aspectFit
view.isHidden = false
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
view.showsPhysics = true
}
}
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown
} else {
return .all
}
}
override var prefersStatusBarHidden: Bool {
return false
}
}

Answered by OOPer in 642722022
Does your 2nd project has LaunchScreen.storyboard ?

You may find this article interesting.
Main screen size is always 320x480?

wPixels 1125
hPixels 2436

Points is 1/3 because 3 pixels per point

That's 11 Pro, Xs and XsMax

wPixels 960
hPixels 1440

That corresponds to no device

Here is a table with screen size for all devices : https ://ios-resolution .com

So what are exactly the case 1 and case 2 ? What are the target devices you simulate on ?


included a photo of the different screen sizes

Photos don't show on forum
Accepted Answer
Does your 2nd project has LaunchScreen.storyboard ?

You may find this article interesting.
Main screen size is always 320x480?
Why am I getting two different screen dimensions in different projects (Swift)?
 
 
Q