This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM swift:4 | |
| WORKDIR /build | |
| COPY Sources ./Sources | |
| COPY Package.swift . | |
| RUN swift package resolve | |
| RUN swift build | |
| COPY pkg-swift-deps.sh /usr/bin/pkg-swift-deps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BIN="$1" | |
| OUTPUT_TAR="${2:-swift_libs.tar.gz}" | |
| TAR_FLAGS="hczvf" | |
| DEPS=$(ldd $BIN | awk 'BEGIN{ORS=" "}$1\ | |
| ~/^\//{print $1}$3~/^\//{print $3}'\ | |
| | sed 's/,$/\n/') | |
| tar $TAR_FLAGS $OUTPUT_TAR $DEPS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let updateTimeLabel = SKAction.customAction(withDuration: 5) { | |
| (node, elapsedTime) in | |
| if let label = node as? SKLabelNode { | |
| label.text = "\(elapsedTime)s" | |
| } | |
| } | |
| let timeLabel = SKLabelNode(fontNamed: "Chalkduster") | |
| timeLabel.text = "0s" | |
| timeLabel.run(updateTimeLabel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let coin = SKSpriteNode(imageNamed: "coin.png") | |
| let animate = SKAction.rotate(byAngle: π/2, duration: 0.75) | |
| let updateScore = SKAction.run { | |
| scoreValue += 10 | |
| } | |
| let sequence = SKAction.sequence([animate, updateScore]) | |
| coin.run(sequence) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
| let player = SKSpriteNode(imageNamed: "player.png") | |
| let moveFiveTimes = SKAction.repeat(moveAction, count: 5) | |
| player.run(moveFiveTimes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
| let rotateAction = SKAction.rotate(byAngle: π, duration: 0.5) | |
| let moveAndRotate = SKAction.group([moveAction, rotateAction]) | |
| let player = SKSpriteNode(imageNamed: "player.png") | |
| player.run(moveAndRotate) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
| let player = SKSpriteNode(imageNamed: "player.png") | |
| player.run(moveAction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func giveMeAStringMaybe(_ maybe: Bool) -> String? { | |
| return maybe ? "Yes!" : nil | |
| } | |
| let str1: String? = giveMeAStringMaybe(true) | |
| let lowercaseStr1: String? = str1?.lowercased() | |
| print(lowercaseStr2) // prints: "yes!" | |
| let str2: String? = giveMeAStringMaybe(false) | |
| let lowercaseStr2: String? = str2?.lowercased() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func giveMeAStringMaybe(_ maybe: Bool) -> String? { | |
| return maybe ? "Yes!" : nil | |
| } | |
| let str: String? = giveMeAStringMaybe(true) | |
| guard let unwrappedStr = str else { | |
| print("str is nil") | |
| // unwrappedStr is NOT accessible here | |
| return | |
| } |
NewerOlder