Skip to content

Instantly share code, notes, and snippets.

tylermilner /
Created May 1, 2020
A simple Bash script to generate an average build time for your iOS project. Replace with your project's workspace and scheme before use.
# Workspace and scheme parameters for the project
workspace="ProjectWorkspace.xcworkspace" # TODO: Replace with your project's workspace
scheme="ProjectScheme" # TODO: Replace with your project's scheme
# The number of times to build the project
# Abort the process if any of the commands in this script fail
tylermilner /
Last active Mar 12, 2019 — forked from ryuichis/gist:755e6297aec13c900cdf
Script integrating OCLint into Xcode 10. Put it in "Run script" build phase of aggregate target (see Replace "<project_name>" and tweak "exclude" flags as necessary.
source ~/.bash_profile
xcodebuild -scheme <project_name> -workspace <project_name>.xcworkspace clean
xcodebuild -scheme <project_name> -workspace <project_name>.xcworkspace COMPILER_INDEX_STORE_ENABLE=NO | xcpretty -r json-compilation-database --output compile_commands.json
oclint-json-compilation-database -exclude Pods -exclude build -- -report-type xcode -max-priority-1=$maxPriority -max-priority-2=$maxPriority -max-priority-3=$maxPriority
tylermilner / Slow_Compiling_Swift_Code.swift
Created Nov 27, 2017
Code samples of common sources of slowdowns for the Swift 2/3 compiler.
View Slow_Compiling_Swift_Code.swift
// The code snippets below showcase common "problem code" that can take a long time to compile.
// These examples were primarily observed in Swift 2/3 and may no longer be relevant in Swift 4 or higher.
/// 1. Array concatenation
// Observed by Robert Gummesson -
// Joining two arrays together with the '+' operator can be expensive to compile.
let someArray = ["a", "b"] + ["c", "d"]
tylermilner / Cupcakes_MapAndFlatMap.swift
Last active Jul 10, 2019
A Swift playground showcasing some use cases for map and flatMap using Cupcakes.
View Cupcakes_MapAndFlatMap.swift
import UIKit
/// Introduction
// This playground showcases many potential use cases of `map` and `flatMap` in Swift (beyond transforming collections).
// See this article on Medium for more information:
// To run this playground in Xcode, copy/paste the contents of this file into a new playground (playgrounds are technically directories so GitHub Gist doesn't work well with them).
// There are several comment blocks that represent the "old way" of doing things (without `map`/`flatMap`). Feel free to uncomment these to verify functionality.
tylermilner /
Last active May 14, 2022
A shell script to selectively copy your GoogleService-Info.plist into your app bundle based on the current build configuration.
# Name of the resource we're selectively copying
# Get references to dev and prod versions of the GoogleService-Info.plist
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually)
# Make sure the dev version of GoogleService-Info.plist exists
View .swiftlint.yml
#### DEPRECATED ####
# Use the standard .swiftlint.yml for all files in your project, including tests.
# Set max line length before warning (default is 120)
line_length: 240
tylermilner / .swiftlint.yml
Last active May 5, 2021
Default SwiftLint repo-wide configuration file. Put this at the root directory of your repository and tweak for your needs.
View .swiftlint.yml
# Turn off default SwiftLint rules
- trailing_whitespace # Disables SwiftLint complaining about whitespace characters on empty lines
- todo # Disables auto-warning of TODO statements
# Turn on extra SwiftLint rules
- array_init
- attributes
- closure_end_indentation
tylermilner / Xcode Breakpoints.swift
Last active Nov 3, 2020
These are Xcode breakpoints I've found to be very useful to have turned on to help debug iOS applications and spot problems early. After creating each one, right-click on it and click "Move Breakpoint To" -> "User" so that the breakpoint will automatically be active for any Xcode project you open.
View Xcode Breakpoints.swift
All Objective-C Exceptions
// Catches exceptions thrown by Objective-C code.
// Default Xcode breakpoint created by clicking "+" to add breakpoint -> "Exception Breakpoint".
// Change "Exception: All" to "Exception: Objective-C".
-[UIApplication main]
// Helps when printing objects via the debugger by making it aware of the classes in UIKit.
// Symbolic breakpoint created by clicking "+" to add breakpoint -> "Symbolic Breakpoint".
// Enter "-[UIApplication main]" for the Symbol.
// Choose Action -> "Debugger Command".
tylermilner / RadioStationAPI Code&Tell Example
Last active Mar 27, 2017
RadioStationAPI - Code & Tell Snippets
View RadioStationAPI Code&Tell Example
1.) Create 'api.raml' file:
#%RAML 1.0
title: Radio Station
version: v1
2.) Layout basic API structure: