6 ms·
Scripting in Swift
- marvel_boy 11y agoI usually use bash or ruby to do scripting, but I think is a good idea to use the power of Swift to this task.
- timanglade 11y agoYeah, I’m actually surprised Apple hasn’t made a play for this from day 1 since developing iOS/OS X often leads to writing/maintaining a bunch of home-made or 3rd-party scripts (usually in Ruby), making app development require not only knowing Objective-C & Cocoa but also some scripting language. After all if Swift is all about making it easier for more people to build apps more easily, this seems like a worthwhile use-case to go after.
- coldtea 11y ago>Yeah, I’m actually surprised Apple hasn’t made a play for this from day 1 since developing iOS/OS X often leads to writing/maintaining a bunch of home-made or 3rd-party scripts (usually in Ruby), making app development require not only knowing Objective-C & Cocoa but also some scripting language. Define "often". Besides, Swift wasn't even that ready for application develoment from day 1.
- timanglade 11y agoI actually can’t recall the last time I looked at an iOS app that didn’t use a build script, Rakefile or Cocoapods/Carthage (the latter of which is mostly written in Swift, it should be noted). It’s true that Apple has to prioritize though!
- zw 11y agoThe Swift standard library is not yet up to snuff for that, you still need to know Cocoa to do basically anything high-level. Thankfully I know Foundation better than I do straight-up POSIX, so that's tenable for me, but it's not for most people who want something script-y.
- tempodox 11y agoNot only that, but you also need to know the hocus pocus to bridge between (Obj)C and Swift. And let's not forget that the Cocoa header files are browsable, thus enabling “discoverability”, while Swift is completely obscure in that respect.
- seivan 11y agoI recently used someones template tool to generate some methods in Swift but with some erb-like syntax to actual Swift code. It was actually more pleasant than I thought, and I usually use Ruby for this. Might do this more often in the future. But Ruby still has the benefit with gem install that can get you anything from a twitter client to an IRC-bot lib.
- melling 11y agoEarlier this year, I read a couple Swift scripting blogs and decided to create a script to generate my Go data structure for my little Swift "search engine": http://www.h4labs.com/dev/ios/swift.html http://www.h4labs.com/dev/ios/swift.html Here's the script that generates the Go data structure: https://github.com/melling/SwiftResources/blob/master/bin/gen_go_var.sh https://github.com/melling/SwiftResources/blob/master/bin/ge... Simply having a few scripts makes it easier to update my site. Btw, here are the other blogs: https://medium.com/swift-programming/1-learn-swift-by-running-scripts-73fdf8507f4b https://medium.com/swift-programming/1-learn-swift-by-runnin... http://www.strathweb.com/2014/06/using-swift-general-purpose-scripting-language/ http://www.strathweb.com/2014/06/using-swift-general-purpose... http://cocoaheads.tv/scripting-with-swift-by-blake-merryman/ http://cocoaheads.tv/scripting-with-swift-by-blake-merryman/
- tkubacki 11y agoWill Apple ship Swift as OS on Linux this year as they promised ?
- Redoubts 11y agoProbably? This article doesn't address that one way or the other.
- Someone 11y agoI expect a Linux port to be made available, but did they actually promise that? From what I can tell, they promised the open source part, and announced their intention to have ports to OS X, iOS and Linux (https://developer.apple.com/swift/blog/?id=29 https://developer.apple.com/swift/blog/?id=29)
- evanriley 11y agoConsidering I've seen this said multiple times in Swift post on HN, I have to ask, why do you keep asking? From what I can remember they said It would be there by Fall...its clearly not fall yet, so why the impatience?
- dottrap 11y agoBased on prior Apple behavior, they will first ship iOS and OS X, and then they do all their open source drops after the releases. Presumably, new iOS and OS X will ship this fall, so the open source drops will come soon after. Hopefully fall, but winter at the latest.
- MrGando 11y agoIMHO This is a pretty bad idea right now... I just had to port a swift "scripting" project to Python a month ago.
- lmedinas 11y agoWhy?
- MrGando 11y agoBecause if you're scripting something out, it's very possible that you'll need to run it outside of a Mac in no time. Plus, there's no decent dependency management yet and you can't compare the amount of external libraries commonly used for scripting with languages like Python or Ruby. Scripting out with Swift sounds to me like the usual "Playing with new & Shiny". Which can be OK if you're just playing around, but I wouldn't do it with anything related to a production environment yet.
- deleted 11y ago[deleted]
- lazerwalker 11y ago> there's no decent dependency management yet What's wrong with CocoaPods?
- MrGando 11y agoWell that depends on the point of view, if you're okay with Cocoapods being designed to modify your Xcode project, etc etc. That should be fine. Again, all of this is a pretty big overhead to just 'script out' something.
- K0nserv 11y agoThe Xcode project integration is optional and can be disabled by passing --no-integrate to the install. Like so pod install --no-integrate
- mdevere 11y agoCool to see Swift being used outside of XCode
- tempodox 11y agoThis is nice, however I'm skeptical as to the virtues of video as a presentation format for this kind of content. I'd have vastly preferred a written document.
- LewisJEllis 11y agoI'm not sure what you're expecting here. This was a conference talk, then someone recorded it and made a transcript. It's not like someone thought, "I'm going to present this content using video instead of writing it," and then recorded themselves talking to their camera.
- timanglade 11y agoAgreed! There is a full, edited transcript right below the video. Realm actually takes the time to rewrite every video it publishes blogpost-style so it’s shorter and easier to read if you’re not much into videos.