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: add bundle command as a fallback to CocoaPods check #304

Conversation

lucasbento
Copy link
Collaborator

Fixes #303.

This PR adds bundle exec pod --version as a "second attempt" to verify that CocoaPods is installed, the current implementation that's solely relying in pod --version to check for CocoaPods installation will fail in projects using Bundler.

Since bundle commands are tied to the specific project installation, it's necessary to execute the command from within the project directory path.

Copy link

vercel bot commented May 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2024 11:52am

isCocoaPodsInstalled = await checkIfCLIInstalled("bundle exec pod --version", {
env,
// Run the command in the current project directory
cwd: workspace.workspaceFolders?.[0].uri.fsPath,
Copy link
Member

Choose a reason for hiding this comment

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

Can we safely assume that first workspace directory is always an app directory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not always, it largely depends on the users' setup but this is a fair try IMHO.
We could attempt to look for the correct folder within the fsPath, though.

const installed = await checkIfCLIInstalled("pod --version", {
env: { ...process.env, LANG: "en_US.UTF-8" },
const env = { ...process.env, LANG: "en_US.UTF-8" };
let isCocoaPodsInstalled = await checkIfCLIInstalled("pod --version", {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can we fit it in the one line please?

});

// If `pod --version` fails, try `bundle exec pod --version` as a second attempt
if (!isCocoaPodsInstalled && workspace.workspaceFolders?.length) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we please make it more explicit? workspace.workspaceFolders?.length > 0

@jakub-gonet
Copy link
Member

This wasn't active for quite a while now so I'm closing it. If need arises, we will reimplement it in the future. Thanks!

kmagiera added a commit that referenced this pull request Oct 14, 2024
This is a draft as it is build on top of #615

This PR refactors the way we install pods in the IDE. The main objective
is to optionally use `bundle` command. This is similar to the changes
proposed in #304 but apart from using bundle for the diagnostics check,
we also use it when installing (which is a mechanism that wasn't in
place when #304 was created).

The second main change that we're making is that we trigger pod
installation when clean build is requested. Before that wasn't
happening.

On top of that, we are including pod command output in the iOS build
log. This will help diagnose potential problems better and will also
provide some feedback for the scenarios when installation take very
long.

Finally, we are fixing the startup message component such that it resets
long wait flag and we are also adding a more prominent message "open
logs" for the native build phase. This way it should be easier to spot
for the users that they can see the build output in case the build takes
long:
<img width="360" alt="image"
src="https://github.com/user-attachments/assets/64ea681c-1b9a-498c-98ef-c4afbe2826fc">


### How Has This Been Tested: 
1. Run clean build in on of the test apps for iOS. See cocoapods in the
log output
2. Run RN 76 example on iOS to see bundle being used there instead of
pod install (check logs)
3. When building on iOS, see that the "open logs" text appears in the
startup message and you can click it to open the logs output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CocoaPods installation check not working with Bundler
2 participants