How to Use Swift Repl with iOS Sdk

How do I access Swift's REPL?

After installing the Xcode6 beta, do

$ sudo xcode-select -s /Applications/Xcode6-Beta.app/Contents/Developer/

$ xcrun swift

is a Swift REPL

EDITED:

For XCode 6, use:

xcrun swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk

Starting Swift REPL for iOS vs OSX

One way to do this is to create an iOS/OS X project and set a break point to interrupt the flow. Then, enter repl into the lldb console and enjoy.

For more on this one, watch WWDC 2014 session 409 - Introduction to LLDB and the Swift REPL.

repl

Can one embed the Swift REPL inside macOS or iOS app?

No. You can talk to the REPL from within Xcode while paused in your app (running from Xcode) at a breakpoint, but that's as close as you can come.

How can I use swift in Terminal?

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

then you can do one of these:

xcrun swift 
lldb --repl

As of Xcode 6.1 - typing swift in the terminal launches the REPL as well.



Related Topics



Leave a reply



Submit