Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const createBuild =

let {xcodeProject, sourceDir} = getXcodeProjectAndDir(
platform,
platformName,
installedPods,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import fs from 'fs';
import {IOSProjectConfig} from '@react-native-community/cli-types';
import {CLIError} from '@react-native-community/cli-tools';
import findXcodeProject from '../../config/findXcodeProject';
import {getPlatformInfo} from '../runCommand/getPlatformInfo';
import {ApplePlatform} from '../../types';

export function getXcodeProjectAndDir(
iosProjectConfig: IOSProjectConfig | undefined,
platformName: ApplePlatform,
installedPods?: boolean,
) {
const {readableName: platformReadableName} = getPlatformInfo(platformName);

if (!iosProjectConfig) {
throw new CLIError(
'iOS project folder not found. Are you sure this is a React Native project?',
`${platformReadableName} project folder not found. Make sure that project.${platformName}.sourceDir points to a directory with your Xcode project and that you are running this command inside of React Native project.`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const createRun =

let {xcodeProject, sourceDir} = getXcodeProjectAndDir(
platform,
platformName,
installedPods,
);

Expand Down
8 changes: 7 additions & 1 deletion packages/cli-platform-apple/src/config/findPodfilePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {inlineString, logger} from '@react-native-community/cli-tools';
import path from 'path';
import findAllPodfilePaths from './findAllPodfilePaths';
import {ApplePlatform} from '../types';
import {supportedPlatforms} from './supportedPlatforms';

// Regexp matching all test projects
const TEST_PROJECTS = /test|example|sample/i;
Expand Down Expand Up @@ -50,8 +51,13 @@ export default function findPodfilePath(
*/
.sort((project) => (path.dirname(project) === platformName ? -1 : 1));

const supportedPlatformsArray: string[] = Object.values(supportedPlatforms);
const containsOnlySupportedPodfiles = podfiles.every((podfile) =>
supportedPlatformsArray.includes(podfile.split('/')[0]),
);

if (podfiles.length > 0) {
if (podfiles.length > 1) {
if (podfiles.length > 1 && !containsOnlySupportedPodfiles) {
logger.warn(
inlineString(`
Multiple Podfiles were found: ${podfiles}. Choosing ${podfiles[0]} automatically.
Expand Down