Post

Replies

Boosts

Views

Activity

Reply to Enable local network access during iOS UI test in iOS14
The solution I've found in the Xcode 15.3 working with iOS 17.4.1 made me SICK! I couldn't find any doc about it, but I'm sure it works. You have to bring your xctrunner app to front, this way OS asks for local network permission in UI test target. Try this in your UI test target without need to specify NSLocalNetworkUsageDescription and bonjour services, etc. func testXCTRunnerToAskForLocalNetworkPermission() { // without bringing xctrunner to front, permission alert won't be shown. let app = XCUIApplication(bundleIdentifier: "{YOUR_APP_BUNDLE_ID}UITests.xctrunner") app.activate() connectToLocalNetwork() waitFor(aSecond: 1) let springBoard = XCUIApplication(bundleIdentifier: "com.apple.springboard") // Allows local network permission. let button = springBoard.alerts.firstMatch.buttons["Allow"] if button.exists { button.tap() // local network is allowed in current running ui test. connectToLocalNetwork() // try to connect, as it's allowed now. } // Keep XCUITest running forever, though sometimes it stops automatically wait(for: [expectation(description: "keep running")], timeout: .infinity) } waiter helper function: func waitFor(aSecond seconds: TimeInterval) { let expectation = expectation(description: "waiting for \(seconds)") let timer = Timer(timeInterval: seconds, repeats: false) { _ in expectation.fulfill() } wait(for: [expectation], timeout: seconds) } local network function: func connectToLocalNetwork() { URLSession.shared.dataTask(with: URLRequest(url: URL(string: "http://192.168.2.101:5055")!)) { data, response, error in if let data { print("Data: \(String(data: data, encoding: .utf8) ?? "")") } }.resume() }
May ’24
Reply to xcode 11.4 beta no longer allow non-universal frameworks
In my case, we have a framework which is exported for devices only, so in previous versions of Xcode (11.3), I was importing and using it contitionally (#if !targetEnvironment(simulator)).Now from Xcode 11.4, as I couldn't build the app for simulator, I've found a workaround with carthage's copy-frameworks run script.I removed the framework from both embedded and linked libraries.I've added a run script: https://imgur.com/99PniC8Basically, it copies your framework to the application during build.
Apr ’20
Reply to WKWebView using URLRequest HTTPBody is nil in WKNavigationDelegate (decidePolicyFor)
Hello eskimo,Thanks for detailed explanation of the workaround for the issue.In my company, we've a similar case while moving from UIWebView to WKWebView.We're receiving online payments and there're multiple redirections with credit card input forms. With UIWebViewDelegate's we could get request data while redirection, as you already know the issue, we can't achieve same data with WKWebView navigation delegate's decidePolicy methods.I know, there's an option where we can register WKScriptMessageHandlers in application and trigger them from web site by posting messages like:window.webkit.messageHandlers.jsHandler.postMessage("trigger from JS");But, we want to keep this implementation as the last choice, as there're various integrated payment systems that communicates with each other and it would be more time consuming both for development and testing with all integrated systems.Considering we cannot rely on form id's, is there any alternative, so that we can achieve request's httpBody from WKWebView redirections?Looking forward for your reply,Best Regards
Mar ’20