public async getTargetFromRunArgs()

in src/extension/ios/iOSPlatform.ts [313:377]


    public async getTargetFromRunArgs(): Promise<IOSTarget | undefined> {
        if (this.runOptions.runArguments && this.runOptions.runArguments.length > 0) {
            const targets = (await this.targetManager.getTargetList()) as IDebuggableIOSTarget[];

            const udid = GeneralMobilePlatform.getOptFromRunArgs(
                this.runOptions.runArguments,
                "--udid",
            );
            if (udid) {
                const target = targets.find(target => target.id === udid);
                if (target) {
                    return IOSTarget.fromInterface(target);
                }
                this.logger.warning(
                    localize(
                        "ThereIsNoIosTargetWithSuchUdid",
                        "There is no iOS target with such UDID: {0}",
                        udid,
                    ),
                );
            }

            const device = GeneralMobilePlatform.getOptFromRunArgs(
                this.runOptions.runArguments,
                "--device",
            );
            if (device) {
                const target = targets.find(
                    target => !target.isVirtualTarget && target.name === device,
                );
                if (target) {
                    return IOSTarget.fromInterface(target);
                }
                this.logger.warning(
                    localize(
                        "ThereIsNoIosDeviceWithSuchName",
                        "There is no iOS device with such name: {0}",
                        device,
                    ),
                );
            }

            const simulator = GeneralMobilePlatform.getOptFromRunArgs(
                this.runOptions.runArguments,
                "--simulator",
            );
            if (simulator) {
                const target = targets.find(
                    target => target.isVirtualTarget && target.name === simulator,
                );
                if (target) {
                    return IOSTarget.fromInterface(target);
                }
                this.logger.warning(
                    localize(
                        "ThereIsNoIosSimulatorWithSuchName",
                        "There is no iOS simulator with such name: {0}",
                        simulator,
                    ),
                );
            }
        }

        return undefined;
    }