It is often to embed a UIWebView in an iOS app. However it doesn’t provide the powerful webkit inspector by default. Nathan de Vries has written a post to solve the problem, but the solution didn’t work on my XCode 4 with Clang front end.
This is Nathan’s solution:
1 2 3 4 5
The compiler will complain that you can’t force
WebView to perform private
_enableRemoteInspector. Thus, I use
of direct method call. Guess what? The compiler accept the hack. Awesome!
1 2 3 4 5 6 7
Now simply run your iphone simulator and open the url
localhost:9999 to view your inspector. Voilà!
For more curious, The
#if (TARGET_IPHONE_SIMULATOR) macro will ensure the hack
of accessing WebKit’s private api won’t ship with your production code.