public async getTarget()

in src/extension/ios/iOSPlatform.ts [93:136]


    public async getTarget(): Promise<IOSTarget> {
        if (!this.target) {
            const targetFromRunArgs = await this.getTargetFromRunArgs();
            if (targetFromRunArgs) {
                this.target = targetFromRunArgs;
            } else {
                const targets =
                    (await this.targetManager.getTargetList()) as IDebuggableIOSTarget[];
                const targetsBySpecifiedType = targets.filter(target => {
                    switch (this.runOptions.target) {
                        case TargetType.Simulator:
                            return target.isVirtualTarget;
                        case TargetType.Device:
                            return !target.isVirtualTarget;
                        case undefined:
                        case "":
                            return true;
                        default:
                            return (
                                target.id === this.runOptions.target ||
                                target.name === this.runOptions.target
                            );
                    }
                });
                if (targetsBySpecifiedType.length) {
                    this.target = IOSTarget.fromInterface(targetsBySpecifiedType[0]);
                } else if (targets.length) {
                    this.logger.warning(
                        localize(
                            "ThereIsNoTargetWithSpecifiedTargetType",
                            "There is no any target with specified target type '{0}'. Continue with any target.",
                            this.runOptions.target,
                        ),
                    );
                    this.target = IOSTarget.fromInterface(targets[0]);
                } else {
                    throw ErrorHelper.getInternalError(
                        InternalErrorCode.IOSThereIsNoAnyDebuggableTarget,
                    );
                }
            }
        }
        return this.target;
    }