`CGImage` APIs cannot be used from playgrounds

Originator:jeff
Number:rdar://17409431 Date Originated:06.21.2014
Status:Closed Resolved:08.06.2014
Product:Developer Tools Product Version:Xcode 6 Beta 2 (6A216f)
Classification:Serious Bug Reproducible:Always
 
Summary:
APIs like `CGImageGetWidth` cannot be used from playgrounds without triggering fatal errors.

Steps to Reproduce:
1. Create a new playground.
2. Paste the following code:

let url = NSURL(string: "http://www.comehike.com/img/hiking_photos/swift.jpg")
let imageData = NSData(contentsOfURL: url)
let image = UIImage(data: imageData)
let width = CGImageGetWidth(image.CGImage)

Expected Results:
To the right of the last line should be shown "300", the width of the image.

Actual Results:
The console output shows

fatal error: Can't unwrap Optional.None
Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

followed by a backtrace.

Version:
Xcode 6 Beta 2 (6A216f)

Notes:
This code works just fine from a Swift project, just not in the playground.

Configuration:


Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!