When doing iOS app development, most unit test suites are fine to run on the simulator. I found myself in the situation on a current project of mine that the app I’m developing uses libraries where it can’t run on a simulator.

The problem was that on app launch, in the app delegate, there are references to these libraries and the app then crashes. No unit tests get run.

I didn’t want to start littering if else statements in my AppDelegate.

I found the easiest thing to do was add a whole new AppDelegate. I called mine SpecAppDelegate

#import "SpecsAppDelegate.h"

@implementation SpecsAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

- (void)applicationWillResignActive:(UIApplication *)application { }
- (void)applicationDidEnterBackground:(UIApplication *)application { }
- (void)applicationWillEnterForeground:(UIApplication *)application { }
- (void)applicationDidBecomeActive:(UIApplication *)application { }
- (void)applicationWillTerminate:(UIApplication *)application { }


And then use this in your main.m when you’re launching the app for unit tests.

int main(int argc, char* argv[]) {
    int returnValue;
    @autoreleasepool {
        BOOL inTests = (NSClassFromString(@"SenTestCase") != nil
                        || NSClassFromString(@"XCTest") != nil);
        if (inTests) {
            returnValue = UIApplicationMain(argc, argv, nil, @"SpecsAppDelegate");
        else {
            returnValue = UIApplicationMain(argc, argv, nil, @"AppDelegate");
    return returnValue;

Swift - Child of the LLVM

Exploring what Swift achieves on LLVM that Obj-C could not. Continue reading

Understanding The LLVM - Introduction

Published on June 18, 2017

Developing for Hardware & Visibility

Published on May 24, 2017