I am running Swift through the command line:
xcrun swift -sdk $(xcrun --show-sdk-path --sdk iphonesimulator --find clang) -
Then I am passing in
import UIKit
UIGraphicsBeginImageContextWithOptions(CGSizeMake(500, 500), false, 0.0)
UIColor.blackColor().setStroke()
let path = UIBezierPath()
path.moveToPoint(CGPointMake(100, 0))
// some path stuff...
path.dynamicType
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
The compiler is returning:
LLVM ERROR: Program used external function '_UIGraphicsEndImageContext' which could not be resolved!
Is there a way that I can run this and include the needed libraries to run UIGraphicsGetImageFromCurrentImageContext()
?
I tried finding the way to include other libraries but I thought that this method would be included in UIKit.
EDIT
I tried adding in frameworks to the command but I am not sure what framework I'd need to add. I tried the following.
xcrun swift -v -F /Applications/Xcode.app/Contents/SharedFrameworks -F /Applications/Xcode.app/Contents/OtherFrameworks -F /Applications/Xcode.app/Contents/Frameworks -sdk $(xcrun --show-sdk-path --sdk iphonesimulator --find clang)
This did not work either.
NOT A DUPLICATE
This is not a duplicate of this question because this is able to import UIKit
and Foundation
. If you write the following code for the REPL it works:
import Foundation
import UIKit
print("works")
In that case it does not throw errors. I also posted an answer there which works.