Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep safari remote debugging open on navigation

I'm using Safari's remote debugging to inspect a webview in an iPhone app in my simulator. The problem is that the remote debugging window closes as soon as the app does.

I have an action which switches to another app and back but I can't read console.log messages from immediately before the switch because I'm not quick enough and I can't read logs from immediately after coming back to my app because I have to re-open the console first.

Is there a way to keep it open so I can at least see the last logs from before switching apps?

like image 462
Jake Avatar asked Apr 09 '13 02:04

Jake


2 Answers

Here is an AppleScript that launches Safari Inspector. You can export it as an executable application and have it sitting in your dock to get into Inspector with a single click or launch it in a build phase in Xcode.

tell application "Safari"
    activate
    delay 2
    tell application "System Events"
        tell process "Safari"
            set frontmost to true
            click menu item 2 of menu 1 of menu item "iPad Simulator" of menu 1 of menu bar item "Develop" of menu bar 1
        end tell
    end tell
end tell
like image 172
James Avatar answered Nov 08 '22 01:11

James


This is James' answer wrapped in an Alfred Workflow, -g- ... check it

ALSO WORKS FOR IPHONE BRAH

on alfred_script(q)
tell application "Safari"
    activate
    delay 0.5
    tell application "System Events"
        tell process "Safari"
            set frontmost to true
            try
                click menu item 2 of menu 1 of menu item "iPhone Simulator" of menu 1 of menu bar item "Develop" of menu bar 1
            end try
            try
                click menu item 2 of menu 1 of menu item "iPad Simulator" of menu 1 of menu bar item "Develop" of menu bar 1
            end try
        end tell
    end tell
end tell
end alfred_script
like image 24
captainclam Avatar answered Nov 08 '22 02:11

captainclam