Skip to content
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

fix: install pods on ios-commands with New Arch #2122

Conversation

TMisiukiewicz
Copy link
Collaborator

Summary:

Coming from #2091. Currently, when installed pods with New Architecture manually, added new package and used run-ios, it installed pods with old Architecture again. This change checks if the New Architecture is enabled and installs it with/without a flag.

Test Plan:

  1. Init new project and install pods during the init
  2. Add a library containing native code e.g. react-native-gesture-handler
  3. Run run-ios and verify it installed pods and ran the app
  4. Go to ios folder and install pods with New Arch manually, RCT_NEW_ARCH_ENABLED=1 pod install
  5. Add another library, e.g. react-native-reanimated
  6. Run run-ios and verify pods are being installed with a with New Architecture message
  7. When app is running, verify fabric: true is visible in Metro console

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

path.join(iosSourceDir, '/Pods/Pods.xcodeproj/project.pbxproj'),
);

return project.includes('-DRCT_NEW_ARCH_ENABLED=1');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cipolleschi is this fine if we use that to detect new arch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this should be enough.

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TMisiukiewicz please rebase and merge? :)

import {readFile} from 'fs-extra';
import path from 'path';

export default async function getArchitecture(iosSourceDir: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the same logic in doctor command:

const project = await readFile(
path.join(
ctx.project.ios.sourceDir,
'/Pods/Pods.xcodeproj/project.pbxproj',
),
);
platforms.iOS.newArchEnabled = project.includes(
'-DRCT_NEW_ARCH_ENABLED=1',
);

mind using this function also there - so we won't have in two places same code? 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already here:

const isNewArchitecture = await getArchitecture(

@TMisiukiewicz
Copy link
Collaborator Author

@szymonrybczak to resolve conflicts i moved iosFolderPath to installPods options object, would you mind double-check if it's fine?

Comment on lines +134 to +138
throw new CLIError(
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
'pod install',
)} manually`,
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm wondering should we add here info about flags that we added 🤔

Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙌

@TMisiukiewicz TMisiukiewicz merged commit 97e68ae into react-native-community:main Oct 23, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants