Skip to content
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

Add physical device support #109

Merged
merged 29 commits into from
Nov 13, 2017
Merged

Add physical device support #109

merged 29 commits into from
Nov 13, 2017

Conversation

JoeSSS
Copy link
Contributor

@JoeSSS JoeSSS commented Nov 11, 2017

No description provided.

@JoeSSS JoeSSS changed the title [WIP] Add physical device support Add physical device support Nov 11, 2017
@JoeSSS
Copy link
Contributor Author

JoeSSS commented Nov 11, 2017

@BasThomas would be nice to get a review here, as we want to release this version before publishing at Monday morning.

@@ -9,6 +9,7 @@ enum Constants {
static let installSimulatorOrPluginDevice = "Please install a simulator or plug-in your device.".localized
static let useLocalBuild = "Skipping download. Use a local app version.".localized
static let notCompatibleWithDeviceType = "not compatible with chosen device type.".localized
static let wrongDeviceSetup = "Please, provide your device IP and bundle identifier. It can be done under 'Configure Device' settings.\n".localized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the \n here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, good question. Didn't have time to investigate. We just need a new line there, as the method that outputs doesn't do it for free. Do you think it will be better to add the \n in the code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it would be a better fit in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


override func viewDidLoad() {
super.viewDidLoad()
if let deviceIP = applicationStateHandler.deviceIP {
textField.stringValue = deviceIP
}
if let bundleIDdata = applicationStateHandler.bundleID {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you bind this to bundleIDdata and not just bundleID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because bundleID is already an outlet name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I think it would be more readable when we rename the bundleID outlet to bundleIDTextField (and also rename the vanilla textField; what's that?) and then in turn rename the bundleIDdata to bundleID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Don't like bundleIDTextField: NSTextField tho. But this is always better than names before ;)

let bundleID = applicationStateHandler.bundleID,
physicalDeviceRadioButton.state == .on,
!deviceIP.isEmpty {
arguments.append("export DEVICE_ENDPOINT=http://\(deviceIP):37265")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this port (the 37265, I think it's a port?) always the same? Maybe add a constant for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this will be always the same. It is Calabash default port. I will add it to the constants

}

var simulatorRadioButtonState: Int {
var simulatorRadioButtonState: Bool? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this optional? bool(forKey:) returns a Bool: https://developer.apple.com/documentation/foundation/userdefaults/1416388-bool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. It was actually causing a bug for a new user.

@JoeSSS
Copy link
Contributor Author

JoeSSS commented Nov 13, 2017

@BasThomas is it ok to be merged?

}

var simulatorRadioButtonState: Int {
var physicalRadioButtonState: Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. You removed simulatorRadioButtonState, and the renamed physicalRadioButtonState references .simulatorRadioButtonState.

}
enum Ruby {
static let helpers = main.path(forResource: "helpers", ofType: .ruby)
}
}

enum DeviceType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be here. I can imagine that this enum will have some more functionality in the future, and I feel it's not strictly just constants.

import AppKit

class DeviceSettingsViewController: NSViewController {
let applicationStateHandler = ApplicationStateHandler()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using this pretty frequently. I am almost thinking it would make sense to add a singleton here?!

func getSimulatorsCommand() {
if let launchPath = Constants.FilePaths.Bash.simulators {
func getDevicesCommand(ofType type: Constants.DeviceType) {
var path: String?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a let path: String

let outputStream = CommandTextOutputStream()
outputStream.textHandler = { text in
let filderedText = text.components(separatedBy: "\n").filter { $0.contains("Simulator") }
let filteredText = text.components(separatedBy: "\n").filter { !RegexHandler().matches(for: "\\(([^()])*\\) \\[(.*?)\\]", in: $0).isEmpty }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe do a == false in the filter instead of the ! at the beginning. Especially since you have the matches (but are actually checking the isEmpty), this is pretty easily misread.

@@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do this in a separate PR next time! 😬

@JoeSSS JoeSSS merged commit 8778dc1 into master Nov 13, 2017
@JoeSSS JoeSSS deleted the add_phys_device_support branch November 13, 2017 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants