swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
372 stars 47 forks source link

Can't load CoreGraphics #93

Closed burbma closed 9 years ago

burbma commented 9 years ago

I've installed swift-mode as instructed and I've already been using flycheck for other languages. I added (add-to-list 'flycheck-checkers 'swift) also and the checker tries to run. I get this error, `Suspicious state from syntax checker swift: Checker swift returned non-zero exit code 1, but no errors from output: :0: error: cannot load underlying module for 'CoreGraphics

:0: note: did you forget to set an SDK using -sdk or SDKROOT? :0: note: use "xcrun -sdk macosx swift" to select the default OS X SDK installed with Xcode` I've googled around but the issue, as far as I can tell, is usually related to making scripts in swift and running them from the terminal with a solution of exporting SDKROOT in the .bash_profile. Any clues?
ap4y commented 9 years ago

Hi @mmb90, flycheck checker uses plain swift frontend, which doesn't know about platform specific modules unless -sdk is specified. You can set sdk variable for the flycheck via this variable.

burbma commented 9 years ago

I'm afraid I'm still confused, how can I set this variable? Forgive my naivety.

nicklanasa commented 9 years ago

@mmb90 I was getting the same error until I added the following to my init.el

(setq flycheck-swift-sdk-path "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/")

If you don't know your SDK path, you can find it by running this command in terminal:

xcrun --show-sdk-path
burbma commented 9 years ago

Awesome, I fixed it with this. Thanks!

(defvar flycheck-swift-sdk-path)
(setq flycheck-swift-sdk-path "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk")