Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
ricardopereira / carthage-filelist.swift
Last active July 7, 2019 13:53
Generate Input and Output Filelist to use in projects with Carthage frameworks
#!/usr/bin/swift sh
import Foundation
import Path // mxcl/Path.swift ~> 0.16
print("Current Directory:", Path.cwd)
extension Array where Element == Entry {
var frameworks: [Path] {
return directories.frameworks
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
SUPPORTED_PLATFORMS = iphoneos macosx appletvos watchos iphonesimulator appletvsimulator watchsimulator
SWIFT_VERSION = 4.2
IPHONEOS_DEPLOYMENT_TARGET = 9.0
MACOSX_DEPLOYMENT_TARGET = 10.11
@ricardopereira
ricardopereira / .gitignore
Created October 30, 2018 00:38 — forked from pepasflo/.gitignore
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
@ricardopereira
ricardopereira / spm
Created August 27, 2018 09:32 — forked from JohnSundell/spm
A script that makes it easier to use the Swift Package Manager by making common commands less verbose 👍
#!/usr/bin/env bash
# Put this file in /usr/local/bin and then run chmod +x on it to make it executable
command=$1
shift
case $command in
"init" )
swift package init "$@"
@ricardopereira
ricardopereira / appstore-screens-Package.swift
Last active August 20, 2018 22:35
Download AppStore high res app screens
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "appstore-screens",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
@ricardopereira
ricardopereira / UIAlertController+TextField.swift
Created August 14, 2018 22:27 — forked from ole/UIAlertController+TextField.swift
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@ricardopereira
ricardopereira / TestCase.swift
Created August 14, 2018 22:09 — forked from DivineDominion/TestCase.swift
Bridging XCTAssertThrows to Swift to catch exceptions. (Doesn't work with assert(), though)
class ExceptionTestCase: XCTestCase {
func raisesException() {
var exception = NSException(name: NSInternalInconsistencyException, reason: "Testing exceptions", userInfo: nil)
XCTAssertThrows({ exception.raise() })
XCTAssertThrowsSpecific({ exception.raise() }, NSInternalInconsistencyException, "Should raise NSInternalInconsistencyException")
}
}
simulatorsIdentifiers=$(instruments -s devices |
grep -o "iPhone .* (.*) \[.*\]" | #only iPhone
grep -o "\[.*\]" | #only UUID
sed "s/^\[\(.*\)\]$/\1/" | #remove square brackets
sed 's/^/"/;$!s/$/"/;$s/$/"/' | #add quotes
sed '$!s/$/,/' #add comma to separate each element
)
arrayOfSimulatorsIdentifiers=($(echo "$simulatorsIdentifiers" | tr ',' '\n'))
@ricardopereira
ricardopereira / DebuggingObjCBlocks.lldbinit
Last active June 13, 2018 02:02 — forked from mayoff/!README.md
Debugging Objective-C blocks in lldb
command script import ~/pblock.py