You must open some private WKWebView methods in the ObjC bridge header and call them to change the UA.
Adapted fragments from my mini browser :
jumper header.h
@import WebKit;
@interface WKWebView (Privates)
@property (copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
@property (copy, setter=_setApplicationNameForUserAgent:) NSString *_applicationNameForUserAgent;
@property (nonatomic, readonly) NSString *_userAgent;
@end
macpin.swift
if let agent = withAgent? {
webview._customUserAgent = agent
} else {
webview._applicationNameForUserAgent = "Version/8.0.2 Safari/600.2.5"
}
webview.loadRequest(NSURLRequest(URL: url))
source
share