Skip to content

Instantly share code, notes, and snippets.

Tyler Milner tylermilner

Block or report user

Report or block tylermilner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tylermilner
tylermilner / oclint.sh
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 http://docs.oclint.org/en/stable/guide/xcode.html). Replace "<project_name>" and tweak "exclude" flags as necessary.
View oclint.sh
source ~/.bash_profile
unset LLVM_TARGET_TRIPLE_SUFFIX
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
maxPriority=15000
oclint-json-compilation-database -exclude Pods -exclude build -- -report-type xcode -max-priority-1=$maxPriority -max-priority-2=$maxPriority -max-priority-3=$maxPriority
@tylermilner
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 - https://medium.com/@RobertGummesson/regarding-swift-build-time-optimizations-fc92cdd91e31#c75c
// Joining two arrays together with the '+' operator can be expensive to compile.
let someArray = ["a", "b"] + ["c", "d"]
@tylermilner
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: https://medium.com/rocket-fuel/step-up-your-functional-game-map-and-flatmap-tricks-cdc1578fe7bc
// 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
tylermilner / copy_appropriate_google-service-info-plist.sh
Last active Jul 8, 2019
A shell script to selectively copy your GoogleService-Info.plist into your app bundle based on the current build configuration.
View copy_appropriate_google-service-info-plist.sh
# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
# 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)
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Dev/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Prod/${GOOGLESERVICE_INFO_PLIST}
# Make sure the dev version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}"
View .swiftlint.yml
#
#### DEPRECATED ####
# Use the standard .swiftlint.yml for all files in your project, including tests.
# https://gist.github.com/tylermilner/f33e33e3b4f23d8c6b2fdd4f87af98a1
#
# Set max line length before warning (default is 120)
line_length: 240
disabled_rules:
@tylermilner
tylermilner / .swiftlint.yml
Last active Aug 15, 2019
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
disabled_rules:
- trailing_whitespace # Disables SwiftLint complaining about whitespace characters on empty lines
- todo # Disables auto-warning of TODO statements
# Turn on extra SwiftLint rules
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
@tylermilner
tylermilner / Xcode Breakpoints.swift
Last active Mar 31, 2017
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
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
baseUri: http://api.samplehost.com
2.) Layout basic API structure:
You can’t perform that action at this time.