Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions lib/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ THE SOFTWARE.
*/

const path = require('path')
const fs = require('fs')
const { spawnSync } = require('child_process')
const { Tail } = require('tail')

const extensions = {
start: function (deviceid) {
Expand Down Expand Up @@ -78,31 +76,6 @@ const extensions = {
// Xcode 8 or older
return spawnSync('xcrun', ['instruments', '-w', deviceid])
}
},

log: function (deviceid, filepath) {
const tail = new Tail(
path.join(process.env.HOME, 'Library', 'Logs', 'CoreSimulator', deviceid, 'system.log')
)

tail.on('line', function (data) {
if (filepath) {
fs.appendFile(filepath, data + '\n', function (error) {
if (error) {
console.error('ERROR: ', error)
throw error
}
})
} else {
console.log(data)
}
})

tail.on('error', function (error) {
console.error('ERROR: ', error)
})

return tail
}
}

Expand Down
14 changes: 0 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"url": "https://github.com/ios-control/simctl.git"
},
"main": "simctl.js",
"dependencies": {
"tail": "^2.2.6"
},
"scripts": {
"test": "node --test --experimental-test-coverage",
"posttest": "npm run eslint",
Expand Down
16 changes: 13 additions & 3 deletions simctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,27 @@ module.exports = {
return spawnSync('xcrun', ['simctl', 'uninstall', device, appIdentifier])
},

launch: function (waitForDebugger, device, appIdentifier, argv) {
launch: function (device, appIdentifier, argv = [], options = {}) {
const args = ['simctl', 'launch']

if (waitForDebugger) {
if (options.waitForDebugger) {
args.push('--wait-for-debugger')
}
if (options.stderr) {
args.push(`--stderr=${options.stderr}`)
}
if (options.stdout) {
args.push(`--stderr=${options.stdout}`)
}
if (options.arch) {
args.push(`--arch=${options.arch}`)
}

args.push(device)
args.push(appIdentifier)
args.push(...argv)

return spawnSync('xcrun', args.concat(argv))
return spawnSync('xcrun', args)
},

spawn: function (waitForDebugger, arch, device, pathToExecutable, argv) {
Expand Down
1 change: 0 additions & 1 deletion test/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ test('exports', (t) => {
t.assert ||= require('node:assert')

t.assert.equal(typeof SimCtlExtensions.start, 'function')
t.assert.equal(typeof SimCtlExtensions.log, 'function')
})

test('start', async (ctx) => {
Expand Down