4

In my application i am using the below code to show an animated splash screen. App working fine in Xcode-6.4(iOS 8), but coming to Xcode-7GM version(iOS9) app crashes with an error.

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];
    // Build array of images, cycling through image names
    for (int i = 1; i <= IMAGE_COUNT; i++)
     [imageArray addObject:[UIImage imageNamed:
                               [NSString stringWithFormat:@"image__%d.png",i]]];
    animationImageView  = [[UIImageView alloc]  initWithFrame:self.window.bounds];
    animationImageView  .animationImages=[NSArray arrayWithArray:imageArray];
    // One cycle through all the images takes 3.5 seconds
    animationImageView .animationDuration = 3.5;
    // Repeat forever
    animationImageView  .animationRepeatCount = 0;
    // Add subview and make window visible
    [window addSubview:animationImageView  ];
    [window makeKeyAndVisible];
    // Start it up animations
    [animationImageView   startAnimating];
    // Wait 3.5 seconds, then stop animation
   [self performSelector:@selector(stopAnimation) withObject:nil afterDelay:3.5];`

This is the error message what i am getting while using Xcode-7GM:

Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294

narendrakumar b
  • 115
  • 1
  • 12
  • 1
    That is not the _whole_ error message. There was an assertion failure. What _is_ the assertion failure? – matt Sep 12 '15 at 12:45
  • 1
    This is the whole error message i seen in the log : 2015-09-14 10:11:59.073 appname[721:11491] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) 2015-09-14 10:11:59.441 appname[721:11367] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294 – narendrakumar b Sep 14 '15 at 04:59
  • Really? It says "assertion failure" but it doesn't tell you what the assertion _is_ (no assertion message)? That is very odd. However, it sounds, from `kCFStreamErrorDomainSSL`, like the problem has to do with networking. Are you doing some sort of networking during launch? (Bad idea.) And did you remember that in iOS 9, by default, you can only do `https:`? – matt Sep 14 '15 at 14:52
  • i also get this error :-"Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294" how to solve this error – Akash Raghani Sep 22 '15 at 06:28

6 Answers6

11

    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

change to


    [window setFrame:[[UIScreen mainScreen] bounds]];

user1404596
  • 138
  • 1
  • 5
1

It sounds like you're trying to do some networking. In iOS 9, by default, all network communication must be secure. If you are trying to do an http: request, it will fail; you must use https: (unless you switch this feature off in your Info.plist).

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

I had the same issue, it has been solved by removing [window makeKeyAndVisible];.

The self window needs to be set as root view controller in your didFinishLaunchingWithOptions: :
[self.window setRootViewController:navController];

JonMo
  • 1
  • 2
0

For me like jonmo, this error was the result of not defining rootViewController prior to exiting didFinishLaunchingWithOptions.

Doing so resolved this issue for me.

Prior to Xcode 7, it was just a warning now it seems to be a hard stop

Craig
  • 344
  • 4
  • 9
0

In my case, the solution to this error message was updating an included CocoaPods dependency called Loopback (that I believe adds an extra UIWindow to the app.)

race_carr
  • 1,387
  • 12
  • 21
0

I had the same issue, It has been solved by replacing the below line of code in Appdelegate.m

[window addSubview:viewController.view];

with

[window setRootViewController:viewController];
arunjos007
  • 4,105
  • 1
  • 28
  • 43