Error Message in Debug Area

With every playground that runs in Xcode 7.0 beta 5, the following three errors display in the debug area:

Aug 6 13:11:50 Tour1[17353] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Aug 6 13:11:50 Tour1[17353] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Aug 6 13:11:50 Tour1[17353] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.


How do I fix this? How do I set the environmental variables and what do I set them to?

Replies

I'm facing the same problem, my app must have a light status bar, so did you fixed it in any way? If there is a solution please help me ,Thanks!!

Changing UIViewControllerBasedStatusBarAppearance (View controller-based status bar appearance) from NO to YES made the error messages go away for me. However, this also prevented my app from using the light colored status bar (statusBarStyle = .LightContent), which is needed for my app's UI. As jtca pointed out, statusBarStyle has been deprecated in iOS 9.0 but without any apparent replacement.


It is good to know that we can ignore these warnings, as JackL said. But I did file bug report number 22752045. Hopefully this gets fixed.

Hello,

none of the above suggestions helped me.



In my info.plist I have nothing related to "UIViewControllerBasedStatusBarAppearance" and only use standard font (but I change the color of a text).



Anyone else have any suggestions?



Come to know whether DST engineers are now analyzing this issue, since even the previous version of Xcode and the iOS 8.4 was all working well?

I'm not running playgrounds and I have the same problem with the released version of xcode 7

This is happening for me in Playgrounds, as it was for the person who made the original post.


Does the info.plist file affect the Playgrounds?


I didn't think so--and if not, altering it won't make the bug go away.

any solution?

Same problem with xcode Version 7.0 (7A220)


any solution?

Just as a heads up, it's also occurring on my mac running Xcode 7.0.1 (7A1001) in story board mode--even with just one line for a variable.

Try:

override func viewWillAppear(animated: Bool) {
        UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: true)
    }

Any update on the bug report?

I also have the problem in xcode 7.0.1

I can confirm that this is still happening in Xcode 7.0.1 (7A1001). I've got a Workspace containing a couple of frameworks and half a dozen playgrounds. All of the code is targeting iOS 9. Interestingly, the <Error>: CGContextSaveGState error shows as coming from an object from one of my frameworks. Neither the framework nor the playground import UIKit. They all just import Foundation.

Me too!

So JackL,

I am getting a whole set of errors as well. Are you suggesting to ignore them? Here are the error messages I am getting in the console:


Oct 11 09:25:19 Variables2[5116] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Oct 11 09:25:19 Variables2[5116] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Oct 11 09:25:19 Variables2[5116] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

The high for New York is 42 degrees celcius


A simple code I am trying out on Xcode Playground


import UIKit
func cityTemperature (city:String, temp:Int) {
/
    print ("The high for \(city) is \(temp) degrees celcius")
}
cityTemperature("New York", temp: 42)

So, where is this, please? I am attempting to use playgrounds to learn Swift coding, and this prevents me running code, and makes it quite difficult to use online tutorials to learn Swift. Looks like the problem is that playgrounds don't give you access to the Info.plist, whereas a full project gives you access to all of the files used in the project, and you can edit the Info.plist file to fix it. If this is a known issue, please fix it.