Example code and package settings for IBM Swift Sandbox
using 3’d party packages like SwiftyJson
.
IBM Swift Sandbox
で SwiftyJson
のようなサードパーティのパッケージ(ライブラリ)を使用するサンプルです。
Access the following link and then execute it.
Note: Do not change value of gitPackage
and swiftVersion
parameters.
A simple code and settings that shows how to use 3'd party packages.
Sources/main.swift
import Foundation
import SwiftyJSON
func JSONExample() {
let json = JSON(["name":"naokits", "age": 50])
if let name = json["name"].string {
print(name)
}
if let age = json["age"].int {
print(age)
}
}
...
.swift-version
DEVELOPMENT-SNAPSHOT-2016-05-09-a
packages.swift
import PackageDescription
let package = Package(
name: "examples-for-ibm-swift-sandbox",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", majorVersion: 8),
.Package(url: "https://github.com/IBM-Swift/BlueCryptor.git", majorVersion: 0, minor: 2),
.Package(url: "https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 0, minor: 9),
]
)
In this case, latest version of each packages works with the DEVELOPMENT-SNAPSHOT-2016-05-09-a
version of the Swift binaries. Compatibility with other Swift versions is not guaranteed.