2

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.

Community
  • 1
  • 1
Johnston
  • 20,196
  • 18
  • 72
  • 121
  • @rob-mayoff This is not a duplicate of that question. I can import UIKit and Foundation without error. It is the use of UIGraphics that causes an error. And specifically an LLVM error. Completely different question. – Johnston Oct 29 '15 at 17:23
  • 1
    Actually... the compiler doesn't yell when you import UIKit *but* it will fail as soon as you will try to use an UIKit object. Your `print` works because it comes from Foundation but anything UIKit won't work because it's specific to iOS SDK and it's not compatible -yet?- with the repl. – Eric Aya Oct 29 '15 at 17:47
  • 1
    @EricD. You are right this is a dup. – Johnston Oct 29 '15 at 17:59

0 Answers0