This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -o pipefail && xcodebuild -workspace StudyJapanese.xcworkspace -scheme "StudyJapanese" -testPlan "AllUITests" -sdk "$SIMULATOR_SDK" $destinations -derivedDataPath "build/DerivedData" -parallel-testing-enabled YES -parallel-testing-worker-count $parallel_test_workers -retry-tests-on-failure -test-iterations 2 test -resultBundlePath artifacts/TestResults.xcresult OS_ACTIVITY_MODE='disable' $exclude_non_parallelizable_tests_args | tee artifacts/xcodebuild.log | bundle exec xcpretty || true | |
# Tests than failed the first time and succeeded the second time will show up in both files. Need the ones that only failed. | |
testRefsID=$(xcrun xcresulttool get --format json --path artifacts/TestResults.xcresult | jq --raw-output '.actions._values[0].actionResult.testsRef.id._value') | |
xcrun xcresulttool get --format json --path artifacts/TestResults.xcresult --id $testRefsID | jq '.summaries._values[0].testableSummaries._values[0].tests._values[0].subtests._values[0].subtests._values[].subtests | select( . != null ) | ._v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Error { | |
var code: Int { return (self as NSError).code } | |
var domain: String { return (self as NSError).domain } | |
var userInfo: [String:Any] { return (self as NSError).userInfo } | |
var isRelatedToPoorInternetConnection: Bool { | |
switch self { | |
case URLError.timedOut, | |
URLError.cancelled, | |
URLError.dataNotAllowed, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Error { | |
var code: Int { return (self as NSError).code } | |
var domain: String { return (self as NSError).domain } | |
var userInfo: [String:Any] { return (self as NSError).userInfo } | |
func timeAfterWhichToRetry(retryCount: Int) -> TimeInterval? { | |
// CloudKit suggests us retry too often, so slow us down as we retry a lot, up to 5 minutes | |
if let suggestedTimeout = suggestedTimeAfterWhichToRetry { | |
if suggestedTimeAfterWhichToRetry == 0 { | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension UIView { | |
@IBInspectable var cornerRadius: CGFloat { | |
get { | |
return layer.cornerRadius | |
} | |
set { | |
layer.cornerRadius = newValue | |
layer.masksToBounds = newValue > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
extension UITableViewController: UIScreenshotServiceDelegate { | |
public func screenshotService(_ screenshotService: UIScreenshotService, generatePDFRepresentationWithCompletion completionHandler: @escaping (Data?, Int, CGRect) -> Void) { | |
let originalFrame = tableView.frame | |
let originalContentOffset = tableView.contentOffset | |
// Layout into an extra large frame, to force the actual heights to be calculated for all rows with estimated heights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
class DisplayLink { | |
static let shared = DisplayLink() | |
var displayLink: CADisplayLink! | |
var lastTimestamp: CFTimeInterval? | |
private let pointsOfInterestLog = OSLog(subsystem: "displaylink", category: .pointsOfInterest) | |
init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run from a folder containing a folder for each language you want to look up a word in, | |
# with the contents of the glossaries from https://developer.apple.com/download/more/?=glossaries | |
# | |
# Prints the all translations found for the given word in each language, along with how many occurrences of that translation were found. | |
# | |
# Dependencies | |
# brew install xmlstarlet | |
# | |
# Usage | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func XCTAssertSoon(_ expression: @autoclosure () throws -> Bool, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line, waitTime: TimeInterval = 3) { | |
let startTime = Date() | |
repeat { | |
let success = (try? expression()) ?? false | |
if success { | |
return | |
} | |
else { | |
Thread.sleep(forTimeInterval: 1) | |
} |