public async getExecutableAndConfigurationFolder()

in src/extension/ios/plistBuddy.ts [67:143]


    public async getExecutableAndConfigurationFolder(
        platformProjectRoot: string,
        projectRoot: string,
        platform: PlatformType.iOS | PlatformType.macOS,
        simulator: boolean = true,
        configuration: string = "Debug",
        productName?: string,
        scheme?: string,
    ): Promise<IOSBuildLocationData> {
        const rnVersions = await ProjectVersionHelper.getReactNativeVersions(projectRoot);
        let productsFolder;
        if (semver.gte(rnVersions.reactNativeVersion, "0.59.0")) {
            if (!scheme) {
                // If no scheme were provided via runOptions.scheme or via runArguments then try to get scheme using the way RN CLI does.
                scheme = this.getInferredScheme(
                    platformProjectRoot,
                    projectRoot,
                    rnVersions.reactNativeVersion,
                );
                if (platform === PlatformType.macOS) {
                    scheme = `${scheme}-macOS`;
                }
            }
            productsFolder = path.join(platformProjectRoot, "build", scheme, "Build", "Products");
        } else {
            productsFolder = path.join(platformProjectRoot, "build", "Build", "Products");
        }
        const sdkType =
            platform === PlatformType.iOS ? this.getSdkType(simulator, scheme) : undefined;
        let configurationFolder = path.join(
            productsFolder,
            `${configuration}${sdkType ? `-${sdkType}` : ""}`,
        );
        let executable = "";
        if (productName) {
            executable = `${productName}.app`;
            if (!fs.existsSync(path.join(configurationFolder, executable))) {
                const configurationData = this.getConfigurationData(
                    projectRoot,
                    rnVersions.reactNativeVersion,
                    platformProjectRoot,
                    configuration,
                    scheme,
                    configurationFolder,
                    sdkType,
                );

                configurationFolder = configurationData.configurationFolder;
            }
        } else {
            const executableList = this.findExecutable(configurationFolder);
            if (!executableList.length) {
                const configurationData_1 = this.getConfigurationData(
                    projectRoot,
                    rnVersions.reactNativeVersion,
                    platformProjectRoot,
                    configuration,
                    scheme,
                    configurationFolder,
                    sdkType,
                );

                configurationFolder = configurationData_1.configurationFolder;
                executableList.push(configurationData_1.fullProductName);
            } else if (executableList.length > 1) {
                throw ErrorHelper.getInternalError(
                    InternalErrorCode.IOSFoundMoreThanOneExecutablesCleanupBuildFolder,
                    configurationFolder,
                );
            }
            executable = `${executableList[0]}`;
        }
        return {
            executable,
            configurationFolder,
        };
    }