Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Remove ios native dependencies #889

Merged
merged 8 commits into from
Mar 14, 2017

Conversation

TsvetanMilanov
Copy link
Contributor

We need to remove our native dependencies - ref and ffi because they are casuing problems with each version of NodeJS which has new version of V8 in it. We are using ref and ffi to communicate with iTunes and execute fs and application management operations on iOS devices. This operations are moved in new dependency - device-lib. The device lib has JavaScript wrapper which we use in the CLI. Everything in the ios device file system and ios device application manager is replaced with the exposed methods from the device lib.

@TsvetanMilanov TsvetanMilanov added this to the AB 3.7.0 milestone Feb 6, 2017
@TsvetanMilanov TsvetanMilanov self-assigned this Feb 6, 2017
@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch 2 times, most recently from a0904aa to 97cbce9 Compare February 6, 2017 16:01
Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov left a comment

Choose a reason for hiding this comment

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

Please fix relevant comments

]
*/
const mappedApps = _.map(applicationsOnDevice, app => {
return {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the short syntax here:

_.map(applicationsOnDevice, app => ({
    applicationIdentifier: app.CFBundleIdentifier,
    isLiveSyncSupported: app.IceniumLiveSyncEnabled,
    configuration: app.configuration,
    deviceIdentifier: this.device.deviceInfo.identifier
}));

}));
this.applicationsLiveSyncInfos = this.applicationsLiveSyncInfos.concat(currentList);
});
this.applicationsLiveSyncInfos = this.applicationsLiveSyncInfos.concat(mappedApps);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're setting this.applicationsLiveSyncInfos = [] 10 rows above, IMO there's no need to concat here.
You can skip this.applicationsLiveSyncInfos = [] from above and just reassign here:
this.applicationsLiveSyncInfos = mappedApps;


this.$logger.trace("Application %s has been uninstalled successfully.", appIdentifier);
}

public async startApplication(appIdentifier: string): Promise<void> {
if (this.$hostInfo.isWindows && !this.$staticConfig.enableDeviceRunCommandOnWindows) {
this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
// this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we need it.

try {
await settlePromises(await this.$iosDeviceOperations.uploadFiles(filesToUpload));
} catch (err) {
if (err.deviceId === this.device.deviceInfo.identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

settlePromises alters the thrown error, so you won't get an object that has a deviceId in the catch clause

}
}

@cache()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should @cache this - what if we want to start a second device log (e.g. we have two devices attached)

import * as applicationManagerPath from "./ios-application-manager";
import * as fileSystemPath from "./ios-device-file-system";
import * as constants from "../../../constants";
import * as net from "net";

export class IOSDevice implements Mobile.IiOSDevice {
// iOS errors are described here with HEX representation
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO you can delete those comments too - they're no longer relevant


public async openDeviceLogStream(): Promise<void> {
if (this.deviceInfo.status !== constants.UNREACHABLE_STATUS) {
await this.$iosDeviceOperations.startDeviceLog(this.deviceInfo.identifier, (data: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need to await this - it doesn't return a Promise

Copy link
Collaborator

@rosen-vladimirov rosen-vladimirov left a comment

Choose a reason for hiding this comment

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

The title says: Remove ios native dependencies
However the PR just adds dependency in package.json. Shouldn't we actually delete the native dependencies from package.json?

this.$logger.trace(`Error while uninstalling application ${e}.`);
}
await this.$iosDeviceOperations.uninstall(appIdentifier, [this.device.deviceInfo.identifier], (err: IDeviceOperationError) => {
this.$logger.warn(`Failed to uninstall install ${appIdentifier} on device with identifier ${err.deviceIdentifier}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

which operation failed - unisntall or install ?


public async execute(args: string[]): Promise<void> {
await this.$devicesService.initialize({ deviceId: this.$options.device, skipInferPlatform: true });
let appIdentifier = args[1];
Copy link
Collaborator

Choose a reason for hiding this comment

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

as we modify the command, shouldn't we delete the $options.app that has been used before (not in the command itself, but in the service behind it. If I understand correctly, we'll support getting of file only from application sandbox, so the $options.app is a mandatory argument now. So... let's remove $options.app


this.$logger.trace("Application %s has been uninstalled successfully.", appIdentifier);
}

public async startApplication(appIdentifier: string): Promise<void> {
if (this.$hostInfo.isWindows && !this.$staticConfig.enableDeviceRunCommandOnWindows) {
this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
// this.$errors.fail("$%s device run command is not supported on Windows for iOS devices.", this.$staticConfig.CLIENT_NAME.toLowerCase());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we need it.

@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch 2 times, most recently from c752b38 to 99e1148 Compare February 9, 2017 12:13
@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch 2 times, most recently from cda297e to f06b56e Compare February 23, 2017 14:34
@Plamen5kov
Copy link
Contributor

related issue: NativeScript/nativescript-cli#2562

We need to remove our native dependencies - ref and ffi because they are casuing problems with each version of NodeJS which has new version of V8 in it. We are using ref and ffi to communicate with iTunes and execute fs and application management operations on iOS devices. This operations are moved in new dependency - device-lib. The device lib has JavaScript wrapper which we use in the CLI. Everything in the ios device file system and ios device application manager is replaced with the exposed methods from the device lib.
@Mitko-Kerezov Mitko-Kerezov force-pushed the milanov/remove-ios-native-dependencies branch from f978b57 to 741a91d Compare March 3, 2017 12:05
@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch from f2d2993 to 220a852 Compare March 10, 2017 09:15
Since we use the ios-device-lib to connect to the device backend port for debugging, the socket returned from the device can be used only in the ios-device lib.
That's why we need to change the logic for creating the Node.js socket in the CLI. The ios-device-lib will expose the device socket on a specific port in the localhost.
After we connect to the exposed socket we can continue to work like we used to.
@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch from 220a852 to cfd19f2 Compare March 10, 2017 17:40
@justcodebuilduser
Copy link

💔

@TsvetanMilanov
Copy link
Contributor Author

run ci

@justcodebuilduser
Copy link

❤️

@TsvetanMilanov TsvetanMilanov force-pushed the milanov/remove-ios-native-dependencies branch from 802b22c to 32ecf38 Compare March 14, 2017 10:12
@justcodebuilduser
Copy link

❤️

@TsvetanMilanov TsvetanMilanov merged commit 6bcc88c into master Mar 14, 2017
@TsvetanMilanov TsvetanMilanov deleted the milanov/remove-ios-native-dependencies branch March 14, 2017 11:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants