Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/platform-ios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"dependencies": {
"@react-native-community/cli-tools": "^2.8.3",
"chalk": "^2.4.2",
"js-yaml": "^3.13.1",
"xcode": "^2.0.0"
},
"devDependencies": {
"@react-native-community/cli-types": "^3.0.0-alpha.2",
"@types/js-yaml": "^3.12.1",
"@types/plist": "^3.0.2"
},
"files": [
Expand Down
2 changes: 2 additions & 0 deletions packages/platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import findXcodeProject, {ProjectInfo} from './findXcodeProject';
import parseIOSDevicesList from './parseIOSDevicesList';
import findMatchingSimulator from './findMatchingSimulator';
import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs';
import warnAboutPodInstall from '../../link/warnAboutPodInstall';
import {
logger,
CLIError,
Expand Down Expand Up @@ -46,6 +47,7 @@ function runIOS(_: Array<string>, ctx: Config, args: FlagsT) {
}

warnAboutManuallyLinkedLibs(ctx);
warnAboutPodInstall(ctx);

process.chdir(args.projectPath);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import fs from 'fs';
import chalk from 'chalk';
import {logger} from '@react-native-community/cli-tools';
import {safeLoad} from 'js-yaml';

export default function getDependenciesFromPodfileLock(
podfileLockPath: string,
) {
logger.debug(`Reading ${podfileLockPath}`);
let fileContent;
try {
fileContent = fs.readFileSync(podfileLockPath, 'utf8');
} catch (err) {
logger.error(
`Could not find "Podfile.lock" at ${chalk.dim(
podfileLockPath,
)}. Did you run "${chalk.bold('pod install')}" in iOS directory?`,
);
return [];
}
return Object.keys(safeLoad(fileContent)['SPEC CHECKSUMS'] || {});
}
29 changes: 29 additions & 0 deletions packages/platform-ios/src/link/warnAboutPodInstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import path from 'path';
import chalk from 'chalk';
import {logger} from '@react-native-community/cli-tools';
import {Config} from '@react-native-community/cli-types';
import getDependenciesFromPodfileLock from '../link-pods/getDependenciesFromPodfileLock';

export default function warnAboutPodInstall(config: Config) {
const podLockDeps = getDependenciesFromPodfileLock(
`${config.project.ios!.podfile}.lock`,
);
const podDeps = Object.keys(config.dependencies)
.map(depName => {
const dependency = config.dependencies[depName].platforms.ios;
return dependency
? path.basename(dependency.podspecPath).replace(/\.podspec/, '')
: '';
})
.filter(Boolean);

const missingPods = podDeps.filter(podDep => !podLockDeps.includes(podDep));

if (missingPods.length) {
logger.error(
`Could not find the following native modules: ${missingPods
.map(pod => chalk.bold(pod))
.join(', ')}. Did you forget to run "${chalk.bold('pod install')}" ?`,
);
}
}
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,11 @@
dependencies:
"@types/jest-diff" "*"

"@types/js-yaml@^3.12.1":
version "3.12.1"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.1.tgz#5c6f4a1eabca84792fbd916f0cb40847f123c656"
integrity sha512-SGGAhXLHDx+PK4YLNcNGa6goPf9XRWQNAUUbffkwVGGXIxmDKWyGGL4inzq2sPmExu431Ekb9aEMn9BkPqEYFA==

"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
Expand Down Expand Up @@ -5784,7 +5789,7 @@ js-levenshtein@^1.1.3:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-yaml@^3.12.0, js-yaml@^3.13.0, js-yaml@^3.9.0:
js-yaml@^3.12.0, js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.9.0:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
Expand Down