Skip to content

Instantly share code, notes, and snippets.

View liamnichols's full-sized avatar
💭
I may be slow to respond.

Liam Nichols liamnichols

💭
I may be slow to respond.
View GitHub Profile
//
// GalleryItemCell.swift
// BrunchApp
//
// Created by Liam Nichols on 30/04/2017.
// Copyright © 2017 Bottomless Brunches. All rights reserved.
//
import UIKit
@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)
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 / 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
@liamnichols
liamnichols / sign_in_with_apple.yml
Created February 21, 2020 14:53
Localisations of the "Sign in with Apple" string taken from Xcode 11.1
SIGN_IN_WITH_APPLE:
- de: Mit Apple anmelden
- he: התחברות באמצעות Apple
- en_AU: Sign in with Apple
- ar: تسجيل الدخول باستخدام Apple
- el: Σύνδεση μέσω Apple
- ja: Appleでサインイン
- en: Sign in with Apple
- uk: Увійти з Apple
- es_419: Iniciar sesión con Apple
diff --git a/spec/fixtures/SwiftFile.swift b/spec/fixtures/SwiftFile.swift
index 0e18440..9dda539 100755
--- a/spec/fixtures/SwiftFile.swift
+++ b/spec/fixtures/SwiftFile.swift
@@ -10,10 +10,33 @@ module Danger
// Hello, World! Program
import Swift
var tempString: String? = "Hello, World!"
print(tempString!)
@liamnichols
liamnichols / URL+StaticString.swift
Created July 10, 2020 06:52
A non-failable initialiser extension for URL that accepts StaticString
import Foundation
extension URL {
/// Initialize with a static string.
///
/// If the `URL` cannot be formed with the string (for example, if the string contains characters that are illegal in a URL, or is an empty string), a precondition failure will trigger at runtime.
init(staticString: StaticString) {
guard let url = Self.init(string: String(describing: staticString)) else {
preconditionFailure("'\(staticString)' does not represent a legal URL")
}
import Cocoa
import Foundation
// MARK: - DataModule
// Types here have a 1:1 match against the API spec and are generated from an OpenAPI specificaition
// They are public types of the DataModule intended only for use within the DomainModule
public struct CollectionDTO: Equatable {
public let id: Int
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "StaticSwiftSyntaxParser",
products: [
.library(name: "StaticSwiftSyntaxParser", type: .static, targets: ["StaticSwiftSyntaxParser"])
],
import Foundation
import XCTest
extension XCTestCase {
/// Waits for an escaping closure to be invoked with a result value for the specified timeout duration and returns the value.
///
/// When using this method, you must trigger work inside the `performWork` closure that invokes the `completion` closure exactly once.
/// Failure to do so within the specified `timeout` will result in an error being thrown.
///
/// ```swift