I had this error already in Xcode 13 but it still persists
in the current version.
When I connect my iPhone XS to preview my SwiftUI app in the canvas, it shows the iPhone 14 Pro layout. However, when I check on Devices and Simulators, it's correctly recognised as iPhone XS.
So when I design my layout, I always have to switch between the iPhone XS simulator for designing, and my real device for testing.
Does anybody know a way to show the correct device in the canvas?
I have the same issue and I found out that if you want to see the specific device type to canvas, you have to download the simulator for this device.
From the "Windows" tab, choose "Device and Simulators", and then Simulators. At the bottom left of the window, you can add new simulators.
Then choose your device type and download it.
Once you've added a new simulator, you can use PreviewDevice(rawValue: "Your Device Type").
For example:
I added a new iPhone 12 Simulator and use HomeScreen().previewDevice(PreviewDevice(rawValue: "iPhone 12"))
add simulator window
After that, I am able to see my screen as an iPhone 12.
Related
We have an app that has been rejected in the review process by the Apple app review people. The cause for the rejection is that the app is not scaling properly when run on an Ipad.
The app was never meant to be run on an Ipad, but there seems to be no point in arguing with them about that.
Apple sent us a couple of screenshots that show our app being run on an Ipad with the top portion of the view cut off. Notice how the app is run in some mode where it looks like an Iphone app and does not fill out the entire display area. When we bring up the app on an Ipad, it fills out the screen and does so without any edges cut off.
Can anyone please tell me how to run the app on an Ipad the way the Apple guys have - Iphone-sized? We believe we have a fix for the issue but we need to reproduce the error and then be able to verify that the fix solves the issue.
(the logotypes in the images are intentionally blurred)
I just went through this myself and here is how I resolved it:
Go into info.plist and see if any of the supported interface orientations are set for iPad. Despite selecting iPhone only, I had iPad supported orientations for four (portrait, portrait upside down, landscape left, landscape right). I deleted those.
I also deleted any reference to the launch screen in the info.plist. My app is pretty simple and there's no preloading of data so I don't really need a launch screen. If you do, you could go old school and make your first VC the launch screen.
I then made these changes in Target-->General-->App Icons and Launch Images
That was the only way I could get it in the sim to run the app at iPhone resolution while running an iPad (iPad2, iPad Air).
If Apple is going to force developers to ensure an app runs on an iPad even if it is made just for iPhone, they should eliminate the iPhone Only and Universal options and just have iPad Only as an option.
To run an iPhone app on an iPad, you just need to:
Acquire an iPad (you can also use the simulator)
Set the target device family in Xcode (it's under your target) to iPhone
Connect your iPad, perform any necessary certificate dances
Run the app on the iPad.
As long as the target device family is set to iPhone, the iPad will show your app in this mode.
Apple is likely running your app on a simulator, not on a real device. Notice the "2X" on the top right. In XCode - you should run the app on iPad Retina Simulator. On the bottom right you will see a button that you can toggle from 1X to 2X.
If you place the simulator in "2X" mode, you will see what Apple is seeing.
What OS are you running on your iPad? Things have changed in iOS 8 - and that's likely why you're not seeing what Apple is seeing. My guess is that your are running an app that was initially developed for iOS 7 or earlier - which means that you need to upgrade from scaled resolution to native resolutions to resolve this issue. Here is how you do it:
How to enable native resolution for apps on iPhone 6 and 6 Plus?
The latest iOS on which I worked was ios 4.3. However continuing with iOS development now, on switching to iOS 6 I found a lot of different features. One interesting and confusing feature is the new look of iphone simulator. It has a new shape and does not have home button. I was looking at this link and learnt that this was true for devices after iPhone 4 including it.
My question is, why is home button absent for new iphone simulators not considering that former would appear after scaling the latter.
there is a option of Home button
1) it gives shortcut for Home button = cmd + Shift + H
2) it gives three size of simulator = (cmd+1, cmd+2 and cmd+3)
you can switch size of ios simulator (cmd+1, cmd+2 and cmd+3)
It also depends on your screen resolution. On my MBP Retina it displays the frame for all the device, on my external monitor (1600 x 1200) it fails to show the frame for all the Retina simulated devices.
I program for both iPhone and iPad. When doing iPhone stuff, I prefer the retina iPhone simulator. When doing iPad stuff, I prefer the non-retina simulator. Swapping between them is a two-step process for me. I have to switch xCode from the "iPhone simulator" target to the "iPad simulator" target. The problem is that when I do this, the simulator switches from retina iPhone to retina iPad. I therefore also have to go into the simulator app and change the hardware to non-retina iPad.
Is there a way to accomplish that in a single step?
Yes! and its super easy. In Xcode 4+ click the dropdown with the name of your target in it in the top menu bar next to the play button. Then click edit scheme.
Click the run action and then click the Options tab. You will see you can specify the type of screen you want to use when you click the play button (build and run) in Xcode.
Then when you switch device target in Xcode it will automatically switch the simulator to the right device and screen type for you.
Also if you're running less than iOS 5.1 the simulator will switch back to non-retina. Set SDK to 5.1+
I have downloaded xcode 4.5 from ios dev center.(dnt know is it the way).I got a dmg file.when i clicked on it to install it has only one xcode setup is there(nothing like samples,simulator folders which normally has).i inatalled it run my application .but when i got the simulator it has hardware options as ipad,ipad retina,iphone,iphone retina3.5,iphone retina 4 inch.only.the normal iphone simulator has the same screen reselution as 320,480.so the retina display has only the changed reselution screen.Is it correct.Can any body used this can guide me?
If you mean that there is no low resolution Simulator, thats right. If you want a smaller Simulator, you can type CMD-3.
Iphone Simulator, in my Mac system, is not having regular phone shape like
Instead it looks like a window
When I give iOS Simulator->Hardware->rotate left, it gives a irregular shape
My Mac system Specification is
OSX: version 10.6.8
xcode: version 3.2.6
iOS: version 4.3
How this can be corrected?
The simulator is displayed this way if your screen is too small to fit the full version. Are you using something with a relatively small screen, like a MacBook Air?
If so it may not be a bug (well, the second screenshot is, obviously, but the first may not be).
Also check what Hardware > Device settings your simulator is using. If it's set to iPhone (Retina), try changing it to just iPhone, which should fit on your screen better.
Also, check the Window > Scale and see if it lets you change it.
Best thing is to reinstall xcode and ios sdk
You change simulator shape for iPhone device
MacBook Air
Simulator settings -> Window -> Show device bezels