Skip to content

Instantly share code, notes, and snippets.

View dobreandl's full-sized avatar

Dragos Dobrean dobreandl

View GitHub Profile
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)
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
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if (message.name == “notification_name”) {
print("Page changed")
}
}
let startupViewController = StartupViewController()
let navController = UINavigationController(rootViewController: startupViewController)
appDelegate.window.rootViewController = navController
pod install
xcodebuild -list -project <your_project_name>.xcodeproj
man xcodebuild
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
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
xcrun llvm-cov show -instr-profile <path_of_the_Coverage.profdata_file> \
<path_of_the_executable> > <name_of_the_report_file>