Skip to content

Instantly share code, notes, and snippets.

View dobreandl's full-sized avatar

Dragos Dobrean dobreandl

View GitHub Profile
xcodebuild -workspace <your_project_name>.xcworkspace -scheme <your_desired_schema> -configuration <your_desired_configuration> -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch),OS=10.2' -derivedDataPath <derived_data_path> BUILD_DIR=<build_directory_path> -UseModernBuildSystem=YES clean build -enableCodeCoverage=YES test
man xcodebuild
xcodebuild -list -project <your_project_name>.xcodeproj
pod install
let newWindow = UIWindow(frame: UIScreen.main.bounds)
newWindow.rootViewController = rootViewController
UIWindow.transition(with: appDelegate.window, duration: 0.3, options: .transitionCrossDissolve, animations: {
let oldWindow = appDelegate.window
appDelegate.window = newWindow
newWindow.makeKeyAndVisible()
oldWindow?.rootViewController?.dismiss(animated: false, completion: nil)
let startupViewController = StartupViewController()
let navController = UINavigationController(rootViewController: startupViewController)
appDelegate.window.rootViewController = navController
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if (message.name == “notification_name”) {
print("Page changed")
}
}
private func addPageHasChangedDelegateScript(wkWebController: WKUserContentController) {
// load the script from the file and create a WKUserScript object
let scriptURL = Bundle.main.path(forResource: Constants.detectPageChangeScript, ofType: "js")
let scriptContent = try! String.init(contentsOfFile: scriptURL!)
let script = WKUserScript(source: scriptContent, injectionTime: .atDocumentStart, forMainFrameOnly: false)
// Add the script to the WKUserContentController
wkWebController.addUserScript(script)
// Register for receiving callbacks from javascript for a notification name
private func configureWebView() {
let wkWebConfig = WKWebViewConfiguration() // We create a web view configuration
let wkUserController = WKUserContentController() // We create a user content controller for adding the JS for manipulating the CSS of the web page
wkWebConfig.userContentController = wkUserController
addHideHeaderScript(wkWebController: wkUserController) // We add the the hide header script
// We configure the web view, and add it as a subview to the current view
webView = WKWebView(frame: self.view.bounds, configuration: wkWebConfig)