SwiftUI - geometry inconsistent on iPad simulator and real device

After running automated UI tests it turned out that my app looks quite different on iPad simulator than on real iPad.

I have my iPad Pro 12,9" right next to me and the app looks completely fine, but on Simulator (same device model on Simulator) the geometry is simply wrong.

I use SwiftUI's GeometryReader to properly place elements, add horizontal padding if the screen width is wide and in landscape orientation.

It is not the worst case, because on real device everything looks fine, but I wanted to use screenshots generated by these tests and the ones taken on iPad Simulators are simply useless. iPhone Simulator is totally fine.

Am I doing something wrong? Has anybody encountered this?

I run the tests in the following way:


projectName="./MyProject.xcodeproj"

schemeName="MyProject"

simulators=(
    ...
   "iPhone 12 Pro Max"
    ...
   "iPad Pro (12.9-inch) (5th generation)"
    ...
)

languages=(
  "en"
   ...
)

appearances=(
  "light"
  "dark"
)

xcrun simctl boot "$simulator"
xcrun simctl ui "$simulator" appearance $appearance


xcodebuild -testLanguage $language -scheme $schemeName -project $projectName -derivedDataPath '/tmp/MyProjectDerivedData/' -destination "platform=iOS

My bad—it turned out I was using my iPad in zoomed mode 🙈 and that is why there was difference in how things were displayed during the tests and on my device.

SwiftUI - geometry inconsistent on iPad simulator and real device
 
 
Q