Skip to content

Instantly share code, notes, and snippets.

View pilot34's full-sized avatar

Gleb pilot34

  • Booking.com
  • Amsterdam
View GitHub Profile
@pilot34
pilot34 / LaunchTime.swift
Last active January 21, 2021 16:32
What is included into XCTApplicationLaunchMetric
@objc class AppDelegate: UIResponder, UIApplicationDelegate {
override init() {
debugPrint("AppDelegate.init")
super.init()
}
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@pilot34
pilot34 / ConstantAreaView.swift
Last active July 7, 2023 13:05
Dynamic intrinsicContentSize example
//
// ViewController.swift
// ConstantArea
//
// Created by Gleb Tarasov on 24.05.2020.
// Copyright © 2020 Gleb Tarasov. All rights reserved.
//
import UIKit
class MyView: UILabel {
init() {
super.init(frame: .zero)
numberOfLines = 0
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
class MyView: UIView {
private var preferredMaxLayoutWidth: CGFloat? {
didSet {
invalidateIntrinsicContentSize()
setNeedsLayout()
}
}
override var intrinsicContentSize: CGSize {
return performLayout(changeFrames: false, width: preferredMaxLayoutWidth)
Privacy Policy
Your privacy is important to us. It is ParkingGuru's policy to respect your privacy regarding any information we may collect from you across our website, http://parkinggu.ru, and other sites we own and operate.
We only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we’re collecting it and how it will be used.
We only retain collected information for as long as necessary to provide you with your requested service. What data we store, we’ll protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.
We don’t share any personally identifying information publicly or with third-parties, except when required to by law.
Our website may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot acce
//
// UITestCase.swift
//
// Created by Gleb Tarasov on 23/04/2018.
//
import Foundation
import XCTest
import UIKit
func typeText(_ text: String, toWebViewField element: XCUIElement) {
// xcode has bug, so we cannot directly access webViews XCUIElements
// as workaround we can check debugDesciption, find frame, tap by coordinate,
// and then paste text there
guard let coordBeforeTap = coordinate(forWebViewElement: element) else {
XCTFail("no element \(element)")
return
}
// "typeText" doesn't work, so we paste text
// first tap to activate field
private func coordinate(forWebViewElement element: XCUIElement) -> XCUICoordinate? {
// wait for element to appear before searching
wait(forWebViewElement: element)
// parse description to find its frame
let descr = element.firstMatch.debugDescription
guard let rangeOpen = descr.range(of: "{{", options: [.backwards]),
let rangeClose = descr.range(of: "}}", options: [.backwards]) else {
return nil
}
func wait(forWebViewElement element: XCUIElementTypeQueryProvider, timeout: TimeInterval = 20) {
// xcode has bug, so we cannot directly access webViews XCUIElements
// as a workaround we can check debugDesciption and parse it, that works
let predicate = NSPredicate { obj, _ in
guard let el = obj as? XCUIElement else {
return false
}
// If element has firstMatch, than there will be description of that at the end
// If no match - it will be ended with "FirstMatch\n"
return !el.firstMatch.debugDescription.hasSuffix("First Match\n")
@pilot34
pilot34 / Fastfile.rb
Last active January 29, 2020 17:37
CircleCI 2.0 iOS Signing without Match
private_lane :prepare_certificates do |options|
sh("base64 -D -o Certificates.p12 <<< \"#{ENV['APPLE_CERTIFICATE']}\"", log: false)
create_keychain(
name: "default_keychain",
default_keychain: true,
unlock: true,
password: "default"
)
import_certificate(
certificate_path: "fastlane/Certificates.p12",