Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default path for swiftc without using xcrun -sdk macosx

Tags:

xcode

swift

Yosemite 10.10.3:

import Foundation
println("Hello, World")

swiftc -o out in.swift, results in:

error: cannot load underlying module for 'CoreGraphics' on my desktop, but compiles and runs on my laptop. The environment variable SDKROOT is not set on either machine. I do not know why this code will compile on my laptop but not on my desktop. Obviously something has been set to allow swiftc to find the module 'CoreGraphics' on my laptop but not on my desktop.

xcrun -sdk macosx swiftc -o out in.swift will allow the code to compile on the desktop. I have been asked to explain why it is important that I be able to run the former and why I cannot just run the latter and forget about it; I don't have an answer other than my own curiosity to understand how and why things work so that I can gain mastery over my computer and not vice versa. Besides that, it is quite a bit shorter to type.

like image 604
Pinecone Avatar asked Nov 17 '25 18:11

Pinecone


1 Answers

Not really an answer, but you can of course save yourself the typing by adding this alias to your ~/.bashrc

alias sc='xcrun -sdk macosx swiftc'
like image 183
Phantrast Avatar answered Nov 19 '25 10:11

Phantrast



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!