 childProcess = require 'child_process'
 fs = require 'fs'
 pathUtils = require 'path'
+
+log = Neft.log.scope('testing').scope 'ios'
 
 SIMULATOR_PATH = """
     /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator

            onLog msg
        return

    tail.on 'exit', -> onExit()

    kill: ->

    cmd = "xcrun simctl io #{deviceId} screenshot #{path}"
    childProcess.execSync cmd, stdio: 'pipe'

exports.build = (env, callback) ->
    log.debug "Finding requested device id"
    device = getDeviceId env
    env.deviceId = device.id
    log.debug "Use device id #{env.deviceId}"

    if device.status is 'Booted'
        log.debug "Requested simulator is already booted"
    else
        log.debug "Running simulator"
        runSimulator env

    log.debug "Building project"
    buildProject env

    log.debug "Installing project"
    installProject env

    log.debug "Running app"
    clearLogs env
    launchProject env

    callback()

exports.run = (env, logsReader, callback) ->
    scanProgress env, logsReader, callback
    return
