Latest 1.0.1
Homepage https://github.com/mgrebenets/SwiftScriptRunner
License MIT
Platforms osx 10.10, requires ARC
Frameworks Foundation
Authors

CI Status
Version
License
Platform

A simple utility for writing Swift scripts with async callbacks to 3rd party frameworks.

See this blog post for more details.

Requirements

  • Xcode 9.2
  • cocoapods gem version 1.4.0
  • cocoapods-rome gem version 0.8.0
  • carthage version 0.28.0

Installation

SwiftScriptRunner is available through CocoaPods Rome and Carthage.

CocoaPods Rome

Make sure you have cocoapods-rome Ruby gem installed.

Add the following line to your Podfile:

platform :osx, "10.10"
use_frameworks!
plugin "cocoapods-rome"

pod "SwiftScriptRunner", "~> 1.0.1"

And run

pod install

Carthage

Add the following line to your Cartfile:

github "mgrebenets/SwiftScriptRunner", ~> 1.0.1

And run

carthage update --platform mac

Swift Package Manager

TODO:

Usage

Example of asynchronous network request using Alamofire.

// 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 SwiftScriptRunner

var runner = SwiftScriptRunner()
runner.lock() // Lock

Alamofire.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.

# 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

License

SwiftScriptRunner is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftScriptRunner",
    "version": "1.0.1",
    "summary": "A helper class for running Swift scripts with asynchronous callbacks.",
    "description": "A helper class for running Swift scripts with asynchronous callbacks.n * Initialize runner, lock before each async call and unlock once it's done.n * Wait for all locks to unlock at the end of the script.",
    "homepage": "https://github.com/mgrebenets/SwiftScriptRunner",
    "license": "MIT",
    "authors": {
        "Maksym Grebenets": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mgrebenets/SwiftScriptRunner.git",
        "tag": "1.0.1"
    },
    "social_media_url": "https://twitter.com/mgrebenets",
    "platforms": {
        "osx": "10.10"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This