I apologise for the incompleteness of this answer, but it is too long for a comment and there would not be any code formatting.
The short answer is, this is not supported: https://forums.developer.apple.com/thread/21503 , but it probably warrants a radar.
The longer answer is, you might be able to hack something together. The setting for dynamic type in the simulator is available on your filesystem at: ~/Library/Developer/CoreSimulator/Devices/<device identifier>/data/Library/Preferences/com.apple.UIKit.plist
. You can programmatically get the path to the simulator filesystem from inside an XCTest
using:
let environment = NSProcessInfo.processInfo().environment
if let resourcesDir = environment[ "SIMULATOR_SHARED_RESOURCES_DIRECTORY" ]
{
print( "-- Simulator Shared Resources Directory: \(resourcesDir)" )
let dictionary = NSMutableDictionary( contentsOfFile: "\(resourcesDir)/data/Library/Preferences/com.apple.UIKit.plist" )!
print( "Dictionary: \(dictionary)" )
}
However, the test is sandboxed from the simulator directory, so you cannot actually open or modify the preferences. That code snippet fails when trying to unwrap the dictionary. I also never tried this with Xcode Server.
You could modify the plist using with a shell script like so: plutil -replace UIPreferredContentSizeCategoryName -string UICTContentSizeCategoryAccessibilityXXXL com.apple.UIKit.plist
. The simulator needs to restart after you modify the file so this may not fly in a shared build environment. Unfortunately, the path to the simulator's filesystem is not available to Pre-action scripts in Xcode. You could modify the setting for all the simulators, but again, might not fly in a shared build environment.
At the end of the day, you might be better off creating your DynamicTypeController
and adding some process to ensure no one uses UIApplication.preferredContentSizeCategory
.
This was all tested using Xcode 7.1 (7B91b).