Last Updated: February 25, 2016
·
564
· hermanlintvelt

Debug output when running on device

I have tried a lot of hacks mentioned on the internet to try and get debug output (from the print(..) function) of a Corona app running on a iOS device.

Nothing worked, until I found this great GDNtip

Steps

  1. You basically create a bin at http://requestb.in/
  2. Then you create a print function like this:

    local isSimulator = "simulator" == system.getInfo("environment")
    function prnt(msg)
      -- do return end -- uncomment this for production build
      if isSimulator then
        print(msg)
      else
        local postURL = "http://www.postbin.org/foobar"
        local function networkListener( event )
           -- nada because if not in sim won't ever see it
        end
        local params = {}
        params.body = msg
        network.request( postURL, "POST", networkListener, params)
      end
    end

Note, this is not my code, but from the post @ GDN that I mentioned at the start.