Skip to content

Instantly share code, notes, and snippets.

@tanb
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanb/704f4f663d2e68e410df to your computer and use it in GitHub Desktop.
Save tanb/704f4f663d2e68e410df to your computer and use it in GitHub Desktop.
flymake - swift
(when (require 'flymake nil 'noerror)
;; ignore syntax check error http://d.hatena.ne.jp/sugyan/20100705/1278306885
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
;; swift
(defvar swift-sdk-path "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk")
(defvar swift-configure-target "i386-apple-ios8.1")
(defun flymake-swift-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name temp-file
(file-name-directory buffer-file-name))))
(list "swiftc" (list "-sdk" swift-sdk-path
"-parse"
"-DDEBUG=1"
"-target" swift-configure-target
local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.swift\\'" flymake-swift-init))
(add-hook 'swift-mode-hook
'(lambda () (flymake-mode t)))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment