when i use font-family:system-ui on the web, i found the text will be smaller on ios 18 beta, the problem also appear on ios 17 when using iphone 15 pro max.
It looks ok if i use font-family:PingFang SC instead of system-ui.
General
RSS for tagExplore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.
Post
Replies
Boosts
Views
Activity
Here's my code:
font-weight: bold;
font-family: 'PingFangSC-Regular';
when use the css below, the text will be smaller than iOS17.
font-family:system-ui
If i use font-family: PingFang SC, that will be ok.
If system-ui was modified by system?
I have opened a WKWebView with "https://www.google.com", for example. After that, I put my app in the background. When I try to open a new URL request in the same web view with a new link, like "https://www.youtube.com", by redirecting the app, it doesn't work. I've put a listener function to detect the new URL and called "webView.load(newURLRequest)". However, the web view never loads the new URL request.
I have tried to solve this issue by adding a delay through DispatchQueue. Adding a delay sometimes works and sometimes doesn't. I also tried using NavigationDelegate, but it still didn't help. Below is my code:
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(self.refreshData), name: NSNotification.Name("refreshweb"), object: nil)
}
@objc func refreshData() {
let url = URL (string: "https://www.youtube.com")
let requestObj = URLRequest(url: url!)
webview.load(requestObj)
}
I am trying to load a URL in webView, and have it exclude the website Header and Footer from displaying within the view.
Text app extremely frozen sliders don’t work. Reboot gets text to work for one or two text then app freezes sliders don’t work swiping it away doesn’t fix it.
Create extension development, call openai in content and background respectively or use native fetch to make streaming requests.
Content is ok, background is normal at first, but when the stream content is a little more, background will be pending and unable to obtain data.
Hello , im having trouble with logging in for developer website , my main ID doesnt seem to work when i try to login , but my other Id works totally fine , what could be the issue ?
I use the WKWebView to show my content. And inside it, I also used a shared worker to run my task. And while I move focus out, the WKWebview is still working but the tasks inside shared worker stops. Is this by design or a bug?
Do you have any suggestions to handle this situation to let the task inside shared worker to continue while focus changes.
In Safari, when there are two password fields side-by-side, they are actually asking for different passwords. However, the browser's autofill might automatically fill the second field with the same password as the first, assuming it's a confirmation.
17.5+, when the wkwebview is not visible, the setTimeout function fails to execute when it reaches time.how to fix?
The process to reproduce:
Create a new extension with Xcode 16 beta.
Run it on the simulator or any iOS device with iOS 18 beta installed.
Open Safari on your Mac, then open Develop -> Device you use.
Unable to access these menus for iOS 18:
1. Extension - Extension Background Content
2. Extension - Extension Pop-up Page - popup.html
However, for iOS 17.4, I can see these options in Develop -> Device iOS(17.4).
I have another extension on the App Store that is not working on the iOS 18 beta, but I am unable to debug it because of this issue.
I have a website of a chatbot that also accepts microphone inputs and I embedded that into my swift and the everything other than the mic is working. I have included permission in the info file and here’s some of the code :
import SwiftUI
import WebKit
import AVFoundation
struct WebView: UIViewRepresentable {
let url: URL
class Coordinator: NSObject, WKUIDelegate, WKNavigationDelegate {
var parent: WebView
init(parent: WebView) {
self.parent = parent
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
decisionHandler(.allow)
}
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler()
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler(true)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
completionHandler(false)
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {
let alert = UIAlertController(title: prompt, message: nil, preferredStyle: .alert)
alert.addTextField { textField in
textField.text = defaultText
}
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler(alert.textFields?.first?.text)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
completionHandler(nil)
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
decisionHandler(.grant)
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
print("Navigation error: \(error.localizedDescription)")
}
}
func makeCoordinator() -> Coordinator {
Coordinator(parent: self)
}
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
webConfiguration.mediaTypesRequiringUserActionForPlayback = []
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = context.coordinator
webView.navigationDelegate = context.coordinator
requestMicrophoneAccess()
return webView
}
func updateUIView(_ webView: WKWebView, context: Context) {
let request = URLRequest(url: url)
webView.load(request)
}
func requestMicrophoneAccess() {
AVAudioSession.sharedInstance().requestRecordPermission { granted in
DispatchQueue.main.async {
if granted {
print("Microphone access granted")
} else {
print("Microphone access denied")
}
}
}
}
func presentAlert(alert: UIAlertController) {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = windowScene.windows.first?.rootViewController {
rootViewController.present(alert, animated: true, completion: nil)
}
}
}
I have a website of a chatbot that also accepts microphone inputs and I embedded that into my swift and the everything other than the mic is working. I have included permission in the info file and here's some of the code :
import SwiftUI
import WebKit
import AVFoundation
struct WebView: UIViewRepresentable {
let url: URL
class Coordinator: NSObject, WKUIDelegate, WKNavigationDelegate {
var parent: WebView
init(parent: WebView) {
self.parent = parent
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
decisionHandler(.allow)
}
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler()
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler(true)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
completionHandler(false)
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {
let alert = UIAlertController(title: prompt, message: nil, preferredStyle: .alert)
alert.addTextField { textField in
textField.text = defaultText
}
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
completionHandler(alert.textFields?.first?.text)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
completionHandler(nil)
}))
parent.presentAlert(alert: alert)
}
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
decisionHandler(.grant)
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
print("Navigation error: \(error.localizedDescription)")
}
}
func makeCoordinator() -> Coordinator {
Coordinator(parent: self)
}
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
webConfiguration.mediaTypesRequiringUserActionForPlayback = []
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = context.coordinator
webView.navigationDelegate = context.coordinator
requestMicrophoneAccess()
return webView
}
func updateUIView(_ webView: WKWebView, context: Context) {
let request = URLRequest(url: url)
webView.load(request)
}
func requestMicrophoneAccess() {
AVAudioSession.sharedInstance().requestRecordPermission { granted in
DispatchQueue.main.async {
if granted {
print("Microphone access granted")
} else {
print("Microphone access denied")
}
}
}
}
func presentAlert(alert: UIAlertController) {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = windowScene.windows.first?.rootViewController {
rootViewController.present(alert, animated: true, completion: nil)
}
}
}
In iOS 18, internal extension pages cannot navigate to external webpages, either via href links or through JS methods such as window.location.replace. Nothing happens when you try to navigate to an external webpage. Only other internal pages can be navigated to. This wasn't an issue on previous versions of iOS.
It would be appreciated if this can be fixed as soon as possible.
Feedback ID: FB14194963
Be warned! When developing your app in Xcode 16 be careful!!! The new SDK has changes that cause builds on Xcode Cloud and other non-beta Xcode to have bugs (EVEN WITH IOS TARGET SET LOWER).
This wasted 2 days of development time, but in WKNavigationDelegate, the webView(_:decidePolicyFor:decisionHandler:) method has a new type signature that will ONLY work in the latest SDK. The change was that the decisionHandler now has a @MainActor attribute. This causes Swift to recognize that it "almost" meets an optional requirement and suggests that you change it. If you change it, it will cause builds to not include the optional method.
It’s a minor issue but since I installed the new ios 18 beta, I can never close a tab on the first try from the list of tabs on Safari. The trigger area seems too small.
In my app I am trying to load webview with an URL , I am checking is it loading on main thread also loading webview in main thread using DispatchQueue.main.async {
self.loadRequest()
}
, webview loads successfully, then showing below error app crashes , unable to find the reason.
"*** Assertion failure in -[UIApplication _performAfterCATransactionCommitsWithLegacyRunloopObserverBasedTiming:block:]"
Thanks in advance
I am new to swift, so any advice would be appreciated. So the I have seen URL and URLSession return a timeout response, the android varient of my app does not show this issue.
class HasInternet: ObservableObject {
let monitor = NWPathMonitor()
let queue = DispatchQueue(label: "Monitor")
private var status: NWPath.Status = .requiresConnection
@Published var isConnected = false
init(){
monitor.pathUpdateHandler = { [weak self] path in
if let url = URL(string: "https://google.com") {
var request = URLRequest(url: url)
request.httpMethod = "HEAD"
request.timeoutInterval = 30
let sessionConfig = URLSessionConfiguration.default
sessionConfig.timeoutIntervalForRequest = 30.0
sessionConfig.timeoutIntervalForResource = 60.0
URLSession(configuration: sessionConfig)
.dataTask(with: request) { (_, response, error) -> Void in
guard error == nil else {
return
}
guard (response as? HTTPURLResponse)?
.statusCode == 200 else { return }
DispatchQueue.main.async {
self?.isConnected = true
}
}
.resume()
}
}
monitor.start(queue: queue)
}
}
Here is another place with the same behaviour.
func post(dModel: DialogModel? = nil, url: String, type: responseTypes, body: [String: Any], headers: [headerType], async: Bool = true) { //async
let semaphore = DispatchSemaphore(value: 0)
let timeout: TimeInterval = 10
if let url = URL(string: url) {
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 30
for header in headers {
request.setValue(header.value, forHTTPHeaderField: header.key)
}
do {
request.httpBody = try JSONSerialization.data(withJSONObject: body, options: .prettyPrinted)
} catch let error {
self.processError(dModel: dModel, error: error.localizedDescription, type: .report)
return
}
let sessionConfig = URLSessionConfiguration.default
sessionConfig.timeoutIntervalForRequest = 30.0
sessionConfig.timeoutIntervalForResource = 60.0
URLSession(configuration: sessionConfig)
.dataTask(with: request) { (data, response, error) -> Void in
if let error = error {
self.processError(dModel: dModel, error: error.localizedDescription, type: .report)
if(async){
semaphore.signal() // Signal semaphore even in case of error
}
return
}
if let httpResponse = response as? HTTPURLResponse{
if let unWrappedData = data {
if let httpResponseData = String(data: unWrappedData, encoding: .utf8) {
self.parse(dModel: dModel, type: type, response: httpResponseData, statusCode: httpResponse.statusCode)
}
}
} else {
self.processError(error: "Invalid response")
}
if(async){
semaphore.signal() // Signal semaphore after processing the response
}
}
.resume()
if(async){
semaphore.wait(timeout: .now() + timeout)
}
} else {
processError(error: "Invalid URL")
}
}
Can we get the list or count of the URLs blocked using the Safari web extension content blocking on the iOS app?