Skip to content

Instantly share code, notes, and snippets.

@seanhenry
seanhenry / LineCounter.rb
Last active November 6, 2015 17:50
A script which counts lines of code in Swift and Objective-C projects. It ignores blank lines and counts production code and test code separately. It provides the average number of lines per file and the standard deviation.
# Usage: ruby LineCounter.rb <directory to search>
class LineCounter
def initialize(lineCounts)
@lineCounts = lineCountsFromString(lineCounts)
end
def lineCountsFromString(string)
lineCountsStrings = string.split("\n")
@seanhenry
seanhenry / SRPAnalyser.rb
Created November 6, 2015 11:04
A script to search Objective-C and Swift files which outputs the number of lines in each file. I've used this to determine areas of an application which violate the Single Responsibility Principle. Output quickly identifies the largest classes in a project.
# Dependencies: sudo gem install colorize
# Usage: ruby SRPAnalyser.rb --hide-acceptable <Path to search>
require 'colorize'
def displayFileWithNumberOfLines (file, lines, hideAcceptable)
message = "#{file} has #{lines} lines."
maxLines = 250
acceptableLines = 150
if lines > maxLines
@seanhenry
seanhenry / resign.sh
Last active February 19, 2024 16:10
Resign an ipa and change the build number
APPNAME=App
BUILDNUMBER=123
CERTIFICATE="iPhone Distribution"
cp "${APPNAME}.ipa" "${APPNAME}.zip"
mkdir contents || true
unzip "${APPNAME}.zip" -d contents
codesign -d --entitlements :Entitlements.plist "contents/Payload/${APPNAME}.app"
plutil -replace CFBundleVersion -string "${BUILDNUMBER}" "contents/Payload/${APPNAME}.app/Info.plist"
rm -r "contents/Payload/${APPNAME}.app/_CodeSignature"
@seanhenry
seanhenry / Playground.swift
Last active November 27, 2017 02:49
SO: Out of bounds UIView constraints programmatically
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
let vc = UIViewController()
let view = vc.view!
PlaygroundPage.current.liveView = vc
view.layoutIfNeeded()
@seanhenry
seanhenry / Gemfile
Last active February 19, 2022 21:00
Source: Better network debugging with Charles Proxy and iOS. See original post for explanation http://seanhenry.codes/ios/better-network-debugging-charles-proxy-ios/
source 'https://rubygems.org' do
gem 'sinatra'
end
@seanhenry
seanhenry / resign.sh
Created May 1, 2018 02:48
Changes provisioning profile, bundle ID, and resigns prebuilt iOS .ipa (Last tested Xcode 9.3)
APPNAME=YourAppName # not including .app/.ipa suffix
BUILDNUMBER=300 # change build number to this value
CERTIFICATE="iPhone Distribution: Your Organisation name here (8JSK92JDKSM)"
PROFILE="NewProvisioningProfile.mobileprovision"
BUNDLE_ID="BundleID"
cp "${APPNAME}.ipa" "${APPNAME}.zip"
mkdir contents || true
unzip "${APPNAME}.zip" -d contents
codesign -d --entitlements :Entitlements.plist "contents/Payload/${APPNAME}.app"
class A: B {}