问题 TL;DR: In legacy Obj-C code, the color space param value was NULL . That is not allowed in the Swift equivalent. What value to use? I have inherited code that reads: unsigned char pixel[1] = {0}; CGContextRef context = CGBitmapContextCreate( pixel,1, 1, 8, 1, NULL, (CGBitmapInfo)kCGImageAlphaOnly ); The port to Swift 4 CGContext is straightforward, except for that NULL color space value. Using a plausible value, I am getting nil back from CGContext.init?() . My translation is: var pixelValue