Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgrebenets/swiftscriptrunner
Swift Script Runner
https://github.com/mgrebenets/swiftscriptrunner
Last synced: about 2 months ago
JSON representation
Swift Script Runner
- Host: GitHub
- URL: https://github.com/mgrebenets/swiftscriptrunner
- Owner: mgrebenets
- License: mit
- Created: 2015-10-06T12:12:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T03:16:02.000Z (almost 7 years ago)
- Last Synced: 2024-10-28T12:55:12.419Z (about 2 months ago)
- Language: Ruby
- Size: 1.31 MB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftScriptRunner
[![CI Status](http://img.shields.io/travis/mgrebenets/SwiftScriptRunner.svg?style=flat)](https://travis-ci.org/mgrebenets/SwiftScriptRunner)
[![Version](https://img.shields.io/cocoapods/v/SwiftScriptRunner.svg?style=flat)](http://cocoapods.org/pods/SwiftScriptRunner)
[![License](https://img.shields.io/cocoapods/l/SwiftScriptRunner.svg?style=flat)](http://cocoapods.org/pods/SwiftScriptRunner)
[![Platform](https://img.shields.io/cocoapods/p/SwiftScriptRunner.svg?style=flat)](http://cocoapods.org/pods/SwiftScriptRunner)A simple utility for writing Swift scripts with async callbacks to 3rd party frameworks.
See [this blog post](http://mgrebenets.github.io/swift/2015/10/08/async-swift-scripting/) for more details.
## Requirements
- Xcode 9.2
- cocoapods gem version 1.4.0
- [cocoapods-rome](https://github.com/neonichu/Rome) gem version 0.8.0
- carthage version 0.28.0## Installation
SwiftScriptRunner is available through [CocoaPods Rome](https://github.com/neonichu/Rome) and [Carthage](https://github.com/Carthage/Carthage).
### CocoaPods Rome
Make sure you have [cocoapods-rome](https://github.com/neonichu/Rome) Ruby gem installed.
Add the following line to your `Podfile`:
```ruby
platform :osx, "10.10"
use_frameworks!
plugin "cocoapods-rome"pod "SwiftScriptRunner", "~> 1.0.1"
```And run
```bash
pod install
```### Carthage
Add the following line to your `Cartfile`:
```ruby
github "mgrebenets/SwiftScriptRunner", ~> 1.0.1
```And run
```bash
carthage update --platform mac
```### Swift Package Manager
_TODO:_
## Usage
Example of asynchronous network request using [Alamofire](https://github.com/Alamofire/Alamofire).
```swift
// Shebangs for using with different dependency managers.
//
// - Carthage:
// #!/usr/bin/env xcrun swift -F Carthage/Build/Mac
// - CocoaPods Rome:
// #!/usr/bin/env xcrun swift -F Rome
// - Swift Package Manager:// Example.swift
import Alamofire
import SwiftScriptRunnervar runner = SwiftScriptRunner()
runner.lock() // LockAlamofire.request("http://httpbin.org/get")
.responseJSON { response in
print("Successful response:")
print(response) // Result of response serialization
runner.unlock() // Unlock
}runner.wait() // Wait
```Now you can run it.
```bash
# When using CocoaPods
swift -F Rome Example.swift# When using Carthage
swift -F Carthage/Build/Mac Example.swift# When -F option is part of shebang and Example.swift is executable
./Example.swift
```See `Examples` folder for details.
## Author
Maksym Grebenets, [email protected], [@mgrebenets](https://twitter.com/mgrebenets)
## License
SwiftScriptRunner is available under the MIT license. See the LICENSE file for more info.