SDK in the survey:
- Fabric Crashlytics
- Firebase
- Facebook SDK: Swift & Objective-C
Crashlytics is a crash reporting library for mobile apps, a close-sourced binary framework.
| import Foundation | |
| import WebKit | |
| final class WebCacheCleaner { | |
| class func clean() { | |
| HTTPCookieStorage.shared.removeCookies(since: Date.distantPast) | |
| print("[WebCacheCleaner] All cookies deleted") | |
| WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in |
| class GoogleTestViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view. | |
| let webView = WKWebView.init(frame: self.view.frame) | |
| webView.load(URLRequest.init(url: URL.init(string: "https://www.google.com")! )) | |
| self.view.addSubview(webView) | |
| } |
| // Douglas Hill, December 2018 | |
| import UIKit | |
| /// A table view that allows navigation and selection using a hardware keyboard. | |
| /// Only supports a single section. | |
| class KeyboardTableView: UITableView { | |
| // These properties may be set or overridden to provide discoverability titles for key commands. | |
| var selectAboveDiscoverabilityTitle: String? | |
| var selectBelowDiscoverabilityTitle: String? |
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| var window: UIWindow? | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
| // Override point for customization after application launch. | |
| if #available(iOS 10.0, *) { | |
| UNUserNotificationCenter.current().delegate = self | |
| } | |
| return true | |
| } |
| # Xcode 10.2 | |
| # please use within Xcode environment (Build Phases -> Run Script or Scheme -> Post Actions) | |
| xcodebuild -version | |
| UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
| # make sure the output directory exists | |
| mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" | |
| env > env.txt | |
| # Step 1. Build Device and Simulator versions | |
| xcodebuild -project "${PROJECT_NAME}.xcodeproj" -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build |
| extension URLComponents { | |
| init(scheme: String = "https", host: String, path: [String], queries: [URLQueryItem]?) { | |
| self = URLComponents.init() | |
| self.scheme = scheme | |
| self.host = host | |
| var p = path | |
| p.insert("/", at: 0) | |
| self.path = NSString.path(withComponents: p) | |
| self.queryItems = queries | |
| } |
| import XCTest | |
| class BaseTestCase: XCTestCase { | |
| let app = XCUIApplication() | |
| // ... | |
| func waitforExistence(element: XCUIElement, file: String = #file, line: UInt = #line) { | |
| let exists = NSPredicate(format: "exists == true") |
| import Foundation | |
| class MockURLProtocol: URLProtocol { | |
| static var requestHandler: ((URLRequest) throws -> (HTTPURLResponse, Data) )? | |
| override class func canInit(with request: URLRequest) -> Bool { | |
| return true | |
| } | |
| override class func canonicalRequest(for request: URLRequest) -> URLRequest { | |
| return request |
| #if MOCK_URL_PROTOCOL | |
| let configuration = URLSessionConfiguration.ephemeral | |
| configuration.protocolClasses = [MockURLProtocol.self] | |
| let urlSession = URLSession(configuration: configuration) | |
| #else | |
| let urlSession = URLSession.shared | |
| #endif |