Update: I am using XCode 7 Beta with Swift 2.0
When I try to run my app on an iPhone I get these 3 errors:
<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
When I enable to CG_CONTEXT_SHOW_BACKTRACE variable I get this:
Backtrace:
<<redacted>+40>
<<redacted>+432>
<<redacted>+144>
<<redacted>+172>
<<redacted>+332>
<<redacted>+112>
<<redacted>+820>
<<redacted>+688>
<<redacted>+356>
<<redacted>+80>
<<redacted>+808>
<<redacted>+344>
<<redacted>+420>
<<redacted>+104>
<<redacted>+284>
<<redacted>+556>
<<redacted>+504>
<<redacted>+1792>
<<redacted>+220>
<<redacted>+284>
<<redacted>+920>
<<redacted>+168>
<<redacted>+184>
<<redacted>+56>
<<redacted>+24>
<<redacted>+540>
<<redacted>+724>
<CFRunLoopRunSpecific+384>
<<redacted>+460>
<UIApplicationMain+204>
<main+164>
I'm not sure how to interpret this, I am not using any CoreGraphics content in my code, and the other similar questions had answers that did not work for me. I understand it can be difficult to help debug without code, but I can't figure out what code is related to this, so if anyone has an idea I can post more code.
From my experimentation, this seems to be due to defining UIViewControllerBasedStatusBarAppearance
in Info.plist
.
It happens on iOS 9 (beta & GM) but not on 8.4.
At @JimRota's suggestion, moving this into an answer, since it was deemed helpful:
Had this still in XCode 7 GM, iOS9 GM. But, check it out: Set UIViewControllerBasedStatusBarAppearance
to YES (even though the status bar is hidden, which is why I set it to NO to begin with), and the warnings go away. Crazy!
I then had to add this to my view controllers to keep the status bar hidden:
- (BOOL) prefersStatusBarHidden
{
return YES;
}
For me, all my VCs actually inherit from the ProjectNameViewController
, so that simplified it a bit.
im getting the same thing on the xcode 7 GM release, i think ill simply ignore them since everything works but its pretty annoying even though they have admitted its a bug and just didnt fix it yet. Dev Forum Posting
from comments given above , this is the real way to fix :
UIViewControllerBasedStatusBarAppearance to YES in Info.plist
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With