简体   繁体   中英

Committed changes on one branch break things on another branch

Here's a rundown of the issue:

  1. I am running my project on the Xcode simulator, everything is fine.
  2. I switch to a new branch to update react native. I run npm install and pod install.
  3. I try building it, it fails, no problem, there are some kinks to work out.
  4. I commit the changes I made, I'll come back to it later.
  5. I switch back to the first branch and now the build fails with the same errors that I was getting on the new branch.

I haven't made any changes to the first branch, git log is the same as it was before, why is this happening?

Both are now failing in Android Studio too, though with a different error.

Xcode errors:

ENOENT: no such file or directory – I think this is because of a space in my path. It wasn't an issue before I did the update but if I fix that, I get:

The sandbox is not in sync with podfile.lock (What is the sandbox? I wonder if this is the issue?)

Android Studio Errors:

Gradle sync failed: Plugin with id 'maven' not found

The issue isn't the errors, I can find solutions to those, the issue is that it was working, nothing changed, and now it's not working.

I've run into this two times. The first time I read forums for hours and tried all that I could but the only thing that helped was deleting my local repo and pulling down a new one from the remote. But, it'd be nice to not have to do that every time I update something.

Has anyone run into this?

Here're some specs if helpful:

  • Xcode: 13.2.1
  • MacOS: Monterrey 12.2 (Intel)
  • Macbook Pro, 16G
  • React Native on first branch: 0.65.1
  • React Native on new branch: 0.67.4
  • Android Studio: Bumblebee| 2021.1.1 Patch 2
  • Node on first branch: 12.19.1
  • npm on first branch: 6.14.15
  • Node on new branch: 16.14.0
  • npm on new branch: 8.3.1

Many thanks in advance!

The issue is probably that changes were made to files that are in your gitignore, possibly the Podfile.lock and within node_modules. When switching back to your original branch, you'll have to run yarn / npm install again, and then pod install. The "sandbox" error occurs when the contents of the Pods directory is out of sync with what is prescribed in the Podfile.

If you've already done that, try stopping your Metro instance and running npx react-native-clean-project . There are several caches that could need to be invalidated or refreshed: native builds, Metro, gradle, watchman, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM