Skip to content

Instantly share code, notes, and snippets.

@danielgehr
danielgehr / UIDevice.swift
Created January 12, 2018 08:57
UIDevice Swift extension to determine the device an app is running on
import Foundation
import UIKit
public enum Model: String {
case simulator = "simulator/sandbox",
iPod1 = "iPod 1",
iPod2 = "iPod 2",
iPod3 = "iPod 3",
iPod4 = "iPod 4",
iPod5 = "iPod 5",
@danielgehr
danielgehr / UIView.swift
Last active January 12, 2018 08:58
UIView Swift extension to add auto layout constraints to the view
import UIKit
public extension UIView {
func addHeightConstraint(_ height: CGFloat) {
addConstraint(NSLayoutConstraint(item: self,
attribute: .height,
relatedBy: .equal,
toItem: nil,
attribute: .notAnAttribute,
@danielgehr
danielgehr / Jenkinsfile
Last active October 30, 2023 02:04
Jenkins pipeline template with environment configuration using gitflow
// ***********************
//
// Build and deploy different environments with jenkins pipeline
//
// Merge to develop -> triggers development release
// Merge to master without tag -> triggers staging release
// Merge to master with tag -> triggers staging and production release
// Production release requires manual approval on the jenkins job
//
// Configure jenkins pipeline project to pull tags! By default, tags are not pulled!
@danielgehr
danielgehr / .yml
Created October 9, 2017 09:37
.swiftlint.yml template
disabled_rules: # rule identifiers to exclude from running
- trailing_whitespace
- vertical_whitespace
- variable_name
- type_name
opt_in_rules: # some rules are only opt-in
# Find all the available rules by running:
# swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
@danielgehr
danielgehr / .gitignore
Last active November 28, 2017 09:25
.gitignore template fox Xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
@danielgehr
danielgehr / .sh
Last active October 9, 2017 08:58
Automatically increment and set build number of an Xcode project by counting git commits of the current branch
# This build phase script updates the Info.plist file of your archived Xcode project with the current build number
# The build number is calculated by counting the amount of git commits on the current branch
# Updating the plist file in the archive has the benefits that this won't result in a code change which then would be visible in git as uncommited change
# Just set the build number in Xcode to something like "AUTO_GENERATED" in order to make clear that this value comes from somewhere else
# You need to add the script after the "Copy Bundle Ressource" phase, otherwise, there wont be an archive
# Ideally, just place it at the end of your build phases
# If your app uses a Settings.bundle and the settings should show the app version, you can use the second part of the script to update the settings bundle