The browser shows ordinary web content that would be inspectable when loaded in Safari. Learn more about enabling Web Inspector… When should I consider making content inspectable?Ī common situation in which you may want the content of WKWebView to be inspectable is in an in-app web browser. You do not need to enable Web Inspector for simulators it is always enabled. For iOS and iPadOS, you must also have enabled Web Inspector in the Settings app under Safari > Advanced > Web Inspector. Once you’ve enabled inspection for your app, you can inspect it from Safari’s Develop menu in the submenu for either your current computer or an attached device. Disabling inspection while Web Inspector actively inspects the content will automatically close Web Inspector, and no further information about the content will be available. The inspectable property can be changed at any point during the lifetime of your WKWebView or JSContext. JSGlobalContextSetInspectable( jsContextRef, true) JsContext ?.isInspectable = true Objective-C JSContext *jsContext = Ĭ JSGlobalContextRef jsContextRef = JSGlobalContextCreate( NULL) WKWebView *webView = initWithFrame:CGRectZero configuration:webConfiguration] įor JSContext, matching API is available, with the addition of C API for developers using JSGlobalContextRef: Swift let jsContext = JSContext() WebView.isInspectable = true Objective-C WKWebViewConfiguration *webConfiguration = So, for example, to make a WKWebView inspectable, you would: Swift let webConfiguration = WKWebViewConfiguration() This decision is made for each individual WKWebView and JSContext to prevent unintentionally making it enabled for a view or context you don’t intend to be inspectable. It defaults to false, and you can set it to true to opt-in to content being inspectable. How do I enable inspection?Īcross all platforms supporting WKWebView or JSContext, a new property is available called isInspectable ( inspectable in Objective-C). Now, this same functionality is available through an API on WKWebView and JSContext. However, released versions of apps had no way to inspect dynamic web content or scripts, leaving developers and users to have to resort to more complicated workflows to get information that would otherwise be made available by Web Inspector. Previously, Web Inspector supported inspecting developer-provisioned apps built directly from Xcode for local development, meaning developers could debug this content so long as the app is installed for development. Web content and JavaScript is used for various purposes in apps, from providing UI from a webpage to enabling apps to be scriptable. iOS and iPadOS allow inspection of the same content as macOS, with the addition of Home Screen web apps. In Safari on macOS, you can use Web Inspector to inspect web pages, extensions, and service workers. Web Inspector is a powerful tool that allows you to debug the layout of web pages, step through JavaScript, read messages logged to the console, and more.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |