Skip to content

Instantly share code, notes, and snippets.

@Berhtulf
Berhtulf / ci_post_xcodebuild.sh
Last active November 13, 2024 19:08
Xcode Cloud - CI/CD Push tag to Github
# 1. Create 'ci_scripts' folder in your main project directory
# 2. Create 'ci_post_xcodebuild.sh' inside of it
# 3. Make it an executable by running 'chmod +x $ci_post_xcodebuild.sh'
set -e # fails build if any command fails
if [ ${CI_XCODEBUILD_EXIT_CODE} != 0 ]
then
exit 1
fi
@MasonSlover
MasonSlover / SFSymbolTitles.swift
Last active September 23, 2024 01:35
A .swift file with all SF Symbols titles in arrays, separated by category for app development and icon selection
//The following file has 20 arrays, allSymbols[] has the title of every SFSymbol, and the remaining 19 arrays have the following categories:
//communication, weather, objectsAndTools, devices, connectivity, transportation, human, nature, editing, textFormatting, media, keyboard, commerce, time, health, shapes, arrows, indicies, math
private var allSymbols = ["0.circle", "00.circle", "0.circle.fill", "00.circle.fill", "0.square", "00.square", "0.square.fill", "00.square.fill", "1.circle", "01.circle", "1.circle.fill", "01.circle.fill", "1.magnifyingglass", "1.square", "01.square", "1.square.fill", "01.square.fill", "2.circle", "02.circle", "2.circle.fill", "02.circle.fill", "2.square", "02.square", "2.square.fill", "02.square.fill", "3.circle", "03.circle", "3.circle.fill", "03.circle.fill", "3.square", "03.square", "3.square.fill", "03.square.fill", "4.alt.circle", "4.alt.circle.fill", "4.alt.square", "4.alt.square.fill", "4.circle", "04.circle", "4.circle.fill", "04.circle.fill", "4.square", "04.square", "4
@douglashill
douglashill / extract-most-common-localised-strings.swift
Last active November 5, 2024 09:18
Extracts the most common translations from Apple’s glossary files. Read more: https://douglashill.co/localisation-using-apples-glossaries/
#! /usr/bin/swift
// Douglas Hill, March 2020
/*
Extracts the most common translations from Apple’s glossary files.
This script helped with localisation for KeyboardKit (https://github.com/douglashill/KeyboardKit) by leveraging Apple’s existing translations.
More detail in the article at https://douglashill.co/localisation-using-apples-glossaries/
@douglashill
douglashill / explore-localisation-glossaries.swift
Last active November 5, 2024 09:16
Prints out translations from Apple’s glossary files matching text in a supplied English .strings file. Read more: https://douglashill.co/localisation-using-apples-glossaries/
#! /usr/bin/swift
// Douglas Hill, March 2020
// Prints out translations from Apple’s glossary files matching text in a supplied English .strings file.
// More detail in the article at https://douglashill.co/localisation-using-apples-glossaries/
import Foundation
let stringsSource = URL(fileURLWithPath: "PUT THE PATH TO YOUR ENGLISH .strings FILE HERE")
@b-outlaw
b-outlaw / insert_newline_xcode.md
Created May 1, 2019 20:58
Xcode – Insert Newline Before/After
  1. Open below directory in Finder with Cmnd + Shift + G
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
  1. Open IDETextKeyBindingSet.plist with a text editor (not Xcode's plist editor).

  2. Add this in:

import CoreData
/// Manages Core Data Persistent History.
///
/// When using Core Data in multiple targets, e.g. an app as well as a file provider, it is crucial to merge changes from one
/// target into another because otherwise you would end up with inconsistent state. To that end, this Apple introduced
/// persistent history, which is a linear stream of changes that can be merged into the current context. This service takes
/// advantage of this feature by providing a simple interface for merging and deleting history. The latter is needed to free up
/// space after the history has been consumed by all targets. It uses history transactions' timestamps in order to determine
/// what to delete.
@morishin
morishin / left-align-stack-view.png
Last active March 22, 2024 00:25
Align to Left the contents of UIStackView
left-align-stack-view.png
/// Additional colors accessibility metrics utilities
import Cocoa
import simd
extension NSColor {
/// Returns in an ordered array the following components from this color, in the sRGB color space:
/// - red
/// - green
@darrarski
darrarski / SystemIdleTime.m
Last active March 30, 2021 07:05
Get Mac OS X system idle time in Swift or Objective-C
//
// Created by Dariusz Rybicki on 17/04/16.
// Copyright © 2016 Darrarski. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
Returns number of seconds since system became idle
@jtbandes
jtbandes / decode-dyn-uti.swift
Last active October 14, 2024 14:54
Dynamic UTI decoding
/// Decodes a dynamically-generated Uniform Type Identifier for inspection purposes. (**NOT FOR PRODUCTION USE!**)
/// Many, many thanks to http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/
///
/// <https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-BCGCDHIJ>
func decodeDynUTI(_ uti: String) -> String?
{
let vec = Array("abcdefghkmnpqrstuvwxyz0123456789")
let encoded = Array(uti).suffix(from: 5)
var result: [UInt8] = []