Committed changes on one branch break things on another branch - xcode

Here's a rundown of the issue:
I am running my project on the Xcode simulator, everything is fine.
I switch to a new branch to update react native. I run npm install and pod install.
I try building it, it fails, no problem, there are some kinks to work out.
I commit the changes I made, I'll come back to it later.
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.

Related

Xcode - Command PhaseScriptExecution failed with a nonzero exit code - Mac M1

This is the error I get when I try to build my Flutter app with Xcode 12.5.1. I can run the app on the Simulator without any problem, my friend with an Intel MacBook Pro can build it but I can't with my M1 processor.
After trying many things on my main project, I've decided to build an empty project in order to know where the problem was. And I still have the same error when I try to build a just created project.
I have noticed this line in the build target runner logs : export arch\=undefined_arch
Of course I have followed several topics about excluded architectures without success.
I once saw a topic that told to change the Build System to Legacy in the Workspace Settings. After doing that, I have an other error I can't resolve :
Command /bin/sh failed with exit code 1, but the export arch is now set to armv7.
I absolutely don't know why I can't build even a new Flutter project on my M1 Mac. Is it a problem with this undefined architecture ?
Here is more information about my configuration :
Flutter doctor
New Build System logs
Legacy Build System logs
I had the same error, you need to reinstall flutter on your device. Just remove the sdk folder or if you want to clean correctly you need to do that in you Flutter install directory :
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor

Xcode not reflecting latest app codes from react-native

EDIT:
Okay turns out this is not a problem with AppStore i ran the app from Xcode release mode and i got the same old version running on the simulator i don't know why but Xcode is not running the latest jsbundle.
now i found this question with the same problem and tried following it i ran this command:
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets and put the newly generated main.jsbundle inside /ios/ProjectName but still when i ran the code from Xcode it gives me an old version
i also tried cleaning and rebuilding and removing derived data and building again with same result
i recently uploaded an app to the Apple App Store but seems to be having issues with it here's the case i uploaded the app and it got approved and says its ready for sell but when i go to the app store and download the app it is just the previous version of the app and i don't see all the new changes made on the app...this is kind of strange for me i have also uploaded a new logo on the new version release and the logo is updated..the version is also updated on the app store listing the previous one was 1.0 this one shows 1.1 and the "Whats new" section is also updated...i have also changed the preview and screenshots with this new version that is also reflected on the app store listing but only when i download the app i get the previous version.
i tried going to my app store connect and then Activity and i see my build is there with a correct uploaded date and build numbers...is there something i am missing here?
Thanks,
Here is a detailed trial-and-error process trying to pin down which step is crucial to resolve the issue.
I start from the code base where npx react-native run-ios --configuration Release does reflect new changes in the code base. Each subsequent round follows the previous round, i.e., the previous round's end state might affect the next round.
Round 1
Remove main.jsbundle from both Xcode and the file system.
Make changes to the react native code base.
Run npx react-native run-ios --configuration Release
FAIL, new changes not reflected in the build.
Round 2
Try npm start -- --reset-cache
Run npx react-native run-ios --configuration Release
FAIL, new changes not reflected in the build.
Round 3
Try "Cmd + Shift + K" within Xcode to clean build.
Run npx react-native run-ios --configuration Release
FAIL, new changes not reflected in the build.
Round 4
Run react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/your_app_name/main.jsbundle
Run npx react-native run-ios --configuration Release
FAIL, new changes not reflected in the build.
Round 5
In Xcode, manually add the main.jsbundle file to your app folder. In your project, right click on the folder baring your app's name, choose "Add file to your_app_name", and add main.jsbundle in the app folder. Note that the bundle we add here was created in Round 4.
Run npx react-native run-ios --configuration Release. In the output message during command execution, a new message shows up: "Copying /.../your_app_name/ios/your_app_name/main.jsbundle".
SUCCCESS, new changes are showing now. This suggests that the bundle created in Round 4 is used for this build, instead of some previous version cached somewhere.
Round 6
Make another change in the react native code base.
Directly run npx react-native run-ios --configuration Release without building the bundle manually. The copy message does not show up.
FAIL, new changes not reflected in the build. Note that main.jsbundle exists in both Xcode and the file system.
Round 7
Run watchman watch-del-all to clean cache of watchman.
Run npx react-native run-ios --configuration Release. The copy message does not show up.
FAIL, new changes not reflected in the build.
Round 8
Run react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/your_app_name/main.jsbundle to rebuild a bundle.
Without tinkering with Xcode, directly run npx react-native run-ios --configuration Release. This time, the copy message shows up.
SUCCCESS, the latest changes are showing now.
Conclusion
At least on my laptop, manually building an offline bundle is required for each new release build to reflect the latest changes in the react native code base. Building the bundle only works if the bundle is added to the app folder in Xcode. It seems that we only need to add the bundle to Xcode once.
Also a big caveat is that the behavior might be different with a different Xcode version.
Versions I am working with
macOS Catalino 10.15.6
Xcode 11.6
react-native 0.61.5
I had the same issue and it turned out to be because it was running a cached version of the app so it got solved by doing npm start --reset-cache

Project Not Opening in XCode

My partner and I are using git to share our Xcode project. We accidentally added the same cocoapod and when I pulled from GitHub my project now won't open.
The merge error is in the podfile.lock but I can't figure out how to access that to fix it.
I've tried everything I can find on the internet which led me to the podfile.lock but I can't figure out where to go from here.
Generally, the error message is about
error: The sandbox is not in sync with the Podfile.lock
Run 'pod install' or update your CocoaPods installation
The usual workaround is to delete to Pod from the project, but here, the goal is to keep it, so, as the OP Ethan Hardacre comments:
the only solution to this problem that I could find was deleting the project and redownloading from GitHub.
In other words, keep the one that was pushed first to GitHub.

How to delete pods from subversion branch in Xcode 5

I am using CocoaPods to manage third party libraries and now I need to remove one of the pods.
Normally I would go to the local folder where I have checked out the repository folder to delete the files and then run pod install.
However, when trying to find the local folder for the subversion branch, I can not seem to find it. I checked in Xcode 5+ and it says the local folder for my branch is the same as the one I branched from. This seems strange to me because of how subversion normally works.
It would seem counterintuitive to be forced to check out every branch manually to be able to interact with the files from the command line.
How do I go about resolving this and deleting a pod from my branch without messing up the source of the branch?
Not sure exactly how you're saying that subversion makes this more difficult but to remove a pod from a project you should remove the line from your Podfile and run pod install

Cocoapods pod install as a target dependency

I've created an external build system target in my Xcode project and made it a dependency of the main target, so I want this target run before the main target starts building. In this external build system target I simply reference a bash script to run pod install from the SRCROOT dir.
As expected, my new target runs first and Pod install runs fine but then the build stops. It does not fail however, it just reports the Build stopped with no issues. The exit code from pod install is 0 so the script should return as successful yet the build stops.
Does anyone know why this may be happening?
I tried to implement the same functionality directly in CocoaPods and experienced the same behavior. I think that Xcode aborts the build as CocoaPods performs changes in the Pods project, which is recreated from scratch at the moment.
This approach might be viable once we start to edit in place the Pods project in CocoaPods.

Resources