user12758279
user12758279

Reputation: 75

How to test layout in 3.5 screen size specifically iPhone 4s in Xcode 11.3.1?

I really need to test the layout of my app in 3.5 screen size specifically iPhone 4s using Xcode 11.3.1 but unfortunately iPhone 4s is not available. I have Xcode 11.3.1 with Mac OS Catalina which I believe that adding 9.0 simulator is impossible with the specification of my macOS. I tried to download iPhoneSimulatorSDK9.3 and iPhoneSimulatorSDK9.0 but it did not work. The image below is what I got when trying to install. Is there any way you can help me? Is there any way I can test my app in 3.5 screen size in xcode 11.3.1? Please help me. Thank you

error message

Upvotes: 0

Views: 252

Answers (2)

mrzzmr
mrzzmr

Reputation: 903

Rafiki's solution works great. Here it is in Objective C:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    @synthesize window;
    …
    UIStoryboard* iPhoneStoryboard = [UIStoryboard storyboardWithName:@"StoryboardFor35inch" bundle:nil];
    UIViewController* initialViewController = [iPhoneStoryboard instantiateInitialViewController];
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    window.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
   …
}

Upvotes: 0

Rafiki
Rafiki

Reputation: 11

There is one possibility using window frame. You can set window size when app is running. I recommend run simulator for iPhone SE device config and then use this special code only for testing.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
/// Only for testing iphone 3.5in screen on iphone SE simulator
 window?.frame = CGRect(x: 0, y: 0, width: 320.0, height: 480.0)

...
}

Upvotes: 1

Related Questions