//
//  BadgeView.swift
//  RightDirection
//
//  Created by Mike Mikina on 3/11/16.
//  Copyright © 2016 FDT. All rights reserved.
//

import UIKit

class BadgeView: UIView {
  let badgeViewWidth = 141
  let badgeViewHeight = 160
  let badgeRoundedCorners = 30

  @IBOutlet weak var statusImage: UIImageView!

  func showBadgeWithType(type: BadgeType) {
    switch type {
      case .Success:
        self.showImageWithAnimation("badgeCorrect")
      case .Fail:
        self.showImageWithAnimation("badgeFail")
    }
  }

  func showImageWithAnimation(image: String) {
    self.statusImage.image = UIImage(imageLiteral: image)
    self.hidden = false

    UIView.animateWithDuration(0.2, delay: 0, options: [.CurveEaseInOut], animations: {
      self.alpha = 1
      }, completion: { finished in
        if finished {
          self.hideStatus()
        }
    })
  }

  func hideStatus() {
    UIView.animateWithDuration(0.2, delay: 0, options: [.CurveEaseInOut], animations: {
      self.alpha = 0

      }, completion: { finished in
        if finished {
          self.hidden = true
        }
    })
  }

  func setupBadgeWithResult(result: Bool) {
    if result {
      self.showBadgeWithType(.Success)
    }
    else {
      self.showBadgeWithType(.Fail)
    }
  }
}

Reduce badge alpha as it's too visible and sometimes covers directions.

//
//  BadgeView.swift
//  RightDirection
//
//  Created by Mike Mikina on 3/11/16.
//  Copyright © 2016 FDT. All rights reserved.
//

import UIKit

class BadgeView: UIView {
  let badgeViewWidth = 141
  let badgeViewHeight = 160
  let badgeRoundedCorners = 30

  @IBOutlet weak var statusImage: UIImageView!

  func showBadgeWithType(type: BadgeType) {
    switch type {
      case .Success:
        self.showImageWithAnimation("badgeCorrect")
      case .Fail:
        self.showImageWithAnimation("badgeFail")
    }
  }

  func showImageWithAnimation(image: String) {
    self.statusImage.image = UIImage(imageLiteral: image)
    self.hidden = false

    UIView.animateWithDuration(0.2, delay: 0, options: [.CurveEaseInOut], animations: {
      self.alpha = 0.5
      }, completion: { finished in
        if finished {
          self.hideStatus()
        }
    })
  }

  func hideStatus() {
    UIView.animateWithDuration(0.2, delay: 0, options: [.CurveEaseInOut], animations: {
      self.alpha = 0

      }, completion: { finished in
        if finished {
          self.hidden = true
        }
    })
  }

  func setupBadgeWithResult(result: Bool) {
    if result {
      self.showBadgeWithType(.Success)
    }
    else {
      self.showBadgeWithType(.Fail)
    }
  }
}


//
//  String+Path.swift
//  MobileLocalizationConverter
//
//  Created by Sébastien Duperron on 23/05/2016.
//  Copyright © 2016 Sébastien Duperron. All rights reserved.
//

import Foundation

extension String {
    func appending(pathComponent component: String) -> String {
        return (self as NSString).stringByAppendingPathComponent(component)
    }
}

Fix license in Swift+Path file

//
//  String+Path.swift
//
//  Created by Sébastien Duperron on 23/05/2016.
//  Copyright © 2016 Sébastien Duperron
//  Released under an MIT license: http://opensource.org/licenses/MIT
//

import Foundation

extension String {
    func appending(pathComponent component: String) -> String {
        return (self as NSString).stringByAppendingPathComponent(component)
    }
}


//
//  StyledString.swift
//
//
//  Created by 1024jp on 2017/03/04.
//
//

struct StyledString {

    let string: String
    let styles: [Style]
}

struct Style {

    let range: Range<String.Index>
    let type: Type
}

enum StyleType {

    case bold
    case strike
    case link(url: String)
    case image(url: String)
}

Put styles type into Style

//
//  StyledString.swift
//
//
//  Created by 1024jp on 2017/03/04.
//
//

struct StyledString {

    let string: String
    let styles: [Style]
}

struct Style {

    let range: Range<String.Index>
    let type: Type

    enum Type {

        case bold
        case strike
        case link(url: String)
        case image(url: String)
    }
}


//
//  SubscriptionRolesRequest.swift
//  Rocket.Chat
//
//  Created by Rafael Kellermann Streit on 11/05/18.
//  Copyright © 2018 Rocket.Chat. All rights reserved.
//

import SwiftyJSON
import RealmSwift

fileprivate extension SubscriptionType {
    var path: String {
        switch self {
        case .channel:
            return "/api/v1/channels.roles"
        case .group:
            return "/api/v1/groups.roles"
        case .directMessage:
            return ""
        }
    }
}

final class SubscriptionRolesRequest: APIRequest {
    typealias APIResourceType = SubscriptionRolesResource

    var path: String {
        return type.path
    }

    var query: String?
    let roomName: String?
    let type: SubscriptionType

    init(roomName: String, subscriptionType: SubscriptionType) {
        self.type = subscriptionType
        self.roomName = roomName
        self.query = "roomName=\(roomName)"
    }
}

final class SubscriptionRolesResource: APIResource {
    var subscriptionRoles: [SubscriptionRoles]? {
        return raw?["roles"].arrayValue.map {
            var object = SubscriptionRoles()
            object.user = User.find(withIdentifier: $0["u"]["_id"].stringValue)
            object.roles.append(contentsOf: $0["roles"].arrayValue.compactMap({ $0.string }))
            return object
        }
    }

    var success: Bool {
        return raw?["success"].bool ?? false
    }
}

Add minimum version for the API

//
//  SubscriptionRolesRequest.swift
//  Rocket.Chat
//
//  Created by Rafael Kellermann Streit on 11/05/18.
//  Copyright © 2018 Rocket.Chat. All rights reserved.
//

import SwiftyJSON
import RealmSwift

fileprivate extension SubscriptionType {
    var path: String {
        switch self {
        case .channel:
            return "/api/v1/channels.roles"
        case .group:
            return "/api/v1/groups.roles"
        case .directMessage:
            return ""
        }
    }
}

final class SubscriptionRolesRequest: APIRequest {
    typealias APIResourceType = SubscriptionRolesResource

    let requiredVersion = Version(0, 64, 2)

    var path: String {
        return type.path
    }

    var query: String?
    let roomName: String?
    let type: SubscriptionType

    init(roomName: String, subscriptionType: SubscriptionType) {
        self.type = subscriptionType
        self.roomName = roomName
        self.query = "roomName=\(roomName)"
    }
}

final class SubscriptionRolesResource: APIResource {
    var subscriptionRoles: [SubscriptionRoles]? {
        return raw?["roles"].arrayValue.map {
            let object = SubscriptionRoles()
            object.user = User.find(withIdentifier: $0["u"]["_id"].stringValue)
            object.roles.append(contentsOf: $0["roles"].arrayValue.compactMap({ $0.string }))
            return object
        }
    }

    var success: Bool {
        return raw?["success"].bool ?? false
    }
}


import UIKit

class CategoryPicker: NSObject, UIPickerViewDelegate, UIPickerViewDataSource {

    let categories: [String]
    let view = UIPickerView(frame: CGRectZero)

    var index: Int { return view.selectedRowInComponent(0) }
    var name: String { return categories[index] }

    init(categories: [String]) {

        self.categories = categories
        super.init()

        view.showsSelectionIndicator = true
        view.backgroundColor = UIColor(white: 0.98, alpha: 1)
        view.delegate = self
        view.dataSource = self

    }

    convenience init(categories: [String], selected: Int) {
        self.init(categories: categories)
        view.selectRow(selected, inComponent: 0, animated: false)
    }

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return categories.count
    }

    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
        return categories[row]
    }

}

Change picker color to match accessory

import UIKit

class CategoryPicker: NSObject, UIPickerViewDelegate, UIPickerViewDataSource {

    let categories: [String]
    let view = UIPickerView(frame: CGRectZero)

    var index: Int { return view.selectedRowInComponent(0) }
    var name: String { return categories[index] }

    init(categories: [String]) {

        self.categories = categories
        super.init()

        view.showsSelectionIndicator = true
        view.backgroundColor = UIColor(white: 0.97, alpha: 1)
        view.delegate = self
        view.dataSource = self

    }

    convenience init(categories: [String], selected: Int) {
        self.init(categories: categories)
        view.selectRow(selected, inComponent: 0, animated: false)
    }

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return categories.count
    }

    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
        return categories[row]
    }

}


//  Copyright © 2015 Rob Rix. All rights reserved.

extension Expression where Recur: FixpointType {
	public static var description: Module<Recur> {
		// Tag : λ _ : Enumeration . Type
		// Tag = λ E : Enumeration . λ _ : Boolean . Tag E

		let tag = Recur.Variable("Tag")
		let enumeration = Recur.Variable("Enumeration")
		let label = Recur.Variable("Label")
		let cons = Recur.Variable("::")

		let Tag = Binding("Tag",
			lambda(enumeration, .BooleanType) { E, _ in .Application(tag, E) },
			lambda(enumeration, const(.Type(0))))

		return Module([ list ], [
			Binding("String", .Axiom(String.self, .Type(0)), .Type(0)),
			Binding("Label", .Variable("String"), .Type(0)),
			Binding("Enumeration", .Application(.Variable("List"), .Variable("Label")), .Type(0)),

			Tag,
		])
	}
}

import Prelude

Define a binding for here.

//  Copyright © 2015 Rob Rix. All rights reserved.

extension Expression where Recur: FixpointType {
	public static var description: Module<Recur> {
		// Tag : λ _ : Enumeration . Type
		// Tag = λ E : Enumeration . λ _ : Boolean . Tag E

		let tag = Recur.Variable("Tag")
		let enumeration = Recur.Variable("Enumeration")
		let label = Recur.Variable("Label")
		let cons = Recur.Variable("::")

		let Tag = Binding("Tag",
			lambda(enumeration, .BooleanType) { E, _ in .Application(tag, E) },
			lambda(enumeration, const(.Type(0))))

		// here : λ first : Label . λ rest : Enumeration . Tag (first :: rest)
		// here = λ first : Label . (true, first)
		let here = Binding("here",
			lambda(label, enumeration) { first, rest in .Annotation(.Product(.Boolean(false), .Unit), .Application(.Application(cons, first), rest)) },
			lambda(label, enumeration) { first, rest in .Application(tag, .Application(.Application(cons, first), rest)) })

		return Module([ list ], [
			Binding("String", .Axiom(String.self, .Type(0)), .Type(0)),
			Binding("Label", .Variable("String"), .Type(0)),
			Binding("Enumeration", .Application(.Variable("List"), .Variable("Label")), .Type(0)),

			Tag,
			here,
		])
	}
}

import Prelude


//
//  Created by Tom Baranes on 18/01/2017.
//  Copyright © 2017 Tom Baranes. All rights reserved.
//

import UIKit

public extension UITextField {

    public func setClearButton(with image: UIImage) {
        let clearButton = UIButton(type: .custom)
        clearButton.setImage(image, for: .normal)
        clearButton.frame = CGRect(origin: .zero, size: image.size)
        clearButton.contentMode = .left
        clearButton.addTarget(self, action: #selector(clear), for: .touchUpInside)
        clearButtonMode = .never

        rightView = clearButton
        rightViewMode = .whileEditing
    }

    func clear() {
        self.text = ""
        self.sendActions(for: .editingChanged)
    }

}

Add setPlaceholderTextColor to UITextField extension

//
//  Created by Tom Baranes on 18/01/2017.
//  Copyright © 2017 Tom Baranes. All rights reserved.
//

import UIKit

// MARK: - Clear button

public extension UITextField {

    public func setClearButton(with image: UIImage) {
        let clearButton = UIButton(type: .custom)
        clearButton.setImage(image, for: .normal)
        clearButton.frame = CGRect(origin: .zero, size: image.size)
        clearButton.contentMode = .left
        clearButton.addTarget(self, action: #selector(clear), for: .touchUpInside)
        clearButtonMode = .never

        rightView = clearButton
        rightViewMode = .whileEditing
    }

    func clear() {
        text = ""
        sendActions(for: .editingChanged)
    }

}

// MARK: - Placeholder

public extension UITextField {

    public func setPlaceHolderTextColor(_ color: UIColor) {
        guard let placeholder = placeholder, placeholder.isNotEmpty else {
            return
        }
        attributedPlaceholder = NSAttributedString(string: placeholder,
                                                   attributes: [NSForegroundColorAttributeName: color])
    }

}


//
//  TKUISheetViewController.swift
//  TripKitUI-iOS
//
//  Created by Adrian Schönig on 29.10.18.
//  Copyright © 2018 SkedGo Pty Ltd. All rights reserved.
//

import UIKit

@objc
public class TKUISheetViewController: UIViewController {

  @objc
  public init(sheet: TKUISheet) {
    super.init(nibName: nil, bundle: nil)
    self.view = sheet
  }

  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  public var sheet: TKUISheet? {
    return self.view as? TKUISheet
  }

  public override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    sheet?.doneButtonPressed(nil)
  }

  public override var preferredContentSize: CGSize {
    get {
      return sheet?.bounds.size ?? .zero
    }
    set {
      // do nothing
    }
  }

}

Fix silly mistake of view dismissing immediately

//
//  TKUISheetViewController.swift
//  TripKitUI-iOS
//
//  Created by Adrian Schönig on 29.10.18.
//  Copyright © 2018 SkedGo Pty Ltd. All rights reserved.
//

import UIKit

@objc
public class TKUISheetViewController: UIViewController {

  @objc
  public init(sheet: TKUISheet) {
    super.init(nibName: nil, bundle: nil)
    self.view = sheet
  }

  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  public var sheet: TKUISheet? {
    return self.view as? TKUISheet
  }

  public override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)

    sheet?.doneButtonPressed(nil)
  }

  public override var preferredContentSize: CGSize {
    get {
      return sheet?.bounds.size ?? .zero
    }
    set {
      // do nothing
    }
  }

}


//
//  Copyright © 2015 Itty Bitty Apps. All rights reserved.

import UIKit

final class InfoViewController: UIViewController, SettableHomeItem {
  @IBOutlet private weak var imageView: UIImageView!
  @IBOutlet private weak var webView: UIWebView!
  @IBOutlet private weak var titleLabel: UILabel!

  var item: HomeItem?

  override func viewDidLoad() {
    super.viewDidLoad()

    guard let item = self.item else {
      fatalError("Item should be set before `-viewDidLoad`")
    }

    // Configure the view
    self.imageView.image = UIImage(named: item.iconName)
    self.titleLabel.text = item.title

    let htmlString = infoHTMLWithContent(item.infoFilename)
    self.webView.loadHTMLString(htmlString, baseURL: nil)
  }

  @IBAction func doneButtonTapped(sender: UIBarButtonItem) {
    self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
  }
}

// MARK: UIWebViewDelegate
extension InfoViewController: UIWebViewDelegate {
  func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
    if let URL = request.URL where URL != NSURL(string: "about:blank") {
      UIApplication.sharedApplication().openURL(URL)
      return false
    }
    return true
  }
}

Remove black line along the bottom of webviews for the info view controller

//
//  Copyright © 2015 Itty Bitty Apps. All rights reserved.

import UIKit

final class InfoViewController: UIViewController, SettableHomeItem {
  @IBOutlet private weak var imageView: UIImageView!
  @IBOutlet private weak var webView: UIWebView!
  @IBOutlet private weak var titleLabel: UILabel!

  var item: HomeItem?

  override func viewDidLoad() {
    super.viewDidLoad()

    guard let item = self.item else {
      fatalError("Item should be set before `-viewDidLoad`")
    }

    // Configure the view
    self.imageView.image = UIImage(named: item.iconName)
    self.titleLabel.text = item.title

    self.webView.opaque = false
    self.webView.backgroundColor = UIColor.clearColor()

    let htmlString = infoHTMLWithContent(item.infoFilename)
    self.webView.loadHTMLString(htmlString, baseURL: nil)
  }

  @IBAction func doneButtonTapped(sender: UIBarButtonItem) {
    self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
  }
}

// MARK: UIWebViewDelegate
extension InfoViewController: UIWebViewDelegate {
  func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
    if let URL = request.URL where URL != NSURL(string: "about:blank") {
      UIApplication.sharedApplication().openURL(URL)
      return false
    }
    return true
  }
}


import UIKit

public class LightboxViewCell: UICollectionViewCell {

  public static let reuseIdentifier: String = "LightboxViewCell"

  var lightboxView: LightboxView?

  public func configureCell(image: UIImage) {
    backgroundColor = .redColor()

    if let lightboxView = lightboxView where lightboxView.superview != nil  {
      lightboxView.removeFromSuperview()
    }

    lightboxView = LightboxView(frame: bounds,
      image: image)

    contentView.addSubview(lightboxView!)
  }
}

Remove setting of background color

import UIKit

public class LightboxViewCell: UICollectionViewCell {

  public static let reuseIdentifier: String = "LightboxViewCell"

  var lightboxView: LightboxView?

  public func configureCell(image: UIImage) {
    if let lightboxView = lightboxView where lightboxView.superview != nil  {
      lightboxView.removeFromSuperview()
    }

    lightboxView = LightboxView(frame: bounds,
      image: image)

    contentView.addSubview(lightboxView!)
  }
}


//
//  AppDelegate.swift
//  SwiftNetworker
//
//  Created by Igor Prysyazhnyuk on 10/15/2017.
//  Copyright (c) 2017 Igor Prysyazhnyuk. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

}

Remove unused code from example

//
//  AppDelegate.swift
//  SwiftNetworker
//
//  Created by Igor Prysyazhnyuk on 10/15/2017.
//  Copyright (c) 2017 Igor Prysyazhnyuk. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        return true
    }
}


//
//  HPControlXibDesignable.swift
//  Pods
//
//  Created by Huy Pham on 12/25/15.
//
//

import UIKit

@IBDesignable
public class HPControlXibDesignable: UIView {
    public override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupNib()
    }

    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.setupNib()
    }

    private func setupNib() {
        let view = self.loadNib()
        view.translatesAutoresizingMaskIntoConstraints = false

        self.addSubview(view)

        let bindings = ["view": view]
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
    }

    private func loadNib() -> UIView {
        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: self.nibName(), bundle: bundle)
        return nib.instantiateWithOwner(self, options: nil)[0] as! UIView
    }

    private func nibName() -> String {
        return self.dynamicType.description().componentsSeparatedByString(".").last!
    }
}

Fix extending wrong class =.=

//
//  HPControlXibDesignable.swift
//  Pods
//
//  Created by Huy Pham on 12/25/15.
//
//

import UIKit

@IBDesignable
public class HPControlXibDesignable: UIControl {
    public override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupNib()
    }

    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.setupNib()
    }

    private func setupNib() {
        let view = self.loadNib()
        view.translatesAutoresizingMaskIntoConstraints = false

        self.addSubview(view)

        let bindings = ["view": view]
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
    }

    private func loadNib() -> UIView {
        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: self.nibName(), bundle: bundle)
        return nib.instantiateWithOwner(self, options: nil)[0] as! UIView
    }

    private func nibName() -> String {
        return self.dynamicType.description().componentsSeparatedByString(".").last!
    }
}


//
//  GradedSectionMessageView.swift
//  edX
//
//  Created by Akiva Leffert on 6/6/15.
//  Copyright (c) 2015 edX. All rights reserved.
//

import UIKit

class GradedSectionMessageView: UIView {
    let messageLabel = UILabel()

    init() {
        super.init(frame: CGRectZero)
        messageLabel.numberOfLines = 0
        messageLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
        addSubview(messageLabel)
        messageLabel.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(self).offset(textInset)
            make.trailing.equalTo(self).offset(-textInset)
            make.top.equalTo(self).offset(textInset)
            make.bottom.equalTo(self).offset(-textInset)
        }
        messageLabel.attributedText = textStyle.attributedStringWithText(OEXLocalizedString("GRADED_CONTENT_WARNING", nil))
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private var textInset : CGFloat {
        return OEXStyles.sharedStyles().standardHorizontalMargin()
    }

    private var textStyle : OEXTextStyle {
        return OEXTextStyle(weight: .Normal, size: .XSmall, color: OEXStyles.sharedStyles().neutralBase())
    }
}

Improve legibility of graded header

//
//  GradedSectionMessageView.swift
//  edX
//
//  Created by Akiva Leffert on 6/6/15.
//  Copyright (c) 2015 edX. All rights reserved.
//

import UIKit

class GradedSectionMessageView: UIView {
    let messageLabel = UILabel()

    init() {
        super.init(frame: CGRectZero)
        messageLabel.numberOfLines = 0
        messageLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
        addSubview(messageLabel)
        messageLabel.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(self).offset(textInset)
            make.trailing.equalTo(self).offset(-textInset)
            make.top.equalTo(self).offset(textInset)
            make.bottom.equalTo(self).offset(-textInset)
        }
        messageLabel.attributedText = textStyle.attributedStringWithText(OEXLocalizedString("GRADED_CONTENT_WARNING", nil))
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private var textInset : CGFloat {
        return OEXStyles.sharedStyles().standardHorizontalMargin()
    }

    private var textStyle : OEXTextStyle {
        return OEXTextStyle(weight: .Normal, size: .Small, color: OEXStyles.sharedStyles().neutralDark())
    }
}


//
//  Operators.swift
//  swiftz_core
//
//  Created by Maxwell Swadling on 28/06/2014.
//  Copyright (c) 2014 Maxwell Swadling. All rights reserved.
//

import Foundation

// Operators
infix operator • {
associativity right
}

infix operator |> {
associativity left
}

//operator  <| {
//  associativity right
//}

// "fmap" like
infix operator  <^> {
associativity left
}

// "imap" like
infix operator  <^^> {
associativity left
}

// "contramap" like
infix operator  <!> {
associativity left
}

// "ap" like
infix operator  <*> {
associativity left
}

// "extend" like
infix operator  =>> {
associativity left
}

/// Monadic bind operator, because >>= is already in the standard lib.
infix operator >>- {
associativity left
}

Change =>> to ->> for consistency.

//
//  Operators.swift
//  swiftz_core
//
//  Created by Maxwell Swadling on 28/06/2014.
//  Copyright (c) 2014 Maxwell Swadling. All rights reserved.
//

import Foundation

// Operators
infix operator • {
associativity right
}

infix operator |> {
associativity left
}

//operator  <| {
//  associativity right
//}

// "fmap" like
infix operator  <^> {
associativity left
}

// "imap" like
infix operator  <^^> {
associativity left
}

// "contramap" like
infix operator  <!> {
associativity left
}

// "ap" like
infix operator  <*> {
associativity left
}

// "extend" like
infix operator  ->> {
associativity left
}

/// Monadic bind operator, because >>= is already in the standard lib.
infix operator >>- {
associativity left
}


//  Created by Eric Marchand on 07/06/2017.
//  Copyright © 2017 Eric Marchand. All rights reserved.
//

import Foundation

extension MomUserInfo: XMLObject {

    public init?(xml: XML) {
        guard let element = xml.element, element.name == "userInfo" else {
            return nil
        }

        for child in xml.children {
            if let entry = MomUserInfoEntry(xml: child) {
                self.entries.append(entry)
            } else {
                MomXML.orphanCallback?(xml, MomUserInfoEntry.self)
            }
        }
    }

}

extension MomUserInfoEntry: XMLObject {

    public init?(xml: XML) {
        guard let element = xml.element, element.name == "element" else {
            return nil
        }
        guard let key = element.attribute(by: "key")?.text,
            let value = element.attribute(by: "value")?.text else {
                return nil
        }
        self.init(key: key, value: value)
    }

}

Fix decoding of userInfo (wrong element name)

//  Created by Eric Marchand on 07/06/2017.
//  Copyright © 2017 Eric Marchand. All rights reserved.
//

import Foundation

extension MomUserInfo: XMLObject {

    public init?(xml: XML) {
        guard let element = xml.element, element.name == "userInfo" else {
            return nil
        }

        for child in xml.children {
            if let entry = MomUserInfoEntry(xml: child) {
                self.entries.append(entry)
            } else {
                MomXML.orphanCallback?(xml, MomUserInfoEntry.self)
            }
        }
    }

}

extension MomUserInfoEntry: XMLObject {

    public init?(xml: XML) {
        guard let element = xml.element, element.name == "entry" else {
            return nil
        }
        guard let key = element.attribute(by: "key")?.text,
            let value = element.attribute(by: "value")?.text else {
                return nil
        }
        self.init(key: key, value: value)
    }

}


import Foundation

final class MCreateLocationStrategyReady:MCreateLocationStrategyProtocol
{
    func nextStep(model:MCreate)
    {
        model.changeStatus(
            statusType:MCreateStatusReady.self)
    }
}

Change map status on ready

import Foundation

final class MCreateLocationStrategyReady:MCreateLocationStrategyProtocol
{
    func nextStep(model:MCreate)
    {
        model.changeMapStatus(
            statusType:MCreateMapStatusContracted.self)
        model.changeStatus(
            statusType:MCreateStatusReady.self)
    }
}


//
// AppDelegate.swift
// PoseGallery
//
// Copyright © 2016 Trollwerks Inc. All rights reserved.
//

import UIKit

/**
Singleton UIApplication delegate
*/
@UIApplicationMain
public class AppDelegate: UIResponder, UIApplicationDelegate {

    // MARK: - Properties

    /// Root window
    public var window: UIWindow?

    // MARK: - UIApplicationDelegate implementations

    public func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        R.assertValid()

        startReporting()

        DataModel.model.intro(launchOptions)

        return true
    }

    public func applicationWillResignActive(application: UIApplication) {
    }

    public func applicationDidEnterBackground(application: UIApplication) {
        DataModel.model.outro()
    }

    public func applicationWillEnterForeground(application: UIApplication) {
        DataModel.model.reintro()
    }

    public func applicationDidBecomeActive(application: UIApplication) {
    }

    public func applicationWillTerminate(application: UIApplication) {
        DataModel.model.outro()
   }
}

Fix swiftlint missing_docs by depublicizing app delegate

//
// AppDelegate.swift
// PoseGallery
//
// Copyright © 2016 Trollwerks Inc. All rights reserved.
//

import UIKit

/**
Singleton UIApplication delegate
*/
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    // MARK: - Properties

    /// Root window
    var window: UIWindow?

    // MARK: - UIApplicationDelegate implementations

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        R.assertValid()

        startReporting()

        DataModel.model.intro(launchOptions)

        return true
    }

    func applicationWillResignActive(application: UIApplication) {
    }

    func applicationDidEnterBackground(application: UIApplication) {
        DataModel.model.outro()
    }

    func applicationWillEnterForeground(application: UIApplication) {
        DataModel.model.reintro()
    }

    func applicationDidBecomeActive(application: UIApplication) {
    }

    func applicationWillTerminate(application: UIApplication) {
        DataModel.model.outro()
   }
}


//
//  Git.swift
//  SwiftShell
//
//  Created by Justin Jia on 5/21/16.
//  Copyright © 2016 SwiftShell. All rights reserved.
//

import Foundation

public enum GitCommand: String {

    case initialize = "init"
    case status = "status"
    case add = "add"
    case commit = "commit"
    case checkout = "checkout"
    case branch = "branch"
    case rebase = "rebase"

}

public typealias git = Git

public class Git {

    public static func git(command: GitCommand, arguments: [String] = []) -> String {
        return execute(command: #function, arguments: [command.rawValue] + arguments)
    }

    public static func initialize() -> String {
        return git(command: .initialize)
    }

    public static func status() -> String {
        return git(command: .status)
    }

    public static func add(_ name: String...) -> String {
        return git(command: .add, arguments: name)
    }

    public enum CommitOption: String {
        case all = "-a"
    }

    public static func commit(_ message: String, options: CommitOption...) -> String {
        return git(command: .commit, arguments: ["-m", message] + options.map { $0.rawValue })
    }

}

Use enum instead of class as namespace wrapper

//
//  Git.swift
//  SwiftShell
//
//  Created by Justin Jia on 5/21/16.
//  Copyright © 2016 SwiftShell. All rights reserved.
//

import Foundation

public enum GitCommand: String {

    case initialize = "init"
    case status = "status"
    case add = "add"
    case commit = "commit"
    case checkout = "checkout"
    case branch = "branch"
    case rebase = "rebase"

}

public typealias git = Git

public enum Git {

    public static func git(command: GitCommand, arguments: [String] = []) -> String {
        return execute(command: #function, arguments: [command.rawValue] + arguments)
    }

    public static func initialize() -> String {
        return git(command: .initialize)
    }

    public static func status() -> String {
        return git(command: .status)
    }

    public static func add(_ name: String...) -> String {
        return git(command: .add, arguments: name)
    }

    public enum CommitOption: String {
        case all = "-a"
    }

    public static func commit(_ message: String, options: CommitOption...) -> String {
        return git(command: .commit, arguments: ["-m", message] + options.map { $0.rawValue })
    }

}


import UIKit

class ViewController: UIViewController {

    let post = Post()

    override func viewDidLoad() {
        super.viewDidLoad()

        post.fetch()
    }

}

Add success handler in example posts fetch

import UIKit

class ViewController: UIViewController {

    let posts = Post()

    override func viewDidLoad() {
        super.viewDidLoad()

        posts.fetch(success: {
            response in
            print(response)
        })
    }

}


//
//  SegueManager+Rswift.swift
//  Q42
//
//  Created by Tom Lokhorst on 2015-12-05.
//
//

import UIKit
import Rswift

extension SegueManager {

  public func performSegue<Segue, Source, Destination>(
    segueIdentifier: StoryboardSegueIdentifier<Segue, Source, Destination>,
    handler: TypedStoryboardSegueInfo<Segue, Source, Destination> -> Void)
  {
    performSegue(segueIdentifier.identifier) { segue in
      if let typedInfo = segue.typedInfoWithIdentifier(segueIdentifier) {
        handler(typedInfo)
      }
      else {
        print("Performing segue '\(segueIdentifier.identifier)', however destinationViewController is of type '\(segue.destinationViewController.dynamicType)' not of expected type '\(Destination.self)'.")
      }
    }
  }
}

Update to new R.swift version

//
//  SegueManager+Rswift.swift
//  Q42
//
//  Created by Tom Lokhorst on 2015-12-05.
//
//

import UIKit
import Rswift

extension SegueManager {

  public func performSegue<Segue, Source, Destination>(
    segueIdentifier: StoryboardSegueIdentifier<Segue, Source, Destination>,
    handler: TypedStoryboardSegueInfo<Segue, Source, Destination> -> Void)
  {
    performSegue(segueIdentifier.identifier) { segue in
      if let typedInfo = TypedStoryboardSegueInfo(segueIdentifier: segueIdentifier, segue: segue) {
        handler(typedInfo)
      }
      else {
        print("Performing segue '\(segueIdentifier.identifier)', however destinationViewController is of type '\(segue.destinationViewController.dynamicType)' not of expected type '\(Destination.self)'.")
      }
    }
  }
}


//  Copyright (c) 2015 Rob Rix. All rights reserved.

public enum Description<Index> {
	public static func end(index: Index) -> Description {
		return .End(Box(index))
	}

	var end: Index? {
		switch self {
		case let .End(index):
			return index.value
		default:
			return nil
		}
	}

	case End(Box<Index>)
}

import Box

Add an analysis function for type descriptions.

//  Copyright (c) 2015 Rob Rix. All rights reserved.

public enum Description<Index> {
	public static func end(index: Index) -> Description {
		return .End(Box(index))
	}

	var end: Index? {
		switch self {
		case let .End(index):
			return index.value
		default:
			return nil
		}
	}

	// MARK: Analyses

	public func analysis<T>(ifEnd: Index -> T) -> T {
		switch self {
		case let .End(index):
			return ifEnd(index.value)
		}
	}

	// MARK: Cases

	case End(Box<Index>)
}

import Box


//
//  EditorRequest.swift
//  SwiftSourceKit
//

import sourcekitd

extension Request {
    static func createEditorOpenRequest(filename: String, sourceText: String, enableSyntaxMap: Bool = true, enableSubStructure: Bool = false, compilerArgs: [String] = []) -> Request {
        return Request(dictionary: [
            KeyRequest: .UID(RequestEditorOpen),
            KeyName: .Str(filename),
            KeySourceText: .Str(sourceText),
            KeyEnableSyntaxMap: .Boolean(enableSyntaxMap),
            KeyEnableSubStructure: .Boolean(enableSubStructure),
            ], compilerArgs: compilerArgs)
    }

    static func createEditorCloseRequest(filename: String) -> Request {
        return Request(dictionary: [
            KeyRequest: .UID(RequestEditorClose),
            KeyName: .Str(filename),
            KeySourceText: .Str(""),
        ])
    }
}

Make editor request creation methods public

//
//  EditorRequest.swift
//  SwiftSourceKit
//

import sourcekitd

extension Request {
    public static func createEditorOpenRequest(filename: String, sourceText: String, enableSyntaxMap: Bool = true, enableSubStructure: Bool = false, compilerArgs: [String] = []) -> Request {
        return Request(dictionary: [
            KeyRequest: .UID(RequestEditorOpen),
            KeyName: .Str(filename),
            KeySourceText: .Str(sourceText),
            KeyEnableSyntaxMap: .Boolean(enableSyntaxMap),
            KeyEnableSubStructure: .Boolean(enableSubStructure),
            ], compilerArgs: compilerArgs)
    }

    public static func createEditorCloseRequest(filename: String) -> Request {
        return Request(dictionary: [
            KeyRequest: .UID(RequestEditorClose),
            KeyName: .Str(filename),
            KeySourceText: .Str(""),
        ])
    }
}


//
//  BugKrushaBulletMatchEntry.swift
//  CodeChallenge
//
//  Created by Jon-Tait Beason on 12/19/16.
//  Copyright © 2016 iosdevelopers. All rights reserved.
//

import Foundation

let bugKrushaBulletMatchEntry = CodeChallengeEntry<BulletChallenge>(name: "bugKrusha") { input in
    let count = input.0.characters.count

    guard
        count == input.1.characters.count
        else { return false }

    var resets = count
    var bulletIndex = 0
    var gunIndex = 0
    var matches = 0

    let bulletMarks = input.0.characters.flatMap { String($0) }
    let gunMarks = input.1.characters.flatMap { String($0) }

    while resets > 0  {
        if bulletMarks[bulletIndex] == gunMarks[gunIndex] {
            gunIndex += 1
            matches += 1
        } else {
            gunIndex = 0
            resets -= 1
            matches = 0
        }

        bulletIndex += 1
        bulletIndex %= count
        if matches == count { return true }
    }
    return false
}

Modify solution to fix a bug.

//
//  BugKrushaBulletMatchEntry.swift
//  CodeChallenge
//
//  Created by Jon-Tait Beason on 12/19/16.
//  Copyright © 2016 iosdevelopers. All rights reserved.
//

import Foundation

let bugKrushaBulletMatchEntry = CodeChallengeEntry<BulletChallenge>(name: "bugKrusha") { input in
    let count = input.0.characters.count

    guard
        count == input.1.characters.count
        else { return false }

    var resets = count
    var bulletIndex = 0
    var gunIndex = 0
    var matches = 0

    let bulletMarks = input.0.characters.flatMap { String($0) }
    var gunMarks = input.1.characters.flatMap { String($0) }

    while resets >= 0 && gunIndex < count {
        if bulletMarks[bulletIndex] == gunMarks[gunIndex] {
            gunIndex += 1
            matches += 1
            bulletIndex += 1
        } else {
            let last = gunMarks.removeLast()
            gunMarks = [last] + gunMarks
            gunIndex = 0
            bulletIndex = 0
            matches = 0

            resets -= 1
        }

        if matches == count { return true }
    }
    return false
}


//
//  UserCell.swift
//  TwitterClientDemo
//
//  Created by Yusuke Kita on 5/21/15.
//  Copyright (c) 2015 kitasuke. All rights reserved.
//

import UIKit

class UserCell: UITableViewCell {
    @IBOutlet weak var profileImageView: UIImageView?
    @IBOutlet weak var nameLabel: UILabel?
    @IBOutlet weak var screenLabel: UILabel?

    internal func setup(row: Int, user: User) {
        nameLabel?.text = user.name
        nameLabel?.tag = row
        let userViewModel = UserViewModel(user: user)
        screenLabel?.text = userViewModel.screenName
        screenLabel?.tag = row
        if let imageURL = NSURL(string: user.profileImage), let imageData = NSData(contentsOfURL: imageURL) {
            profileImageView?.image = UIImage(data: imageData)
        }
        profileImageView?.tag = row
        self.accessoryType = user.following == true ? .Checkmark : .None
    }
}

Implement SDWebImage like image loader by using cache

//
//  UserCell.swift
//  TwitterClientDemo
//
//  Created by Yusuke Kita on 5/21/15.
//  Copyright (c) 2015 kitasuke. All rights reserved.
//

import UIKit

class UserCell: UITableViewCell {
    @IBOutlet weak var profileImageView: UIImageView?
    @IBOutlet weak var nameLabel: UILabel?
    @IBOutlet weak var screenLabel: UILabel?
    private var imageCache = NSCache()
    private var queue = NSOperationQueue()

    internal func setup(row: Int, user: User) {
        nameLabel?.text = user.name
        nameLabel?.tag = row
        let userViewModel = UserViewModel(user: user)
        screenLabel?.text = userViewModel.screenName
        screenLabel?.tag = row

        // use image on cache, if no exists, fetch and store it on cache
        if let image = imageCache.objectForKey(row) as? UIImage {
            profileImageView?.image = image
        } else {
            let request = NSURLRequest(URL: NSURL(string: user.profileImage)!)
            NSURLConnection.sendAsynchronousRequest(request,
                queue: queue,
                completionHandler: { [unowned self] (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
                    if let image = UIImage(data: data) {
                        self.imageCache.setObject(image, forKey: row)
                        dispatch_async(dispatch_get_main_queue(), { () -> Void in
                            self.profileImageView?.image = image
                            self.profileImageView?.alpha = 0
                            UIView.animateWithDuration(1.0, animations: { () -> Void in // like SDWebImage
                                self.profileImageView?.alpha = 1
                            })
                        })
                    }
            })
        }
        profileImageView?.tag = row
        self.accessoryType = user.following == true ? .Checkmark : .None
    }
}


import Foundation

public enum SystemFontWeight: String {
    public static let allValues: [SystemFontWeight] = [
        .ultralight, .thin, .light, .regular, .medium, .semibold, .bold, .heavy, .black
    ]

    case ultralight
    case thin
    case light
    case regular
    case medium
    case semibold
    case bold
    case heavy
    case black

    public var name: String {
        switch self {
        case .ultralight:
            return "UIFontWeightUltraLight"
        case .thin:
            return "UIFontWeightThin"
        case .light:
            return "UIFontWeightLight"
        case .regular:
            return "UIFontWeightRegular"
        case .medium:
            return "UIFontWeightMedium"
        case .semibold:
            return "UIFontWeightSemibold"
        case .bold:
            return "UIFontWeightBold"
        case .heavy:
            return "UIFontWeightHeavy"
        case .black:
            return "UIFontWeightBlack"
        }
    }

    #if ReactantRuntime
    public var value: CGFloat {
        switch self {
        case .ultralight:
            return UIFontWeightUltraLight
        case .thin:
            return UIFontWeightThin
        case .light:
            return UIFontWeightLight
        case .regular:
            return UIFontWeightRegular
        case .medium:
            return UIFontWeightMedium
        case .semibold:
            return UIFontWeightSemibold
        case .bold:
            return UIFontWeightBold
        case .heavy:
            return UIFontWeightHeavy
        case .black:
            return UIFontWeightBlack
        }
    }
    #endif
}

Correct the order of System Font Weights.

import Foundation

public enum SystemFontWeight: String {
    public static let allValues: [SystemFontWeight] = [
        .thin, .ultralight, .light, .regular, .medium, .semibold, .bold, .heavy, .black
    ]

    case ultralight
    case thin
    case light
    case regular
    case medium
    case semibold
    case bold
    case heavy
    case black

    public var name: String {
        switch self {
        case .thin:
            return "UIFontWeightThin"
        case .ultralight:
            return "UIFontWeightUltraLight"
        case .light:
            return "UIFontWeightLight"
        case .regular:
            return "UIFontWeightRegular"
        case .medium:
            return "UIFontWeightMedium"
        case .semibold:
            return "UIFontWeightSemibold"
        case .bold:
            return "UIFontWeightBold"
        case .heavy:
            return "UIFontWeightHeavy"
        case .black:
            return "UIFontWeightBlack"
        }
    }

    #if ReactantRuntime
    public var value: CGFloat {
        switch self {
        case .thin:
            return UIFontWeightThin
        case .ultralight:
            return UIFontWeightUltraLight
        case .light:
            return UIFontWeightLight
        case .regular:
            return UIFontWeightRegular
        case .medium:
            return UIFontWeightMedium
        case .semibold:
            return UIFontWeightSemibold
        case .bold:
            return UIFontWeightBold
        case .heavy:
            return UIFontWeightHeavy
        case .black:
            return UIFontWeightBlack
        }
    }
    #endif
}


//
//  String+Attributed.swift
//  Attributed
//
//  Created by Nicholas Maccharoli on 2016/12/08.
//  Copyright © 2016年 Attributed. All rights reserved.
//

import Foundation
import UIKit

// MARK: Primary Extension

extension String {

    public func attributed(with attributes: Attributes) -> NSAttributedString {
        let attributes = attributes.dictionary
        return NSAttributedString(string: self, attributes: attributes)
    }

    public func attributed(_ attributeBlock: (Attributes) -> (Attributes)) -> NSAttributedString {
        let attributes = attributeBlock(Attributes())
        return attributed(with: attributes)
    }
}

extension NSAttributedString {

    public func modified(with attributes: Attributes, for range: NSRange) -> NSAttributedString {
        let result = NSMutableAttributedString(attributedString: self)
        result.add(attributes, to: range)
        return NSAttributedString(attributedString: result)
    }

}

extension NSMutableAttributedString {

    public func add(_ attributes: Attributes, to range: NSRange) {
        self.addAttributes(attributes.dictionary, range: range)
    }

}

Clean up unneeded use of self.

//
//  String+Attributed.swift
//  Attributed
//
//  Created by Nicholas Maccharoli on 2016/12/08.
//  Copyright © 2016年 Attributed. All rights reserved.
//

import Foundation
import UIKit

// MARK: Primary Extension

extension String {

    public func attributed(with attributes: Attributes) -> NSAttributedString {
        let attributes = attributes.dictionary
        return NSAttributedString(string: self, attributes: attributes)
    }

    public func attributed(_ attributeBlock: (Attributes) -> (Attributes)) -> NSAttributedString {
        let attributes = attributeBlock(Attributes())
        return attributed(with: attributes)
    }
}

extension NSAttributedString {

    public func modified(with attributes: Attributes, for range: NSRange) -> NSAttributedString {
        let result = NSMutableAttributedString(attributedString: self)
        result.add(attributes, to: range)
        return NSAttributedString(attributedString: result)
    }

}

extension NSMutableAttributedString {

    public func add(_ attributes: Attributes, to range: NSRange) {
        addAttributes(attributes.dictionary, range: range)
    }

}


//
//  MasterUnreadIndicatorView.swift
//  NetNewsWire
//
//  Created by Brent Simmons on 2/16/16.
//  Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//

import UIKit

class MasterUnreadIndicatorView: UIView {

	var isSelected = false {
		didSet {
			setNeedsDisplay()
		}
	}

	override init(frame: CGRect) {
		super.init(frame: frame)
		self.isOpaque = false
	}

	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		self.isOpaque = false
	}

	static let bezierPath: UIBezierPath = {
		let r = CGRect(x: 0.0, y: 0.0, width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension)
		return UIBezierPath(ovalIn: r)
	}()

    override func draw(_ dirtyRect: CGRect) {
		let color = isSelected ? AppAssets.tableViewCellHighlightedTextColor : AppAssets.primaryAccentColor
		color.setFill()
		MasterUnreadIndicatorView.bezierPath.fill()
    }

}

Change unread indicator to use secondary accent color

//
//  MasterUnreadIndicatorView.swift
//  NetNewsWire
//
//  Created by Brent Simmons on 2/16/16.
//  Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//

import UIKit

class MasterUnreadIndicatorView: UIView {

	var isSelected = false {
		didSet {
			setNeedsDisplay()
		}
	}

	override init(frame: CGRect) {
		super.init(frame: frame)
		self.isOpaque = false
	}

	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		self.isOpaque = false
	}

	static let bezierPath: UIBezierPath = {
		let r = CGRect(x: 0.0, y: 0.0, width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension)
		return UIBezierPath(ovalIn: r)
	}()

    override func draw(_ dirtyRect: CGRect) {
		let color = isSelected ? AppAssets.tableViewCellHighlightedTextColor : AppAssets.secondaryAccentColor
		color.setFill()
		MasterUnreadIndicatorView.bezierPath.fill()
    }

}


//
//  HALAdapterTests.swift
//  Representor
//
//  Created by Kyle Fuller on 08/11/2014.
//  Copyright (c) 2014 Apiary. All rights reserved.
//

import Cocoa
import XCTest
import Representor

class HALAdapterTests: XCTestCase {
    func fixture() -> Dictionary<String, AnyObject> {
        return JSONFixture("poll.hal", self)
    }

    func testConversionFromHAL() {
        let representor = Representor(hal: fixture())
        let representorFixture = PollFixture(self)

        XCTAssertEqual(representor, representorFixture)
    }

    func testConversionToHAL() {
        let embeddedRepresentor = Representor(transitions:[:], representors:[:], attributes:["name": "Embedded"], links:[:], metadata:[:])
        let representor = Representor(transitions:[:], representors:["embedded": [embeddedRepresentor]], attributes:["name":"Kyle"], links:["next": "/next/"], metadata:[:])

        let representation = representor.asHAL()

        let fixture = [
            "_links": [
                "next": [ "href": "/next/" ],
            ],
            "_embedded": [
                "embedded": [
                    [
                        "name": "Embedded",
                    ]
                ]
            ],
            "name": "Kyle",
        ]

        XCTAssertEqual(representation as NSObject, fixture as NSObject)
    }
}

Use fixtures for converting to HAL

//
//  HALAdapterTests.swift
//  Representor
//
//  Created by Kyle Fuller on 08/11/2014.
//  Copyright (c) 2014 Apiary. All rights reserved.
//

import Cocoa
import XCTest
import Representor

class HALAdapterTests: XCTestCase {
    func fixture() -> Dictionary<String, AnyObject> {
        return JSONFixture("poll.hal", self)
    }

    func testConversionFromHAL() {
        let representor = Representor(hal: fixture())
        let representorFixture = PollFixture(self)

        XCTAssertEqual(representor, representorFixture)
    }

    func testConversionToHAL() {
        let representor = PollFixture(self)
        let representation = representor.asHAL()

        XCTAssertEqual(representation as NSObject, fixture() as NSObject)
    }
}


//
//  Window.swift
//  goodbar
//
//  Created by Peter Hajas on 5/22/16.
//  Copyright © 2016 Peter Hajas. All rights reserved.
//

import Cocoa

class Window : NSWindow {
    private func updateSizeAndScreen() {
        let screenToUse = NSScreen.screens()![0]

        let screenRect = screenToUse.visibleFrame

        let yPosition = screenRect.size.height - BarGeometry.height

        let windowRect = CGRectMake(0, yPosition, screenRect.width, BarGeometry.height)

        self.minSize = windowRect.size
        self.maxSize = windowRect.size

        self.setFrame(windowRect, display: true)
    }

    override func constrainFrameRect(frameRect: NSRect, toScreen screen: NSScreen?) -> NSRect {
        return frameRect
    }

    private func commonInit() {
        let cgLevelKey = CGWindowLevelKey.DesktopWindowLevelKey
        let cgLevel = CGWindowLevelForKey(cgLevelKey)
        let level = Int(cgLevel)

        self.level = level
        self.collectionBehavior = [.Default, .Transient]

        updateSizeAndScreen()
    }

    override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, defer flag: Bool) {
        super.init(contentRect: contentRect, styleMask: aStyle, backing: bufferingType, defer: flag)
        commonInit()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        commonInit()
    }
}

Fix window layout with a small fudge factor

//
//  Window.swift
//  goodbar
//
//  Created by Peter Hajas on 5/22/16.
//  Copyright © 2016 Peter Hajas. All rights reserved.
//

import Cocoa

class Window : NSWindow {
    private func updateSizeAndScreen() {
        let screenToUse = NSScreen.screens()![0]

        let screenRect = screenToUse.visibleFrame

        // 4 is a fudge factor
        let yPosition = screenRect.size.height - BarGeometry.height + 4

        let windowRect = CGRectMake(0, yPosition, screenRect.width, BarGeometry.height)

        self.minSize = windowRect.size
        self.maxSize = windowRect.size

        self.setFrame(windowRect, display: true)
    }

    override func constrainFrameRect(frameRect: NSRect, toScreen screen: NSScreen?) -> NSRect {
        return frameRect
    }

    private func commonInit() {
        let cgLevelKey = CGWindowLevelKey.DesktopWindowLevelKey
        let cgLevel = CGWindowLevelForKey(cgLevelKey)
        let level = Int(cgLevel)

        self.level = level
        self.collectionBehavior = [.Default, .Transient]

        updateSizeAndScreen()
    }

    override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, defer flag: Bool) {
        super.init(contentRect: contentRect, styleMask: aStyle, backing: bufferingType, defer: flag)
        commonInit()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        commonInit()
    }
}


//
//  TraktManager+Resources.swift
//  TraktKit
//
//  Created by Maxamilian Litteral on 6/14/21.
//  Copyright © 2021 Maximilian Litteral. All rights reserved.
//

import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
extension TraktManager {

    func show(id: CustomStringConvertible) -> ShowResource {
        ShowResource(id: id, traktManager: self)
    }

    func season(showId: CustomStringConvertible, season: Int) -> SeasonResource {
        SeasonResource(showId: showId, seasonNumber: season, traktManager: self)
    }

    func episode(showId: CustomStringConvertible, season: Int, episode: Int) -> EpisodeResource {
        EpisodeResource(showId: showId, seasonNumber: season, episodeNumber: episode, traktManager: self)
    }

    func currentUser() -> CurrentUserResource {
        CurrentUserResource()
    }

    func user(_ username: String) -> UsersResource {
        UsersResource(username: username, traktManager: self)
    }
}

Mark async resources as public

//
//  TraktManager+Resources.swift
//  TraktKit
//
//  Created by Maxamilian Litteral on 6/14/21.
//  Copyright © 2021 Maximilian Litteral. All rights reserved.
//

import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
extension TraktManager {

    public func show(id: CustomStringConvertible) -> ShowResource {
        ShowResource(id: id, traktManager: self)
    }

    public func season(showId: CustomStringConvertible, season: Int) -> SeasonResource {
        SeasonResource(showId: showId, seasonNumber: season, traktManager: self)
    }

    public func episode(showId: CustomStringConvertible, season: Int, episode: Int) -> EpisodeResource {
        EpisodeResource(showId: showId, seasonNumber: season, episodeNumber: episode, traktManager: self)
    }

    public func currentUser() -> CurrentUserResource {
        CurrentUserResource()
    }

    public func user(_ username: String) -> UsersResource {
        UsersResource(username: username, traktManager: self)
    }
}


import Foundation
import Messages

class MessagesViewController: MSMessagesAppViewController {
  @IBAction func sendMessage() {
    self.activeConversation?.sendText("Hello, extension!", completionHandler: nil)
  }
}

Add license to example code for ios_imessage_extension.

// Copyright 2018 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import Messages

class MessagesViewController: MSMessagesAppViewController {
  @IBAction func sendMessage() {
    self.activeConversation?.sendText("Hello, extension!", completionHandler: nil)
  }
}


//
//  Compatibility.swift
//  BonMot
//
//  Created by Brian King on 8/24/16.
//  Copyright © 2016 Raizlabs. All rights reserved.
//

#if os(OSX)
    import AppKit
#else
    import UIKit
#endif

/// This file declares extensions to system types to provide a compatible API
/// between Swift iOS, macOS, watchOS, and tvOS.

#if os(OSX)
#else
    public extension NSParagraphStyle {

        typealias LineBreakMode = NSLineBreakMode

    }

    public extension NSLayoutConstraint {

        typealias Attribute = NSLayoutAttribute
        typealias Relation = NSLayoutRelation
    }
#endif

Extend NSLayoutConstraint only on platforms where it exists.

//
//  Compatibility.swift
//  BonMot
//
//  Created by Brian King on 8/24/16.
//  Copyright © 2016 Raizlabs. All rights reserved.
//

#if os(OSX)
    import AppKit
#else
    import UIKit
#endif

/// This file declares extensions to system types to provide a compatible API
/// between Swift iOS, macOS, watchOS, and tvOS.

#if os(OSX)
#else
    public extension NSParagraphStyle {

        typealias LineBreakMode = NSLineBreakMode

    }

    #if os(iOS) || os(tvOS)
        public extension NSLayoutConstraint {

            typealias Attribute = NSLayoutAttribute
            typealias Relation = NSLayoutRelation
        }
    #endif
#endif


import Foundation;

println("Hello, World!")

// Class examples

class lowerCamelCase {
    var x: String = "hello";
    let b = 2;

    func demo()
    {
        for var x = 0; ; {
            print(x);
        };

        if temperatureInFahrenheit <= 32 {
            println("It's very cold. Consider wearing a scarf.");
        } else if temperatureInFahrenheit >= 86 {
            println("It's really warm. Don't forget to wear sunscreen.");
        } else {
            println("It's not that cold. Wear a t-shirt.");
        }
    };
};

Add enum special case for ';' test

import Foundation;

println("Hello, World!")

enum CompassPoint {
    case North;
    case South;
    case East;
    case West;
};

// Class examples

class lowerCamelCase {
    var x: String = "hello";
    let b = 2;

    func demo()
    {
        for var x = 0; ; {
            print(x);
        };

        if temperatureInFahrenheit <= 32 {
            println("It's very cold. Consider wearing a scarf.");
        } else if temperatureInFahrenheit >= 86 {
            println("It's really warm. Don't forget to wear sunscreen.");
        } else {
            println("It's not that cold. Wear a t-shirt.");
        }
    };
};


let a = 12

// rdar://problem/30346106
// Invalid offset should not trigger a crash.

// RUN: not %sourcekitd-test 2>&1 \
// RUN:   -req=open %s -- %s == \
// RUN:   -req=edit -async -offset=0 -length=200 -replace='' %s -- %s == \
// RUN:   -req=cursor -offset=250 %s -- %s

// rdar://problem/38162017
// REQUIRES: OS=macosx

Disable test failing rarely in CI until we can fix

let a = 12

// rdar://problem/30346106
// Invalid offset should not trigger a crash.

// RUN: not %sourcekitd-test 2>&1 \
// RUN:   -req=open %s -- %s == \
// RUN:   -req=edit -async -offset=0 -length=200 -replace='' %s -- %s == \
// RUN:   -req=cursor -offset=250 %s -- %s

// rdar://problem/38162017
// REQUIRES: OS=macosx

// FIXME: this test is failing (rarely) in CI
// REQUIRES: rdar71468441


import TextInputSources
import Commander

let main = Group {
    $0.command("current", description: "Print the current selected input source") {
        let inputSource = TextInputSources.current
        print(inputSource.id)
    }

    $0.command("list", description: "List enabled input sources") {
        for inputSource in TextInputSources.find(filtering: [
            .category: InputSource.Category.keyboard,
            .selectCapability: true,
        ]) {
            print(inputSource.id)
        }
    }

    $0.command("select",
               Argument<String>("id", description: "Input source ID"),
               description: "Select an input source")
    { (id) in
        guard let inputSource = TextInputSources.find(filtering: [.id: id]).first else {
            throw CUIError.inputSourceIsNotFound(forID: id)
        }
        try TextInputSources.select(inputSource)
    }
}

main.run()

Add --name flag to current subcommand

import TextInputSources
import Commander

let main = Group {
    $0.command("current",
               Flag("name", description: "Print input source name instead of ID"),
               description: "Print the current selected input source")
    { (name) in
        let inputSource = TextInputSources.current
        if name {
            print(inputSource.localizedName)
        } else {
            print(inputSource.id)
        }
    }

    $0.command("list", description: "List enabled input sources") {
        for inputSource in TextInputSources.find(filtering: [
            .category: InputSource.Category.keyboard,
            .selectCapability: true,
        ]) {
            print(inputSource.id)
        }
    }

    $0.command("select",
               Argument<String>("id", description: "Input source ID"),
               description: "Select an input source")
    { (id) in
        guard let inputSource = TextInputSources.find(filtering: [.id: id]).first else {
            throw CUIError.inputSourceIsNotFound(forID: id)
        }
        try TextInputSources.select(inputSource)
    }
}

main.run()


// RUN: %target-swift-frontend -emit-silgen %s

func foo<U>(_ x: U?) {
  _ = "\(anyLabelHere: x)"
}

// This one also crashes in a slightly different place
func bar(_ x: Int?) {
  _ = "\(anyLabelHere: x)"
}

Correct run line on unfixed crasher

// RUN: not --crash %target-swift-frontend %s -emit-ir

func foo<U>(_ x: U?) {
  _ = "\(anyLabelHere: x)"
}

// This one also crashes in a slightly different place
func bar(_ x: Int?) {
  _ = "\(anyLabelHere: x)"
}


// RUN: rm -rf %t/clang-module-cache
// RUN: %swift -target x86_64-apple-macosx10.9 -module-cache-path %t/clang-module-cache -sdk %S/Inputs -I=%S/Inputs -enable-source-import %s -emit-ir | FileCheck %s

import Foundation

// CHECK-LABEL: @_TMdC28class_with_stub_initializers3Foo =
// CHECK:         %C28class_with_stub_initializers3Foo* (i64, %C28class_with_stub_initializers3Foo*)*
// -- The init() stub should get no vtable entry
// CHECK-NOT:     %C28class_with_stub_initializers3Foo* (%C28class_with_stub_initializers3Foo*)*
class Foo: NSObject {
  init(x: Int) { super.init() }
}

Verify that a stub initializer appears nowhere within the vtable.

// RUN: rm -rf %t/clang-module-cache
// RUN: %swift -target x86_64-apple-macosx10.9 -module-cache-path %t/clang-module-cache -sdk %S/Inputs -I=%S/Inputs -enable-source-import %s -emit-ir | FileCheck %s

import Foundation

// CHECK:       @_TMd[[FOO:C28class_with_stub_initializers3Foo]] =
// -- The init() stub should get no vtable entry
// CHECK-NOT:     %[[FOO]]* (%[[FOO]]*)*
// CHECK:         %[[FOO]]* (i64, %[[FOO]]*)*
// -- The init() stub should get no vtable entry
// CHECK-NOT:     %[[FOO]]* (%[[FOO]]*)*
class Foo: NSObject {
  init(x: Int) { super.init() }
}


// swift-tools-version:4.2
import PackageDescription

let package = Package(
    name: "Typist",
    // platforms: [.iOS("8.0")],
    products: [
        .library(name: "Typist", targets: ["Typist"])
    ],
    targets: [
        .target(
            name: "Typist",
            path: "Typist.swift"
        )
    ]
)

Update SwiftPM manifest code pointer

// swift-tools-version:4.2
import PackageDescription

let package = Package(
    name: "Typist",
    // platforms: [.iOS("8.0")],
    products: [
        .library(name: "Typist", targets: ["Typist"])
    ],
    targets: [
        .target(
            name: "Typist",
            path: ".",
            exclude: ["Typist"],
            sources: "Typist.swift"
        )
    ]
)


// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "Song",
    products: [
        .executable(name: "sing", targets: ["Sing"]),
        .library(name: "Song", targets: ["Song"])
    ],
    dependencies: [
        .package(url: "https://github.com/dcutting/Syft.git", .branch("develop"))
    ],
    targets: [
        .target(
            name: "Sing",
            dependencies: ["Song"]),
        .target(
            name: "Song",
            dependencies: ["Syft"]),
        .testTarget(
            name: "SongTests",
            dependencies: ["Song"])
    ]
)

Change REPL tool name to song.

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "Song",
    products: [
        .executable(name: "song", targets: ["Sing"]),
        .library(name: "Song", targets: ["Song"])
    ],
    dependencies: [
        .package(url: "https://github.com/dcutting/Syft.git", .branch("develop"))
    ],
    targets: [
        .target(
            name: "Sing",
            dependencies: ["Song"]),
        .target(
            name: "Song",
            dependencies: ["Syft"]),
        .testTarget(
            name: "SongTests",
            dependencies: ["Song"])
    ]
)


// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "HandyUIKit",
    platforms: [.iOS(.v9), .tvOS(.v9)],
    products: [
        .library(name: "HandyUIKit", targets: ["HandyUIKit"])
    ],
    targets: [
        .target(
            name: "HandyUIKit",
            path: "Frameworks/HandyUIKit"
        ),
        .testTarget(
            name: "HandyUIKitTests",
            dependencies: ["HandyUIKit"]
        )
    ]
)

#if swift(>=5.6)
  // Add the documentation compiler plugin if possible
  package.dependencies.append(
    .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
  )
#endif

Remove DocC compiler plugin section (no longer needed)


//
//  ResultFormatter.swift
//  xcconfig-extractor
//
//  Created by Toshihiro Suzuki on 2017/04/30.
//  Copyright © 2017 Toshihiro Suzuki. All rights reserved.
//

import Foundation

class ResultFormatter {
    let config: Config
    init(config: Config) {
        self.config = config
    }
    private var header: [String] {
        let signature = "// Generated using xcconfig-extractor \(Config.version) by Toshihiro Suzuki - https://github.com/toshi0383/xcconfig-extractor"
        return [signature]
    }
    private func addInclude(filePath: String) -> String {
        return "#include \"\(filePath)\""
    }
    func format(result: ResultObject, includes: [String] = []) -> [String] {
        return header
            + result.includes.map(addInclude)
            + includes.map(addInclude)
            + result.settings
    }
}

Add new line at the end of xcconfig

//
//  ResultFormatter.swift
//  xcconfig-extractor
//
//  Created by Toshihiro Suzuki on 2017/04/30.
//  Copyright © 2017 Toshihiro Suzuki. All rights reserved.
//

import Foundation

class ResultFormatter {
    let config: Config
    init(config: Config) {
        self.config = config
    }
    private var header: [String] {
        let signature = "// Generated using xcconfig-extractor \(Config.version) by Toshihiro Suzuki - https://github.com/toshi0383/xcconfig-extractor"
        return [signature]
    }
    private func addInclude(filePath: String) -> String {
        return "#include \"\(filePath)\""
    }
    func format(result: ResultObject, includes: [String] = []) -> [String] {
        return header
            + result.includes.map(addInclude)
            + includes.map(addInclude)
            + result.settings
            + ["\n"]
    }
}


// swift-tools-version:5.0

import PackageDescription

let package = Package(
  name: "AMPopTip",
  products: [
    .library(
      name: "AMPopTip",
      targets: ["AMPopTip"])
  ],
  targets: [
    .target(
      name: "AMPopTip",
      path: "Source")
  ]
)

Update swift package manager with platform

// swift-tools-version:5.0

import PackageDescription

let package = Package(
  name: "AMPopTip",
  platforms: [.iOS(.v12), .macOS(.v10_14), .tvOS(.v12), .watchOS(.v5)],
  products: [
    .library(
      name: "AMPopTip",
      targets: ["AMPopTip"])
  ],
  targets: [
    .target(
      name: "AMPopTip",
      path: "Source")
  ]
)


import Foundation
import XCTest

class UITestCase: XCTestCase {
    let app = XCUIApplication()

    var loginScreen: LoginScreen!
    var welcomeScreen: WelcomeScreen!

    override func setUp() {
        super.setUp()

        continueAfterFailure = true
        app.launch()

        loginScreen = LoginScreen(self)
        welcomeScreen = WelcomeScreen(self)
    }
}

Delete the reference of each object in each teardown

import Foundation
import XCTest

class UITestCase: XCTestCase {
    let app = XCUIApplication()

    var loginScreen: LoginScreen!
    var welcomeScreen: WelcomeScreen!

    override func setUp() {
        super.setUp()

        continueAfterFailure = true
        app.launch()

        loginScreen = LoginScreen(self)
        welcomeScreen = WelcomeScreen(self)
    }

    override func tearDown() {
        loginScreen = nil
        welcomeScreen = nil
    }
}


//
//  StringExtension.swift
//  Client
//
//  Created by Mahmoud Adam on 11/9/15.
//  Copyright © 2015 Cliqz. All rights reserved.
//

import Foundation

extension String {

    var boolValue: Bool {
        return NSString(string: self).boolValue
    }

    func trim() -> String {
        let newString = self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
        return newString
    }

    static func generateRandomString(length: Int, alphabet: String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") -> String {
        var randomString = ""

        let rangeLength = UInt32 (alphabet.characters.count)

        for (var i=0; i < length; i++){
            let randomIndex = Int(arc4random_uniform(rangeLength))
            randomString.append(alphabet[alphabet.startIndex.advancedBy(randomIndex)])
        }

        return String(randomString)
    }

    func replace(string:String, replacement:String) -> String {
        return self.stringByReplacingOccurrencesOfString(string, withString: replacement, options: NSStringCompareOptions.LiteralSearch, range: nil)
    }

    func removeWhitespaces() -> String {
        return self.replace(" ", replacement: "")
    }

    func escapeURL() -> String {
        return self.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet())!
    }

}

Enforce escaping of `=` character so that google card works

//
//  StringExtension.swift
//  Client
//
//  Created by Mahmoud Adam on 11/9/15.
//  Copyright © 2015 Cliqz. All rights reserved.
//

import Foundation

extension String {

    var boolValue: Bool {
        return NSString(string: self).boolValue
    }

    func trim() -> String {
        let newString = self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
        return newString
    }

    static func generateRandomString(length: Int, alphabet: String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") -> String {
        var randomString = ""

        let rangeLength = UInt32 (alphabet.characters.count)

        for (var i=0; i < length; i++){
            let randomIndex = Int(arc4random_uniform(rangeLength))
            randomString.append(alphabet[alphabet.startIndex.advancedBy(randomIndex)])
        }

        return String(randomString)
    }

    func replace(string:String, replacement:String) -> String {
        return self.stringByReplacingOccurrencesOfString(string, withString: replacement, options: NSStringCompareOptions.LiteralSearch, range: nil)
    }

    func removeWhitespaces() -> String {
        return self.replace(" ", replacement: "")
    }

    func escapeURL() -> String {
        let allowedCharacterSet = NSMutableCharacterSet()
        allowedCharacterSet.formUnionWithCharacterSet(NSCharacterSet.URLQueryAllowedCharacterSet())
        allowedCharacterSet.removeCharactersInString("=")

        return self.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacterSet)!
    }

}


// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules %s -verify

// REQUIRES: objc_interop

// Test the use of Objective-C categories on the value types that
// bridge to Objective-C class types.
import Foundation
import AppKit

func testStringBridge(_ str: String) {
  var str2 = str.nsStringMethod()!
  var int = String.nsStringClassMethod()
  var str3 = str.nsStringProperty!

  // Make sure the types worked out as expected
  var str: String = str2
  str2 = str
  str = str3
  str3 = str

  var int2: Int = 0
  int = int2

  // Not bridged because it's in the Foundation module.
  str.notBridgedMethod() // expected-error{{value of type 'String' has no member 'notBridgedMethod'}}
}

func testDictionaryBridge(_ dict: Dictionary<String, String>) {
  var d2 = dict.nsDictionaryMethod() // expected-error{{value of type 'Dictionary<String, String>' has no member 'nsDictionaryMethod'}}
  var int = Dictionary<String, String>.nsDictionaryClassMethod() // expected-error{{type 'Dictionary<String, String>' has no member 'nsDictionaryClassMethod'}}
  var d3 = dict.nsDictionaryProperty  // expected-error{{value of type 'Dictionary<String, String>' has no member 'nsDictionaryProperty'}}
}

func testStringBridge() {
  var i = String.someFactoryMethod()
  i = 17
  _ = i
}

Update test with the right metatype

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules %s -verify

// REQUIRES: objc_interop

// Test the use of Objective-C categories on the value types that
// bridge to Objective-C class types.
import Foundation
import AppKit

func testStringBridge(_ str: String) {
  var str2 = str.nsStringMethod()!
  var int = NSString.nsStringClassMethod()
  var str3 = str.nsStringProperty!

  // Make sure the types worked out as expected
  var str: String = str2
  str2 = str
  str = str3
  str3 = str

  var int2: Int = 0
  int = int2

  // Not bridged because it's in the Foundation module.
  str.notBridgedMethod() // expected-error{{value of type 'String' has no member 'notBridgedMethod'}}
}

func testDictionaryBridge(_ dict: Dictionary<String, String>) {
  var d2 = dict.nsDictionaryMethod() // expected-error{{value of type 'Dictionary<String, String>' has no member 'nsDictionaryMethod'}}
  var int = Dictionary<String, String>.nsDictionaryClassMethod() // expected-error{{type 'Dictionary<String, String>' has no member 'nsDictionaryClassMethod'}}
  var d3 = dict.nsDictionaryProperty  // expected-error{{value of type 'Dictionary<String, String>' has no member 'nsDictionaryProperty'}}
}

func testStringBridge() {
  var i = String.someFactoryMethod()
  i = 17
  _ = i
}


//
//  RetrievingImageTests.swift
//  ImageCacheTests
//
//  Created by Julian Grosshauser on 12/07/15.
//  Copyright © 2015 Julian Grosshauser. All rights reserved.
//

import XCTest
import ImageCache

class RetrievingImageTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }
}

Test that cached image gets retrieved as expected

//
//  RetrievingImageTests.swift
//  ImageCacheTests
//
//  Created by Julian Grosshauser on 12/07/15.
//  Copyright © 2015 Julian Grosshauser. All rights reserved.
//

import XCTest
import ImageCache
import DiskCache

class RetrievingImageTests: XCTestCase {

    override func setUp() {
        super.setUp()

        clearAllCachedImages()
    }

    func testRetrievingImageCallsCompletionHandlerWithSuccessAndExpectedImage() {
        let key = "TestRetrievingImage"
        let expectedImage = testImageWithName("Square", fileExtension: .PNG)

        createImageInDiskCache(expectedImage, forKey: key)

        let completionExpectation = expectationWithDescription("completionHandler called")

        let completionHandler: Result<UIImage> -> Void = { result in
            switch result {
            case .Success(let image):
                if let expectedImageData = UIImagePNGRepresentation(expectedImage), imageData = UIImagePNGRepresentation(image) {
                    XCTAssertEqual(expectedImageData, imageData, "Retrieved image isn't equal to expected image")

                    completionExpectation.fulfill()
                } else {
                    XCTFail("Creating image data failed")
                }
            case .Failure(let error):
                XCTFail("Retrieving image failed: \(error)")
            }
        }

        do {
            try imageCache.retrieveImageForKey(key, completionHandler: completionHandler)
        } catch {
            XCTFail("Retrieving image failed: \(error)")
        }

        waitForExpectationsWithTimeout(expectationTimeout, handler: nil)
    }
}


//
//  Publisher.swift
//  ZamzamCore
//
//  Created by Basem Emara on 2021-01-02.
//  Copyright © 2021 Zamzam Inc. All rights reserved.
//

import Combine

public extension Optional where Wrapped: Combine.Publisher {
    /// Returns the wrapped value of a publisher or defaults to an empty publisher.
    func orEmpty() -> AnyPublisher<Wrapped.Output, Wrapped.Failure> {
        self?.eraseToAnyPublisher() ?? Empty().eraseToAnyPublisher()
    }
}

Add Concurrency Combine sink convenience API

//
//  Publisher.swift
//  ZamzamCore
//
//  Created by Basem Emara on 2021-01-02.
//  Copyright © 2021 Zamzam Inc. All rights reserved.
//

import Combine

public extension Publisher where Failure == Never {
    /// Attaches a subscriber with closure-based behavior to a publisher that never fails.
    func sink(receiveValue: @escaping ((Self.Output) async throws -> Void)) -> AnyCancellable {
        sink { value in Task { try await receiveValue(value) } }
    }
}

public extension Optional where Wrapped: Combine.Publisher {
    /// Returns the wrapped value of a publisher or defaults to an empty publisher.
    func orEmpty() -> AnyPublisher<Wrapped.Output, Wrapped.Failure> {
        self?.eraseToAnyPublisher() ?? Empty().eraseToAnyPublisher()
    }
}


//
//  SpringBoardLaunchedAppViewController.swift
//  UIPlayground
//
//  Created by Kip Nicol on 9/27/16.
//  Copyright © 2016 Kip Nicol. All rights reserved.
//

import UIKit

class SpringBoardLaunchedAppViewController: UIViewController {

    let exitButton = UIButton()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .red

        view.addSubview(exitButton)
        exitButton.translatesAutoresizingMaskIntoConstraints = false
        exitButton.anchorConstraintsToCenterInSuperview()
        exitButton.setTitle("Exit", for: .normal)
        exitButton.titleLabel?.font = .systemFont(ofSize: 16)
        exitButton.addTarget(self, action: #selector(exitPressed), for: .touchUpInside)
    }

    // MARK: - Actions

    func exitPressed(_ sender: UIButton) {
        dismiss(animated: true, completion: nil)
    }
}

Update launched app vc exit button.

//
//  SpringBoardLaunchedAppViewController.swift
//  UIPlayground
//
//  Created by Kip Nicol on 9/27/16.
//  Copyright © 2016 Kip Nicol. All rights reserved.
//

import UIKit

class SpringBoardLaunchedAppViewController: UIViewController {

    let exitButton = UIButton()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .white

        view.addSubview(exitButton)
        exitButton.translatesAutoresizingMaskIntoConstraints = false
        exitButton.anchorConstraintsToCenterInSuperview()
        exitButton.contentEdgeInsets = UIEdgeInsets(top: 7, left: 20, bottom: 7, right: 20)
        exitButton.setTitle("Exit", for: .normal)
        exitButton.setTitleColor(.white, for: .normal)
        exitButton.setTitleColor(.red, for: .highlighted)
        exitButton.titleLabel?.font = .systemFont(ofSize: 26)
        exitButton.addTarget(self, action: #selector(exitPressed), for: .touchUpInside)
        exitButton.backgroundColor = .black
        exitButton.clipsToBounds = true
        exitButton.layer.cornerRadius = 8
    }

    // MARK: - Actions

    func exitPressed(_ sender: UIButton) {
        dismiss(animated: true, completion: nil)
    }
}


//
//  KnownFacets.swift
//  SoftU2F
//
//  Created by Benjamin P Toews on 1/27/17.
//

import Foundation

let KnownFacets: [Data: String] = [
    SHA256.digest("https://github.com/u2f/trusted_facets"): "https://github.com",
    SHA256.digest("https://demo.yubico.com"): "https://demo.yubico.com",
    SHA256.digest("https://www.dropbox.com/u2f-app-id.json"): "https://dropbox.com",
    SHA256.digest("https://www.gstatic.com/securitykey/origins.json"): "https://google.com",
    SHA256.digest("https://vault.bitwarden.com/app-id.json"): "https://vault.bitwarden.com",
    SHA256.digest("https://keepersecurity.com"): "https://keepersecurity.com",
    SHA256.digest("https://api-9dcf9b83.duosecurity.com"): "https://api-9dcf9b83.duosecurity.com"
]

Add Stripe to known facets.

//
//  KnownFacets.swift
//  SoftU2F
//
//  Created by Benjamin P Toews on 1/27/17.
//

import Foundation

let KnownFacets: [Data: String] = [
    SHA256.digest("https://github.com/u2f/trusted_facets"): "https://github.com",
    SHA256.digest("https://demo.yubico.com"): "https://demo.yubico.com",
    SHA256.digest("https://www.dropbox.com/u2f-app-id.json"): "https://dropbox.com",
    SHA256.digest("https://www.gstatic.com/securitykey/origins.json"): "https://google.com",
    SHA256.digest("https://vault.bitwarden.com/app-id.json"): "https://vault.bitwarden.com",
    SHA256.digest("https://keepersecurity.com"): "https://keepersecurity.com",
    SHA256.digest("https://api-9dcf9b83.duosecurity.com"): "https://api-9dcf9b83.duosecurity.com",
    SHA256.digest("https://dashboard.stripe.com"): "https://dashboard.stripe.com"
]


import Kitura

struct WorkshopsController {

  static var handler: RouterHandler = { request, response, next in
    try response.send(
      WorkshopsIndexPage(
        allWorkshops: Array(NewWorkshopManager.workshops.values).sorted { $0.title < $1.title }
      ).node.render()
    ).end()
  }

  static var workshopHandler: RouterHandler = { request, response, next in
    if let workshopId = request.parameters["workshopId"],
      let workshop = NewWorkshopManager.workshops["workshop-\(workshopId)"] {
        try response.send(
          IndividualWorkshopPage(workshop: workshop).node.render()
        ).end()
    } else {
      next()
    }
  }

}

Remove the sample workshop from listing

import Kitura

struct WorkshopsController {

  static var handler: RouterHandler = { request, response, next in
    try response.send(
      WorkshopsIndexPage(
        allWorkshops: Array(NewWorkshopManager.workshops.values)
          .sorted { $0.title < $1.title }
          .filter { $0.workshopId != "example" }
      ).node.render()
    ).end()
  }

  static var workshopHandler: RouterHandler = { request, response, next in
    if let workshopId = request.parameters["workshopId"],
      let workshop = NewWorkshopManager.workshops["workshop-\(workshopId)"] {
        try response.send(
          IndividualWorkshopPage(workshop: workshop).node.render()
        ).end()
    } else {
      next()
    }
  }

}


// Check source locations (only InterpolatedStringLiteral for now).

func string_interpolation() {
  "\("abc")"
}

// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
// CHECK: (interpolated_string_literal_expr {{.*}} trailing_quote_loc=SOURCE_DIR/test/Parse/source_locs.swift:4:12 {{.*}}

Fix path separators for Windows.

// Check source locations (only InterpolatedStringLiteral for now).

func string_interpolation() {
  "\("abc")"
}

// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
// CHECK: (interpolated_string_literal_expr {{.*}} trailing_quote_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:4:12 {{.*}}


// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_member_closure %s | FileCheck %s

class C {
  // CHECK-LABEL: sil_coverage_map {{.*}}// coverage_member_closure.C.__allocating_init
  init() {
    if (false) { // CHECK: [[@LINE]]:16 -> [[@LINE+2]]:6 : 1
      // ...
    }
  }

  // Closures in members show up at the end of the constructor's map.
  // CHECK-NOT: sil_coverage_map
  // CHECK: [[@LINE+1]]:55 -> [[@LINE+1]]:77 : 2
  var completionHandler: (String, [String]) -> Void = {(foo, bar) in return}
}

Fix whitespaces for a closure

// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_member_closure %s | FileCheck %s

class C {
  // CHECK-LABEL: sil_coverage_map {{.*}}// coverage_member_closure.C.__allocating_init
  init() {
    if (false) { // CHECK: [[@LINE]]:16 -> [[@LINE+2]]:6 : 1
      // ...
    }
  }

  // Closures in members show up at the end of the constructor's map.
  // CHECK-NOT: sil_coverage_map
  // CHECK: [[@LINE+1]]:55 -> [[@LINE+1]]:79 : 2
  var completionHandler: (String, [String]) -> Void = { (foo, bar) in return }
}


//
//  UIViewControllerDimming.swift
//  Rocket.Chat
//
//  Created by Matheus Cardoso on 11/23/18.
//

import UIKit

let kDimViewAlpha: CGFloat = 0.6
let kDimViewAnimationDuration = 0.25

class DimView: UIView { }

extension UIViewController {
    var dimViewTag: Int {
        return "Dim_View".hashValue
    }

    var dimView: DimView {
        if let res = view.viewWithTag(dimViewTag) as? DimView {
            return res
        } else {
            let dimView = DimView(frame: view.frame)
            dimView.tag = dimViewTag
            dimView.backgroundColor = .black
            dimView.alpha = kDimViewAlpha

            view.addSubview(dimView)
            return dimView
        }
    }

    func startDimming() {
        view.bringSubviewToFront(dimView)
        dimView.isHidden = false

        UIView.animate(withDuration: kDimViewAnimationDuration) { [dimView] in
            dimView.alpha = kDimViewAlpha
        }
    }

    func stopDimming() {

        UIView.animate(withDuration: kDimViewAnimationDuration, animations: { [dimView] in
            dimView.alpha = 0
        }, completion: { [dimView] _ in
            dimView.isHidden = true
        })
    }
}

Fix dim view positioning on iPad

//
//  UIViewControllerDimming.swift
//  Rocket.Chat
//
//  Created by Matheus Cardoso on 11/23/18.
//

import UIKit

let kDimViewAlpha: CGFloat = 0.6
let kDimViewAnimationDuration = 0.25

class DimView: UIView { }

extension UIViewController {
    var dimViewTag: Int {
        return "Dim_View".hashValue
    }

    var dimView: DimView {
        if let res = view.viewWithTag(dimViewTag) as? DimView {
            res.frame = view.bounds
            return res
        } else {
            let dimView = DimView(frame: view.bounds)
            dimView.tag = dimViewTag
            dimView.backgroundColor = .black
            dimView.alpha = kDimViewAlpha

            view.addSubview(dimView)
            return dimView
        }
    }

    func startDimming() {
        view.bringSubviewToFront(dimView)
        dimView.isHidden = false

        UIView.animate(withDuration: kDimViewAnimationDuration) { [dimView] in
            dimView.alpha = kDimViewAlpha
        }
    }

    func stopDimming() {

        UIView.animate(withDuration: kDimViewAnimationDuration, animations: { [dimView] in
            dimView.alpha = 0
        }, completion: { [dimView] _ in
            dimView.isHidden = true
        })
    }
}


//
//  TransitionOperation+Action.swift
//  Pageboy
//
//  Created by Merrick Sapsford on 30/05/2017.
//  Copyright © 2017 Merrick Sapsford. All rights reserved.
//

import Foundation

internal extension TransitionOperation {

    /// Action that occurs in an operation.
    struct Action {

        /// The page start index.
        let startIndex: Int
        /// The page end index.
        let endIndex: Int
        /// The direction of travel.
        let direction: PageboyViewController.NavigationDirection
        /// The orientation of the page view controller.
        let orientation: UIPageViewControllerNavigationOrientation

    }
}

internal extension TransitionOperation.Action {

    /// Animation sub-type for the action.
    var transitionSubType: String {
        switch orientation {

        case .horizontal:
            switch direction {

            case .reverse:
                return kCATransitionFromLeft
            default:
                return kCATransitionFromRight
            }

        case .vertical:
            switch direction {

            case .reverse:
                return kCATransitionFromTop
            default:
                return kCATransitionFromBottom
            }
        }
    }
}

Fix issue with incorrect transition in vertical orientation

//
//  TransitionOperation+Action.swift
//  Pageboy
//
//  Created by Merrick Sapsford on 30/05/2017.
//  Copyright © 2017 Merrick Sapsford. All rights reserved.
//

import Foundation

internal extension TransitionOperation {

    /// Action that occurs in an operation.
    struct Action {

        /// The page start index.
        let startIndex: Int
        /// The page end index.
        let endIndex: Int
        /// The direction of travel.
        let direction: PageboyViewController.NavigationDirection
        /// The orientation of the page view controller.
        let orientation: UIPageViewControllerNavigationOrientation

    }
}

internal extension TransitionOperation.Action {

    /// Animation sub-type for the action.
    var transitionSubType: String {
        switch orientation {

        case .horizontal:
            switch direction {

            case .reverse:
                return kCATransitionFromLeft
            default:
                return kCATransitionFromRight
            }

        case .vertical:
            switch direction {

            case .reverse:
                return kCATransitionFromBottom
            default:
                return kCATransitionFromTop
            }
        }
    }
}


@objc(RMTRating)
class RMTRating: _RMTRating {

    class func deleteAllExceptMyRatings(finishedCallback: () -> Void) {

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
            let userUUID = NSUserDefaults.standardUserDefaults().userUUID
            let moc: NSManagedObjectContext = NSManagedObjectContext.MR_defaultContext()
            let predicate = NSPredicate(format: "%K != %@", RMTRatingAttributes.userUUID.rawValue, userUUID)
            var objectsToDelete: [RMTRating] = RMTRating.MR_findAllWithPredicate(predicate, inContext: moc) as [RMTRating]
            for rating in objectsToDelete {
                moc.deleteObject(rating)
            }

            moc.MR_saveToPersistentStoreWithCompletion({ (saved, error) -> Void in
                dispatch_async(dispatch_get_main_queue(), { () -> Void in
                    finishedCallback()
                })
            })
        })
    }
}

Use thread context for deleting the ratings.

@objc(RMTRating)
class RMTRating: _RMTRating {

    class func deleteAllExceptMyRatings(finishedCallback: () -> Void) {

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
            let userUUID = NSUserDefaults.standardUserDefaults().userUUID
            let moc: NSManagedObjectContext = NSManagedObjectContext.MR_contextForCurrentThread()
            let predicate = NSPredicate(format: "%K != %@", RMTRatingAttributes.userUUID.rawValue, userUUID)
            var objectsToDelete: [RMTRating] = RMTRating.MR_findAllWithPredicate(predicate, inContext: moc) as [RMTRating]
            for rating in objectsToDelete {
                rating.ratingCategory?.removeRatingsObject(rating)
                moc.deleteObject(rating)
            }

            moc.MR_saveToPersistentStoreWithCompletion({ (saved, error) -> Void in
                dispatch_async(dispatch_get_main_queue(), { () -> Void in
                    finishedCallback()
                })
            })
        })
    }
}


//  FightingFantasy
//  Created by Tony Smith on 29/10/2017.
//  Copyright © 2017 Tony Smith. All rights reserved.

import Cocoa

class FFCollectionViewItem: NSCollectionViewItem {

    var index: Int = -1
    var image: NSImage? {
        didSet {
            guard isViewLoaded else { return }

            if let image = image {
                imageView?.image = image
            } else {
                imageView?.image = nil
            }
        }
    }

    override func viewDidLoad() {

        super.viewDidLoad()
        view.wantsLayer = true
        view.layer?.backgroundColor = NSColor.white.cgColor
        view.layer?.borderColor = NSColor.init(red: 0.6, green: 0.1, blue: 0.0, alpha: 1.0).cgColor
        view.layer?.borderWidth = 0.0
    }

    override var isSelected: Bool {

        didSet {
            view.layer?.borderWidth = isSelected ? 5.0 : 0.0
        }
    }

}

Reduce selected image border size

//  FightingFantasy
//  Created by Tony Smith on 29/10/2017.
//  Copyright © 2017 Tony Smith. All rights reserved.

import Cocoa

class FFCollectionViewItem: NSCollectionViewItem {

    var index: Int = -1
    var image: NSImage? {
        didSet {
            guard isViewLoaded else { return }

            if let image = image {
                imageView?.image = image
            } else {
                imageView?.image = nil
            }
        }
    }

    override func viewDidLoad() {

        super.viewDidLoad()
        view.wantsLayer = true
        view.layer?.backgroundColor = NSColor.white.cgColor
        view.layer?.borderColor = NSColor.init(red: 0.6, green: 0.1, blue: 0.0, alpha: 1.0).cgColor
        view.layer?.borderWidth = 0.0
    }

    override var isSelected: Bool {

        didSet {
            view.layer?.borderWidth = isSelected ? 2.0 : 0.0
        }
    }

}