This is a reference of all the useful links to follow my UIKonf'17 talk on Code Generation in Swift
- Slides on SpeakerDeck
- Keynote Live URL
- All the other files in this GIST contains the code snippets I used in my slides, referenced by slide number.
// When you are in the diff page of a GitHub PR | |
// And want to hide all the Pods/* files in that diff page, use this: | |
// Paste that in your Web Inspector's console | |
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ); | |
for(i=0; i<nodes.snapshotLength; ++i) { | |
nodes.snapshotItem(i).parentNode.hidden = true | |
} | |
// Or even better, create a bookmark with this code for easy quick access: |
This is a reference of all the useful links to follow my UIKonf'17 talk on Code Generation in Swift
This proposal enhances protocol safety at compile time by incorporating role keywords to discourage two categories of potential user errors. This proposal can be phased in first over time and language release.
func json(from dict: [String: Any]) -> String { | |
let jsonData = try! JSONSerialization.data(withJSONObject: dict, options: []) | |
let str = String(data: jsonData, encoding: .utf8)! | |
return str | |
} | |
struct Product { | |
var price: Double | |
var quantity: Int |
#!/bin/bash | |
##### | |
# | |
# git-gerrit v1.1 | |
# O. Halligon, 2017.08.18 | |
# | |
##### | |
# | |
# Usage: | |
# |
import Foundation | |
//: ## Option 1: A Failable type for each item | |
//: In practice, it's very similar to the concept of the "Result" type that you see in most code bases (and that will be integrated in Swift 5), so if you already have a Result type, you might just want to use it instead, but if not, this is a super-simplification of it | |
enum Failable<T>: CustomStringConvertible { | |
case success(T) | |
case failure(Error) | |
var description: String { |
#!/usr/bin/env ruby | |
require 'tmpdir' | |
require 'open3' | |
# The first parameter is supposed to be the path to the markdown file | |
input_file = ARGV.first | |
config_file = ARGV[1] || '.swiftlint.yml' | |
config_param = File.exist?(config_file) ? " --config #{File.realpath(config_file)}" : '' |
####################################### | |
# Check that some Build Settings (those defined by VERSION_SETTINGS below) are set on the right level (target/project) | |
####################################### | |
VERSION_SETTINGS = %w(GLOBAL_APP_VERSION GLOBAL_APP_BUILD_VERSION) | |
require 'xcodeproj' | |
project = Xcodeproj::Project.open('YOUR_PROJECT_NAME.xcodeproj') | |
target = project.targets.find("YOUR_TARGET_NAME").first | |
target.build_configurations.each do |bc| | |
## Don't allow some build settings at target level (but only at project level) |
#!/usr/bin/env ruby | |
# This script walks thru all the files in a Xcode project's groups belong to the target they are supposed to | |
# according to group names found while walking the groups hierarchy. | |
# | |
# This example only focuses on test files and groups/targets ending with "...Tests" | |
require 'xcodeproj' | |
def check(group, all_targets, walk_path, ctx_target_name = nil, ctx_expected_files_list = nil) |
//#! Swift 5 | |
import Foundation | |
import AppKit | |
//////////////////////////////////////////////////////////////////// | |
//: ## Type Definition | |
struct AttrString { | |
let attributedString: NSAttributedString |