Skip to content

Commit f9584c3

Browse files
authored
fix: fix @react-native-community/cli-platform-apple not being resolved correctly (microsoft#2820)
## Summary: `@react-native-community/cli-platform-apple` is not correctly resolved in pnpm setups: ``` % DEBUG=react-native yarn build:macos /~/packages/app/example/node_modules/react-native-macos/react-native.config.js: @react-native-community/cli-platform-apple not found, the react-native.config.js may be unusable. info Bundling macos... error Invalid platform "macos" selected. info Available platforms are: "android", "ios", "windows". If you are trying to bundle for an out-of-tree platform, it may not be installed. ``` ## Test Plan: n/a
1 parent b9dde72 commit f9584c3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/react-native/react-native.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ try {
7171
// [macOS
7272
let apple;
7373
try {
74+
const iosPath = require.resolve('@react-native-community/cli-platform-ios', {
75+
paths: [process.cwd()],
76+
});
7477
// $FlowFixMe[untyped-import]
75-
apple = require('@react-native-community/cli-platform-apple');
78+
apple = findCommunityPlatformPackage(
79+
'@react-native-community/cli-platform-apple',
80+
iosPath,
81+
);
7682
} catch {
7783
if (verbose) {
7884
console.warn(
@@ -156,7 +162,7 @@ if (android != null) {
156162

157163
// [macOS
158164
config.commands.push(...macosCommands);
159-
if (apple != null) {
165+
if (apple) {
160166
config.platforms.macos = {
161167
linkConfig: () => {
162168
return {

0 commit comments

Comments
 (0)