-
Notifications
You must be signed in to change notification settings - Fork 932
feat: add warnings for run-ios and run-android when manually linked libraries detected
#447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // @flow | ||
|
|
||
| import chalk from 'chalk'; | ||
| import {logger} from '@react-native-community/cli-tools'; | ||
| import type {ConfigT} from 'types'; | ||
| import getLinkConfig from './index'; | ||
|
|
||
| // TODO: move to cli-tools once platform-ios and platform-android are migrated | ||
| // to TS and unify with iOS implementation | ||
| export default function warnAboutManuallyLinkedLibs( | ||
| config: ConfigT, | ||
| platform: string = 'android', | ||
| linkConfig: $Call<typeof getLinkConfig> = getLinkConfig(), | ||
| ) { | ||
| let deps = []; | ||
|
|
||
| for (let key in config.dependencies) { | ||
| const dependency = config.dependencies[key]; | ||
| try { | ||
| const projectConfig = config.project[platform]; | ||
| const dependencyConfig = dependency.platforms[platform]; | ||
| if (projectConfig && dependencyConfig) { | ||
| const x = linkConfig.isInstalled( | ||
| projectConfig, | ||
| dependency.name, | ||
| dependencyConfig, | ||
| ); | ||
| deps = deps.concat(x ? dependency.name : []); | ||
| } | ||
| } catch (error) { | ||
| logger.debug('Checking manually linked modules failed.', error); | ||
| } | ||
| } | ||
|
|
||
| const installedModules = [...new Set(deps)]; | ||
|
|
||
| if (installedModules.length) { | ||
| logger.error( | ||
| `React Native CLI uses autolinking for native dependencies, but following modules are linked manually: \n${installedModules | ||
| .map( | ||
| x => | ||
| ` - ${chalk.bold(x)} ${chalk.dim( | ||
| `(to unlink run: "react-native unlink ${x}")`, | ||
| )}`, | ||
| ) | ||
| .join( | ||
| '\n', | ||
| )}\nThis is likely to happen when upgrading React Native from version lower than 0.60 to 0.60 or later. Please unlink them as they are likely to cause build failures. You can do so with "react-native unlink" command as shown above. If a library is not compatible with autolinking yet, please ignore this warning and notify the library maintainers.`, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via Read more about autolinking: […]" |
||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,14 @@ | |
| */ | ||
|
|
||
| import path from 'path'; | ||
| import {memoize} from 'lodash'; | ||
| import findProject from './findProject'; | ||
| import findPodfilePath from './findPodfilePath'; | ||
| import findPodspec from './findPodspec'; | ||
| import type {UserConfigT} from 'types'; | ||
|
|
||
| const memoizedFindProject = memoize(findProject); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| /** | ||
| * For libraries specified without an extension, add '.tbd' for those that | ||
| * start with 'lib' and '.framework' to the rest. | ||
|
|
@@ -37,7 +40,7 @@ export function projectConfig( | |
| if (!userConfig) { | ||
| return; | ||
| } | ||
| const project = userConfig.project || findProject(folder); | ||
| const project = userConfig.project || memoizedFindProject(folder); | ||
|
|
||
| /** | ||
| * No iOS config found here | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // @flow | ||
|
|
||
| import chalk from 'chalk'; | ||
| import {logger} from '@react-native-community/cli-tools'; | ||
| import type {ConfigT} from 'types'; | ||
| import getLinkConfig from './index'; | ||
|
|
||
| // TODO: move to cli-tools once platform-ios and platform-android are migrated | ||
| // to TS and unify with Android implementation | ||
| export default function warnAboutManuallyLinkedLibs( | ||
| config: ConfigT, | ||
| platform?: string = 'ios', | ||
| linkConfig: $Call<typeof getLinkConfig> = getLinkConfig(), | ||
| ) { | ||
| let deps = []; | ||
|
|
||
| for (let key in config.dependencies) { | ||
| const dependency = config.dependencies[key]; | ||
| try { | ||
| const projectConfig = config.project[platform]; | ||
| const dependencyConfig = dependency.platforms[platform]; | ||
| if (projectConfig && dependencyConfig) { | ||
| const x = linkConfig.isInstalled( | ||
| projectConfig, | ||
| dependency.name, | ||
| dependencyConfig, | ||
| ); | ||
| deps = deps.concat(x ? dependency.name : []); | ||
| } | ||
| } catch (error) { | ||
| logger.debug('Checking manually linked modules failed.', error); | ||
| } | ||
| } | ||
|
|
||
| const installedModules = [...new Set(deps)]; | ||
|
|
||
| if (installedModules.length) { | ||
| logger.error( | ||
| `React Native CLI uses autolinking for native dependencies, but following modules are linked manually: \n${installedModules | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "but the following" |
||
| .map( | ||
| x => | ||
| ` - ${chalk.bold(x)} ${chalk.dim( | ||
| `(to unlink run: "react-native unlink ${x}")`, | ||
| )}`, | ||
| ) | ||
| .join( | ||
| '\n', | ||
| )}\nThis is likely to happen when upgrading React Native from version lower than 0.60 to 0.60 or later. Please unlink them as they are likely to cause build failures. You can do so with "react-native unlink" command as shown above. If a library is not compatible with autolinking yet, please ignore this warning and notify the library maintainers.`, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
| ); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"but the following"