-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify get simulator command + reduce launch time #31
Changes from 5 commits
362e6ee
0b68fbb
6b7f5cc
eee7560
fc1568d
8ad4589
7cea75f
e3a46d0
80da3e1
15337fe
2286a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,37 +25,21 @@ class TasksViewController: NSViewController { | |
var deviceListIsEmpty = false | ||
var buildItemIsDisabled = false | ||
@objc dynamic var isRunning = false | ||
var outputPipeConsole: Pipe? | ||
var outputPipeTestRun: Pipe? | ||
var buildTask: Process! | ||
var buildTask1: Process! | ||
var buildTask2: Process! | ||
var buildProcess:Process! | ||
var killProcessesProcess:Process! | ||
var sendToIRBSessionProcess:Process! | ||
var simulatorProcess:Process! | ||
var generalIRBSessionTask:Process! | ||
var createIRBSessionTask:Process! | ||
let env = ProcessInfo.processInfo.environment as [String: String] | ||
let applicationStateHandler = ApplicationStateHandler() | ||
let tagsController = TagsController() | ||
let fileManager = FileManager.default | ||
var devices: [String] = [""] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe either remove the |
||
var simulators: [String] = [""] | ||
var file = "" | ||
var timer: Timer! | ||
var pathToCalabashFolder = "" | ||
|
||
override func viewDidAppear() { | ||
super.viewDidAppear() | ||
let filePath2 = "/tmp/allout.txt" | ||
let filePath3 = "/tmp/phys_dev.txt" | ||
let filePath4 = "/tmp/tag_list.txt" | ||
|
||
try? fileManager.removeItem(atPath: filePath2) | ||
try? fileManager.removeItem(atPath: filePath3) | ||
try? fileManager.removeItem(atPath: filePath4) | ||
|
||
textField.backgroundColor = .darkAquamarine | ||
textField.textColor = .white | ||
let placeholderText = NSMutableAttributedString(string: "Console Input (Beta)") | ||
|
@@ -112,8 +96,6 @@ class TasksViewController: NSViewController { | |
tagPicker.completes = true | ||
killIrbSession() | ||
runGeneralIrbSession() | ||
getSimulators() | ||
|
||
setupTagSelection() | ||
|
||
if let simulatorRadioButtonState = applicationStateHandler.simulatorRadioButtonState, | ||
|
@@ -124,49 +106,7 @@ class TasksViewController: NSViewController { | |
|
||
disableBuildItems() | ||
|
||
let filePath2 = "/tmp/allout.txt" | ||
let filePath3 = "/tmp/phys_dev.txt" | ||
|
||
if let bStreamReader = StreamReader(path: filePath2) { | ||
defer { | ||
bStreamReader.close() | ||
} | ||
while var line = bStreamReader.nextLine() { | ||
line = line.trimmingCharacters(in: .whitespaces) | ||
phoneComboBox.addItem(withTitle: line) | ||
} | ||
} | ||
|
||
|
||
simulators = phoneComboBox.itemTitles | ||
|
||
phoneComboBox.removeAllItems() | ||
|
||
if let bStreamReader = StreamReader(path: filePath3) { | ||
defer { | ||
bStreamReader.close() | ||
} | ||
while var line = bStreamReader.nextLine() { | ||
line = line.trimmingCharacters(in: .whitespaces) | ||
phoneComboBox.addItem(withTitle: line) | ||
} | ||
} | ||
|
||
devices = phoneComboBox.itemTitles | ||
|
||
phoneComboBox.removeAllItems() | ||
|
||
if simulator_radio.state == .on { | ||
languagePopUpButton.isEnabled = true | ||
phoneComboBox.addItems(withTitles: simulators) | ||
} else { | ||
get_device.isEnabled = true | ||
languagePopUpButton.isEnabled = false | ||
phoneComboBox.addItems(withTitles: devices) | ||
} | ||
|
||
phoneComboBox.selectItem(at: 0) | ||
|
||
getSimulators() | ||
selectDeviceIfAvailable(prefixed: "iPhone 7(") | ||
|
||
if phoneComboBox.selectedItem == nil { | ||
|
@@ -255,24 +195,6 @@ class TasksViewController: NSViewController { | |
|
||
getSimulators() | ||
|
||
phoneComboBox.removeAllItems() | ||
|
||
let filePath6 = "/tmp/phys_dev.txt" | ||
let filePath7 = "/tmp/allout.txt" | ||
|
||
if let bStreamReader = StreamReader(path: filePath6) { | ||
defer { | ||
bStreamReader.close() | ||
} | ||
while var line = bStreamReader.nextLine() { | ||
line = line.trimmingCharacters(in: .whitespaces) | ||
phoneComboBox.addItem(withTitle: line) | ||
} | ||
} | ||
|
||
try? fileManager.removeItem(atPath: filePath6) | ||
try? fileManager.removeItem(atPath: filePath7) | ||
|
||
if phoneComboBox.selectedItem == nil { | ||
deviceListIsEmpty = true | ||
phoneComboBox.highlight(true) | ||
|
@@ -285,19 +207,13 @@ class TasksViewController: NSViewController { | |
|
||
spinner.stopAnimation(self) | ||
progressBar.stopAnimation(self) | ||
|
||
devices = self.phoneComboBox.itemTitles | ||
} | ||
|
||
@IBAction func simulator_radio(_ sender: Any) { | ||
phys_radio.state = .off | ||
get_device.isEnabled = false | ||
languagePopUpButton.isEnabled = true | ||
|
||
phoneComboBox.removeAllItems() | ||
|
||
phoneComboBox.addItems(withTitles: simulators) | ||
|
||
|
||
if let phoneName = applicationStateHandler.phoneName, | ||
phoneName != "\(Constants.Strings.noDevicesConnected) \(Constants.Strings.pluginDevice)" { | ||
phoneComboBox.selectItem(withTitle: phoneName) | ||
|
@@ -512,41 +428,23 @@ class TasksViewController: NSViewController { | |
get_device.isEnabled = false | ||
isRunning = true | ||
|
||
deviceCollector.simulators(completion: { | ||
DispatchQueue.global(qos: .background).async { [weak self] in | ||
guard let strongSelf = self else { return } | ||
if let launchPath = Constants.FilePaths.Bash.simulators { | ||
let outputStream = CommandsCore.CommandTextOutputStream() | ||
outputStream.textHandler = { text in | ||
DispatchQueue.main.async { | ||
strongSelf.buildButton.isEnabled = true | ||
strongSelf.spinner.stopAnimation(strongSelf) | ||
strongSelf.get_device.isEnabled = true | ||
strongSelf.progressBar.stopAnimation(strongSelf) | ||
} | ||
strongSelf.isRunning = false | ||
} | ||
}) { output in | ||
DispatchQueue.global(qos: .background).async { [weak self] in | ||
guard let strongSelf = self else { return } | ||
let previousOutput = strongSelf.textView.string | ||
if !output.isEmpty { | ||
let nextOutput = "\(previousOutput)\n\(output)" | ||
strongSelf.textView.string = nextOutput | ||
|
||
let range = NSRange(location: nextOutput.count, length: 0) | ||
strongSelf.textView.scrollRangeToVisible(range) | ||
let filderedText = text.components(separatedBy: "\n").filter { !$0.isEmpty } | ||
self.phoneComboBox.addItems(withTitles: filderedText) | ||
} | ||
} | ||
let commands = CommandsCore.CommandExecutor() | ||
commands.executeCommand(at: launchPath, arguments: [""], outputStream: outputStream) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
DispatchQueue.global(qos: .background).async { [weak self] in | ||
guard let strongSelf = self else { return } | ||
DispatchQueue.main.async { | ||
strongSelf.buildButton.isEnabled = true | ||
strongSelf.get_device.isEnabled = true | ||
strongSelf.spinner.stopAnimation(strongSelf) | ||
strongSelf.progressBar.stopAnimation(strongSelf) | ||
} | ||
strongSelf.isRunning = false | ||
} | ||
buildButton.isEnabled = true | ||
spinner.stopAnimation(self) | ||
get_device.isEnabled = true | ||
progressBar.stopAnimation(self) | ||
isRunning = false | ||
} | ||
|
||
func killIrbSession() { | ||
|
@@ -585,13 +483,14 @@ class TasksViewController: NSViewController { | |
} | ||
} | ||
let commands = CommandsCore.CommandExecutor() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated, let's create a ticket for this: we should remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
commands.executeCommand(at: launchPath, arguments: arguments, outputStream: outputStream) | ||
DispatchQueue.global(qos: .background).async { | ||
commands.executeCommand(at: launchPath, arguments: arguments, outputStream: outputStream) | ||
self.buildButton.isEnabled = true | ||
self.spinner.stopAnimation(self) | ||
self.progressBar.stopAnimation(self) | ||
self.isRunning = false | ||
} | ||
} | ||
|
||
buildButton.isEnabled = true | ||
spinner.stopAnimation(self) | ||
progressBar.stopAnimation(self) | ||
isRunning = false | ||
} | ||
|
||
func runGeneralIrbSession() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
#!/bin/bash --login | ||
|
||
xcrun instruments -s devices | grep -E "Simulator" | sed '/Known Devices:/d' | sed '/nb/d' | sed '/Apple Watch -/d' | sed '/Apple TV/d' | sort -nr -t/ -k2,2>/tmp/allout.txt 2>&1 | ||
xcrun instruments -s devices | sed '/Simulator/d' | sed '/Known Devices:/d' | sed '/nb/d' | sed '/Apple Watch -/d' | sed '/Apple TV/d'>/tmp/phys_dev.txt 2>&1 | ||
xcrun instruments -s devices | grep -E "Simulator" | grep -E 'iPhone|iPad' | sed '/Watch/d' | sort -nr -t/ -k2,2 | ||
|
||
|
||
if xcrun instruments -s devices | sed '/Simulator/d' | sed '/Known Devices:/d' | sed '/nb/d' | sed '/Apple Watch/d' | grep -q '(null)'; then | ||
echo "Please unlock your iPhone and tap on 'Trust' button" | ||
fi | ||
|
||
exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@q231950 Not sure why it is needed. Sometimes we get a lot of empty strings after actual result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess somewhere in the script an empty line is generated.