Skip to content

Instantly share code, notes, and snippets.

View jaredsinclair's full-sized avatar

Jared Sinclair jaredsinclair

View GitHub Profile
View repackage.md

Repackaging a Fat Static Library as an xcframework

Consider this directory tree from a vendor:

OwningTheLibs/
  OwningTheLibs.a
  include/
    OwningTheLibs/
      OwningTheLibs.h
@jaredsinclair
jaredsinclair / Composition.swift
Last active May 28, 2020 21:48
Exposing private members to tests via composition.
View Composition.swift
import Foundation
/// This class is public, because my library exposes this to the rest of my app.
public class ObligatoryNetworkingClient {
public enum GetEndpoint {
case timeline
case profile(userID: String)
case directMessages
}
@jaredsinclair
jaredsinclair / .zshrc
Last active September 19, 2023 20:22
The World's Most Disappointing .zshrc File
View .zshrc
# ______ ______ __ __
# /\___ \ /\ ___\ /\ \_\ \
# \/_/ /__ \ \___ \ \ \ __ \
# /\_____\ \/\_____\ \ \_\ \_\
# \/_____/ \/_____/ \/_/\/_/
#
# THE GODDAMN PROMPT
# ---------------------------------------------------------------
# Looks best with certain fonts, e.g. SFMono, smoothing enabled.
@jaredsinclair
jaredsinclair / Importer.swift
Created April 8, 2019 01:02
Transform a Feedbin JSON backup file into a directory of Jekyll-formatted posts
View Importer.swift
import Foundation
/*
Alls you gotta do is (in Main.swift):
1. Initialize an Importer with the file URL to the JSON file (origin) and a URL to the directory that will contain all the Jekyll-formatted posts (destination).
2. Call the `run()` method on the Importer.
*/
@jaredsinclair
jaredsinclair / xcode-gsuite-email-notifs.md
Last active February 16, 2021 15:49
Setting Up Xcode Server Email Notifications So They Send From Your GSuite Account
View xcode-gsuite-email-notifs.md

Setting Up Xcode Server Email Notifications on a Repurposed Household Mac So They Send From Your GSuite Account

I recently repurposed a family computer to play a new role: Xcode build server. Setting up the bot wasn't too bad overall, but there was one really big hurdle: getting post-integration email notifications to actually send. Despite the (relative) user-friendliness of the UI, the email notification feature is very unforgiving. It expects to be running on a mac that is hosting (or sitting behind) a domain that's also running it's own SMTP service. A repurposed family computer is not going to have such a setup. Outbound mail is going to either not send at all or else likely get bounced by spam filtering.

I do have a GSuite account for small business stuff. I host my website at Media Temple, but the email service is run by Gmail, with DNS records configured to route mail traffic to Gmail. What I want is for my Xcode bot to send email notifications from one of my GSuite accounts. The following are s

@jaredsinclair
jaredsinclair / Autocodable.swift
Last active January 22, 2022 00:23
[Notion]: Automatic Codable synthesis for Enums with Codable associated values.
View Autocodable.swift
enum MyEnum: Codable {
case foo
case bar(Int)
case baz(label: String)
case qux(Bool, label: String, Int)
case anotherCase(discriminator: String, anotherCase_1: Int)
}
// Begin synthesized code...
@jaredsinclair
jaredsinclair / NSString+HTML.swift
Created December 18, 2017 05:21
Convert HTML string to plain text (Swift version of MWFeedParser's utility)
View NSString+HTML.swift
/// Quick-n-dirty translation of MWFeedParser's algorithm from Objective-C to Swift
/// seealso: https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString%2BHTML.m
public extension NSString {
public func byConvertingHTMLToPlainText() -> String {
let stopCharacters = CharacterSet(charactersIn: "< \t\n\r\(0x0085)\(0x000C)\(0x2028)\(0x2029)")
let newLineAndWhitespaceCharacters = CharacterSet(charactersIn: " \t\n\r\(0x0085)\(0x000C)\(0x2028)\(0x2029)")
let tagNameCharacters = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
View gist:a145a2c1c413fd5ba6d2fa8c833103bf
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@jaredsinclair
jaredsinclair / Warnings.xcconfig
Created July 5, 2016 04:34 — forked from steipete/Warnings.xcconfig
The warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
View Warnings.xcconfig
//
// Warnings.xcconfig
//
// The list of warnings we (don’t) use, and the reasons why.
//
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
//
// :MARK: - Warnings not to be promoted:
@jaredsinclair
jaredsinclair / gist:4de506e108249f39b12d
Created August 22, 2015 16:41
Podfile post-install script for best-practice code signing settings.
View gist:4de506e108249f39b12d
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.to_s == 'Beta'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution'
elsif config.to_s == 'Release'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution'
end
end
end