diff --git a/lib/common/README.md b/lib/common/README.md index c756c61456..2d7b18532b 100644 --- a/lib/common/README.md +++ b/lib/common/README.md @@ -56,7 +56,7 @@ Before installing the `mobile-cli-lib`, verify that your system meets the follow * iTunes (latest official) * For testing in the native emulator - * Xcode 5 or later + * Xcode **Additional Software Requirements for Android On-Device Deployment** diff --git a/lib/common/bootstrap.ts b/lib/common/bootstrap.ts index f7b0c226a5..5585e575a6 100644 --- a/lib/common/bootstrap.ts +++ b/lib/common/bootstrap.ts @@ -74,7 +74,6 @@ injector.require( "./mobile/ios/device/ios-device-operations" ); -injector.require("iTunesValidator", "./validators/iTunes-validator"); injector.require("deviceDiscovery", "./mobile/mobile-core/device-discovery"); injector.require( "iOSDeviceDiscovery", diff --git a/lib/common/definitions/mobile.d.ts b/lib/common/definitions/mobile.d.ts index fb34eb2cd1..0c0458743b 100644 --- a/lib/common/definitions/mobile.d.ts +++ b/lib/common/definitions/mobile.d.ts @@ -814,10 +814,6 @@ declare global { webSocketDebuggerUrl: string; } - interface IiTunesValidator { - getError(): string; - } - interface ILocalToDevicePathData { getLocalPath(): string; getDevicePath(): string; diff --git a/lib/common/mobile/mobile-core/ios-device-discovery.ts b/lib/common/mobile/mobile-core/ios-device-discovery.ts index b08af861ee..7cfe3ec91e 100644 --- a/lib/common/mobile/mobile-core/ios-device-discovery.ts +++ b/lib/common/mobile/mobile-core/ios-device-discovery.ts @@ -4,30 +4,15 @@ import { IInjector } from "../../definitions/yok"; import { injector } from "../../yok"; export class IOSDeviceDiscovery extends DeviceDiscovery { - private _iTunesErrorMessage: string; - constructor( private $injector: IInjector, private $logger: ILogger, - private $iTunesValidator: Mobile.IiTunesValidator, private $mobileHelper: Mobile.IMobileHelper, private $iosDeviceOperations: IIOSDeviceOperations ) { super(); } - private validateiTunes(): boolean { - if (!this._iTunesErrorMessage) { - this._iTunesErrorMessage = this.$iTunesValidator.getError(); - - if (this._iTunesErrorMessage) { - this.$logger.warn(this._iTunesErrorMessage); - } - } - - return !this._iTunesErrorMessage; - } - public async startLookingForDevices( options?: Mobile.IDeviceLookingOptions ): Promise { @@ -41,28 +26,26 @@ export class IOSDeviceDiscovery extends DeviceDiscovery { return; } - if (this.validateiTunes()) { - await this.$iosDeviceOperations.startLookingForDevices( - (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { + await this.$iosDeviceOperations.startLookingForDevices( + (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { + const device = this.createDevice(deviceInfo); + this.addDevice(device); + }, + (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { + const currentDevice = this.getDevice(deviceInfo.deviceId); + if (currentDevice) { + const device = this.createDevice(deviceInfo); + this.updateDeviceInfo(device); + } else { const device = this.createDevice(deviceInfo); this.addDevice(device); - }, - (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { - const currentDevice = this.getDevice(deviceInfo.deviceId); - if (currentDevice) { - const device = this.createDevice(deviceInfo); - this.updateDeviceInfo(device); - } else { - const device = this.createDevice(deviceInfo); - this.addDevice(device); - } - }, - (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { - this.removeDevice(deviceInfo.deviceId); - }, - options - ); - } + } + }, + (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { + this.removeDevice(deviceInfo.deviceId); + }, + options + ); } private createDevice( diff --git a/lib/common/validators/iTunes-validator.ts b/lib/common/validators/iTunes-validator.ts deleted file mode 100644 index 811ecfa508..0000000000 --- a/lib/common/validators/iTunes-validator.ts +++ /dev/null @@ -1,100 +0,0 @@ -import * as path from "path"; -import { IFileSystem, IHostInfo } from "../declarations"; -import { injector } from "../yok"; - -export class ITunesValidator implements Mobile.IiTunesValidator { - private static NOT_INSTALLED_iTUNES_ERROR_MESSAGE = - "iTunes is not installed. Install it on your system and run this command again."; - private static BITNESS_MISMATCH_ERROR_MESSAGE = - "The bitness of Node.js and iTunes must match. Verify that both Node.js and iTunes are 32-bit or 64-bit and try again."; - private static UNSUPPORTED_OS_ERROR_MESSAGE = - "iTunes is not available for this operating system. You will not be able to work with connected iOS devices."; - - constructor(private $fs: IFileSystem, private $hostInfo: IHostInfo) {} - - public getError(): string { - if (this.$hostInfo.isWindows) { - let commonProgramFiles = ""; - const isNode64 = process.arch === "x64"; - - if (isNode64) { - //x64-windows - commonProgramFiles = process.env.CommonProgramFiles; - if ( - this.isiTunesInstalledOnWindows( - process.env["CommonProgramFiles(x86)"] - ) && - !this.isiTunesInstalledOnWindows(commonProgramFiles) - ) { - return ITunesValidator.BITNESS_MISMATCH_ERROR_MESSAGE; - } - } else { - if (this.$hostInfo.isWindows32) { - // x86-node, x86-windows - commonProgramFiles = process.env.CommonProgramFiles; - } else { - // x86-node, x64-windows - // check for x64-iTunes - commonProgramFiles = process.env["CommonProgramFiles(x86)"]; - - if ( - this.isiTunesInstalledOnWindows(process.env.CommonProgramFiles) && - !this.isiTunesInstalledOnWindows(commonProgramFiles) - ) { - return ITunesValidator.BITNESS_MISMATCH_ERROR_MESSAGE; - } - } - } - - if (!this.isiTunesInstalledOnWindows(commonProgramFiles)) { - return ITunesValidator.NOT_INSTALLED_iTUNES_ERROR_MESSAGE; - } - - return null; - } else if (this.$hostInfo.isDarwin) { - // Commented out check to get macOS Big Sur working - // by the looks of it - iTunes is no longer used by the CLI - // so we likely want to remove any legacy code related to it - // this is currently in progress - // TODO: remove this comment when no longer relevant. - return null; - // const coreFoundationDir = - // "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"; - // const mobileDeviceDir = - // "/System/Library/PrivateFrameworks/MobileDevice.framework/MobileDevice"; - // - // if (!this.isiTunesInstalledCore(coreFoundationDir, mobileDeviceDir)) { - // return ITunesValidator.NOT_INSTALLED_iTUNES_ERROR_MESSAGE; - // } - // - // return null; - } - - return ITunesValidator.UNSUPPORTED_OS_ERROR_MESSAGE; - } - - private isiTunesInstalledOnWindows(commonProgramFiles: string): boolean { - const coreFoundationDir = path.join( - commonProgramFiles, - "Apple", - "Apple Application Support" - ); - const mobileDeviceDir = path.join( - commonProgramFiles, - "Apple", - "Mobile Device Support" - ); - - return this.isiTunesInstalledCore(coreFoundationDir, mobileDeviceDir); - } - - private isiTunesInstalledCore( - coreFoundationDir: string, - mobileDeviceDir: string - ): boolean { - return ( - this.$fs.exists(coreFoundationDir) && this.$fs.exists(mobileDeviceDir) - ); - } -} -injector.register("iTunesValidator", ITunesValidator); diff --git a/test/ios-project-service.ts b/test/ios-project-service.ts index 60f18527e1..5993c6d124 100644 --- a/test/ios-project-service.ts +++ b/test/ios-project-service.ts @@ -125,7 +125,6 @@ function createTestInjector( testInjector.register("logFilter", LogFilter); testInjector.register("loggingLevels", LoggingLevels); testInjector.register("utils", Utils); - testInjector.register("iTunesValidator", {}); testInjector.register("xcprojService", { getXcprojInfo: () => { return {