Skip to content

Instantly share code, notes, and snippets.

@claybridges
Created November 27, 2014 02:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claybridges/39e47f4579fd9526273f to your computer and use it in GitHub Desktop.
Save claybridges/39e47f4579fd9526273f to your computer and use it in GitHub Desktop.
Allows setting of WKPreferences.developerExtrasEnabled flag
@import WebKit;
@interface WKPreferences (DevExtras)
@property (nonatomic, setter=_setDeveloperExtrasEnabled:) BOOL _developerExtrasEnabled;
- (void)enableDevExtras;
@end1
// Copyright (c) 2014 Clay Bridges. All rights reserved.
#import "WKPreferences+DevExtras.h"
@implementation WKPreferences (DevExtras)
@dynamic _developerExtrasEnabled;
- (void)enableDevExtras
{
[self _setDeveloperExtrasEnabled:YES];
}
@end
@claybridges
Copy link
Author

Original info from this SO question.

Works in Objective-C or Swift.

In Swift, you'll need to add the following line to your bridging header:

#import "WKPreferences+DevExtras.h"

Usage looks like

let webView = WKWebView(frame: window.frame)
webView.configuration.preferences.enableDevExtras();

@DarkDust
Copy link

DarkDust commented May 3, 2016

Bad idea to do it this way: you may get rejected due to use of internal APIs. Use the setValue way instead.

@lucatorella
Copy link

This solution doesn't seem to work in iOS. It just works in OS X. Am I right?

@shravanteegala
Copy link

is it Working fine or getting any issues ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment