Skip to content

Instantly share code, notes, and snippets.

@liamnichols
liamnichols / fix_ios_11_simulator_runtime_xcode_11.sh
Last active April 14, 2020 13:35
Fix for missing libswiftXCTest.dylib when trying to run Unit Tests in Xcode 11.1 on an iOS 11 simulator
sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
sudo ln -s /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Swift/libswiftXCTest.dylib /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
import UIKit
extension UIFont {
/// Returns an instance of the system font for the specified text style and weight.
///
/// The scale of the text style is determined by the specified traits.
///
/// If no traits are specified (the default) the font will be scaled for the user's selected content size category,
///
/// Otherwise the font will be scaled using the content size category information in the specified trait collection.
@liamnichols
liamnichols / gist:3e21bf923ada7fd778af9e3b47d2e6ec
Created July 3, 2018 16:21
Exporting localisations does not escape quotation marks and new lines correctly
Summary:
The Xcode Export Localisation tool fails to correctly escape quotation marks and new line sequences when exporting via "Editor -> Export For Localization..." or via the xcodebuild command line tool.
The behaviour changed in Xcode 9.3 and has been broken ever since. I've included the "_SampleExport" folder that shows the results of the export when I run it on my machine. Xcode 9.2 produces the results as expected.
The result of this corrupt export means that many third party translation tools retain the escapes in the translated xliff files but when importing them via the import tool, it will corrupt the .strings files as the escaping is wrong. I have not covered an example of it in this report as I believe it will be fixed once the export issue is fixed however it is still worth noting.
Steps to Reproduce:
1. Download the attached sample project
2. Open the project in Xcode 10 (Beta 2)
//
// GalleryItemCell.swift
// BrunchApp
//
// Created by Liam Nichols on 30/04/2017.
// Copyright © 2017 Bottomless Brunches. All rights reserved.
//
import UIKit
@liamnichols
liamnichols / WebImageCache.swift
Created August 8, 2017 10:47
Why use a library when its this easy?
import UIKit
extension URLSessionTask: WebImageOperation { }
protocol WebImageOperation {
func cancel()
}
class WebImageManager {
struct Error: Swift.Error {
import Foundation
import FirebaseRemoteConfig
final class Config {
/// The shared instance of config to use
static let shared: Config = Config()
/// The maximum number of items that are allowed in this mystery app
internal let maxItemCount: Int
@liamnichols
liamnichols / SmallCaps.swift
Last active December 29, 2017 18:11
An extension to simplify use of small caps within a UIFont object in Swift.
public extension UIFont {
/// Helper method to create a UIFont with updated attributes applied to the UIFontDescriptor
///
/// - parameter attributes: The new attributes to apply to the fontDescriptor
///
/// - returns: A UIFont object with the new attributes appended to the receivers fontDescriptor
func addingAttributes(_ attributes: [String : Any] = [:]) -> UIFont {
return UIFont(descriptor: fontDescriptor.addingAttributes(attributes), size: pointSize)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>fb254145378030027</string>
<string>isupr8</string>
<string>fb176151905794941</string>
<string>recipeSearch-iPad</string>
<string>airfile</string>
<string>univision</string>
Incident Identifier: 2986E199-B268-464A-883E-362B59A00AD0
CrashReporter Key: c68af6ee22388954851f65669288c7fb6e1c03dc
Hardware Model: iPad4,1
OS Version: iPhone OS 7.1.2 (11D257)
Kernel Version: Darwin Kernel Version 14.0.0: Thu May 15 23:17:54 PDT 2014; root:xnu-2423.10.71~1/RELEASE_ARM64_S5L8960X
Date: 2014-10-21 09:58:46 +0100
Time since snapshot: 218 ms
Free pages: 1951
Active pages: 133010
+ (UIImage *)installButtonBackground:(BOOL)fill
{
CGFloat borderWidth = 1.0;
CGFloat cornerRadius = 3.0;
CGSize size = CGSizeMake((cornerRadius * 2) + 1.0, (cornerRadius * 2) + 1.0);
UIColor *buttonColor = [UIColor installButtonColor];
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake((borderWidth / 2), (borderWidth / 2), size.width - borderWidth, size.height - borderWidth) byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];