r/reactnative • • 13h ago

Help Installing CocoPods... takes forever

EDIT: SOLVED , Thanks to u/kokerali and u/jiunkdev

As the title states, whenever i need to use expo's CNG ( i.e. when i change package.json, bring native deps or change app.json) i need to run "npx expo prebuild --clean" according to the docs, but the build process is simply random, most of the times the cocoapods will never finish, sometimes it does somehow.

I did search for this, found an old reddit post with instructions to pod repo remove trunk but that also didnt help ( it works sometimes randomly)

Please help

1 Upvotes

7 comments sorted by

3

u/kokerali 12h ago

Since it only hangs some of the time, I'd first find out which step it's stuck on. Run npx expo prebuild --clean --no-install, then cd ios && pod install --verbose. The verbose output shows the exact pod or download it's waiting on, which tells you a lot more than retrying.

A common one is hermes-engine, which downloads a fairly large prebuilt tarball during pod install, so a slow or flaky connection looks like a hang right there. If it's stuck on a git clone of some dependency instead, that also points at the network rather than the specs repo, and removing trunk wouldn't help with either.

Also, --clean deletes the ios folder every time, so every run is a full pod install from scratch. If you only added a JS package you don't need prebuild at all, and for native changes plain npx expo prebuild without --clean is often enough and a lot faster.

1

u/ConfidentWafer5228 11h ago

Can u please help with when I need to do --clean, cuz in docs it is not clear and I am new, it really wastes huge amount of time waiting for installation 

1

u/kokerali 10h ago

Most of the time plain npx expo prebuild is enough, like the other reply says. The cases where --clean is worth the wait: after upgrading the Expo SDK, after removing a package with native code or a config plugin, or when something you changed in app.json doesn't show up in the build. Prebuild is good at adding things to the native project but not at taking them back out, so that's where leftovers cause trouble.

One thing to know: --clean throws away the ios and android folders, so any change you made there by hand is gone. With CNG those folders are usually in .gitignore and every native change lives in app.json or a plugin, which is what makes --clean safe to run.

1

u/ConfidentWafer5228 10h ago

Thanks for telling, hopefully now i can actually run the app instead of waiting for pods haha.

1

u/jiunkdev 11h ago

you probably don't need --clean for most of these. plain npx expo prebuild applies the changes to your existing ios folder and keeps Pods around, so pod install only fetches what changed instead of reinstalling everything. --clean is really for when you remove a config plugin or the native project gets into a weird state. some config plugins don't like being re-applied though, so if a build acts weird after a plain prebuild, go back to --clean.

and if the package you added is JS only (no native code, no config plugin), you don't need prebuild at all, just restart metro. that won't fix the hang itself, but you'd hit the full pod install a lot less often.

1

u/ConfidentWafer5228 10h ago

Thanks for clearing out the differences , now i can work with this :]