Although (to my knowledge) not documented, a launch argument can be used to define the initial Dynamic Type setting.
Key: UIPreferredContentSizeCategoryName
Value: One of the below
UICTContentSizeCategoryXS
UICTContentSizeCategoryS
UICTContentSizeCategoryM
UICTContentSizeCategoryL
UICTContentSizeCategoryXL
UICTContentSizeCategoryXXL
UICTContentSizeCategoryXXXL
UICTContentSizeCategoryAccessibilityM
UICTContentSizeCategoryAccessibilityL
UICTContentSizeCategoryAccessibilityXL
UICTContentSizeCategoryAccessibilityXXL
UICTContentSizeCategoryAccessibilityXXXL
Source of this undocumented key/values: GitHub.
A convenient way to do so is to add a launch argument to an Xcode scheme (add for example -UIPreferredContentSizeCategoryName UICTContentSizeCategoryXL
under Arguments Passed On Launch), and this setting will apply when you run the app in Xcode. You can create multiple schemes with different Dynamic Type settings to switch between them.
If the purpose is creating screenshots using Fastlane Snapshot, the equivalent code is as follows:
app.launchArguments += [ "-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryXL" ]
app.launch()