From the symptoms, it looks like the compiler is not holding onto "background" 
because it is no longer used.  That's a desirable thing to do for optimized 
code, but not at -O0.

What happens if you rewrite this to:

                let background = sceneView.snapshot().cgImage!
                let cropped = background.cropping(to: overlayView.frame)
                UIGraphicsBeginImageContextWithOptions(overlayView.frame.size, 
false, 1.0)
                print(background)

When you step to the UIGraphics... line, are you still able to print the 
variable?  If so, that's quite likely what is going on, and it would be great 
if you could file a bug about this.

Jim



> On Jan 31, 2017, at 10:54 AM, Maury Markowitz via swift-users 
> <swift-users@swift.org> wrote:
> 
> I hope this is the right place to ask this:
> 
> I'm using Xcode Version 8.2.1 (8C1002) and I'm trying to find out what's 
> going wrong in my Swift3 app. Here's the code:
> 
>               let background = sceneView.snapshot().cgImage!
>               let cropped = background.cropping(to: overlayView.frame)
>               UIGraphicsBeginImageContextWithOptions(overlayView.frame.size, 
> false, 1.0)
> 
> I have a breakpoint on the first line. When it trips I F6 to the next line 
> and examine background:
> 
> (lldb) p background
> (CGImage) $R0 = 0x00000001741d4370 {}
> Printing description of background:
> <CGImage 0x1741d4370>
>       <<CGColorSpace 0x170024480> (kCGColorSpaceICCBased; 
> kCGColorSpaceModelRGB; sRGB IEC61966-2.1)>
>               width = 640, height = 998, bpc = 8, bpp = 32, row bytes = 2560 
> 
> Now I hit F6 again and do the same thing:
> 
> (lldb) p background
> error: <EXPR>:3:1: error: use of unresolved identifier 'background'
> background
> ^~~~~~~~~~
> 
> This happens to pretty much every variable in the app, after running another 
> line or two, it apparently disappears. This is particularly annoying in this 
> case, because QuickLook fails almost every time, which makes debugging image 
> work somewhat difficult.
> 
> I've cleaned and rebooted and it keeps coming back. Any suggestions?
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to