ERROR: main.jsbundle does not exist - React Native 0.60.4 - xcode

I'm trying to publish my first React Native app in App store and when I'll build in Xcode:
Product > Archive
appears some error, but i already have main.jsbundle
main.jsbundle does not exist. This must be a bug with
echo 'React Native
Screen Error:

You can generate a new main.jsbundle using this command.
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Run this command in your project directory.

In my case, I was able to fix the issue by removing main.jsbundle from Bundle Resources.
Open react native project in xcode
Check if Copy Bundle Resources build phase contains main.jsbundle
If it contains, remove it and build again

Clear watchman watches:
watchman watch-del-all
Delete node_modules:
rm -rf node_modules and run yarn install
Reset Metro's cache:
yarn start --reset-cache
Remove the cache:
rm -rf /tmp/metro-*

In Xcode, you should be able to find the main.jsbundle inside the Xcode project sidebar.
If it isn't there, then you should drag the main.jsbundle into your Xcode project (in the default template app you can find it at ios/main.jsbundle)
If it is in there, but red - then you need to build a copy of the main.jsbundle which you can do via react-native bundle (and some additional args which you can look up.

I was getting the error because of a bug in the code, instead of using simulator I was using Xcode to install a release build to my device which led to this error.
To fix this, run the app on the simulator make sure it builds and runs properly and then install it on your device.

Try this instead
Go to Xcode
Go to targets
Select Build phases from the top
Just remove main.jsbundle lib from Copy Bundle Resources in build phase
re-run again.

Related

issue with all >1.2 flutter version on mac

17.5 ( last before 1.2 ) and when I try to upgrade to 1.2 or more I have
Warning: Podfile is out of date
This can cause issues if your application depends on plugins that do not support iOS.
See https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms for details.
If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/45197 for instructions.
To regenerate the Podfile, run:
rm ios/Podfile
I tried rm ios/Podfile
rm: ios/Podfile: No such file or directory
I follow issue and solution but not working with me ... Or did wrong things
If someone can help me thank you
[Edit] : I remove podfil, and It's ok, thank you for help
Find where your project file is stored in finder. Or by typing find ~/ -type f -name "YOUR PROJECT NAME" in terminal. list your files by typing ls and go into the ios file in your flutter project, then type rm Podfile. This should delete the podfile, and once you run the project again, the pods will be installed via flutter
Best thing to do here is regenerate the iOS Project.
If you have made any changes to the native solution (Xcode), meaning new view controllers, assets, or video files, etc, then make sure to back those up first.
Then delete the iOS project, from your flutter project workspace, and run the following command:
flutter create -i swift .
This will generate a swift solution, but if you're looking for objective-c then try this:
flutter create -i objc .
After the iOS project is recreated, you will need to clean the project, then make sure that the podfile exists in your project directory.
Then run:
cd ios
podfile install
After the podfile installs all the required dependencies, try a fresh deployment of your iOS project:
flutter run -d "Device Name" --release
But make sure that you are running flutter on the root directory, so:
cd ..

Flutter app uploading to AppStore Xcode error: Rsync failed

Whenever I try to Validate App after Archiving it in Xcode I get the following error popup:
Rsync failed
It then shows a 'Show logs.' button but when I select that it opens a folder called 'T' which contains many files and folders.
How can I see the logs that I need to fix this error?
Using Xcode 11.5
Usually the problem with Rsync is with the pods and the build itself. Try to run flutter clean, run pod install inside the ios folder, test your app in a real devidce, build the app and try again.

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

xcode_backend.sh: no such file or directory. Do I need to create this file?

My Flutter Project won't run on the ios simulator and is throwing this error:
Launching lib/main.dart on iPhone Xʀ in debug mode...
Running Xcode build...
Xcode build done. 7.6s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/bin/sh: /Users/pinercode/AndroidStudioProjects/bmi-calculator-flutter/packages/flutter_tools/bin/xcode_backend.sh: No such file or directory
Could not build the application for the simulator.
Error launching application on iPhone Xʀ.
The xcode error was also as follows:
/bin/sh: /Users/pinercode/AndroidStudioProjects/bmi-calculator-flutter/packages/flutter_tools/bin/xcode_backend.sh: No such file or directory
I've already tried running flutter doctor and there were no errors.
I also tried re-rooting my xcode 'FLUTTER_ROOT' and 'FLUTTER_APPLICATION_PATH' in build settings, which did not work.
after a lot of messing around, I set these two settings and the build ran on to my physical device.
Goto Xcode,
click on Runner
select Project (top one)
go to Info tab
change configurations for debug
top Runner (green icon) to Generated
Bottom Runner (red circles) Pods-Runner-debug
Basically what happens is that one of the project's 'Build Phases' is running a script:
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
Now in order to find xcode_backend.sh the FLUTTER_ROOT variable needs to be defined. It is defined in a file called Flutter/Generated.xcconfig, which is generated when you run flutter pub get or flutter build.
The build configuration files Debug.xcconfig and Release.xcconfig (in the same Flutter folder) include Generated.xcconfig.
Now the only thing left is to ensure that for each of the project configurations these build configuration files are properly set (in XCode under Project > Info > Configuration).
use this settings:
Open Xcode - Click on Runner(Top one)
Select the Runner from "PROJECT" Not from "TARGETS"
Select configuration
And update all the modes as this photo
Open Xcode
Click on Runner(Top one)
Select the Runner from "PROJECT" Not from "TARGETS"
Select configuration
And update all the modes for ex: In debug select "debug" configuration set
By Setting FLUTTER_ROOT as the Flutter sdk path solved this issue for me.
Setting runner to Generated in project->Info Configurations seemed to fix it. I can build in xcode now.
The simple solution was to call
flutter clean
flutter run
and then run the app from Xcode.
If changing the configuration as suggested above doesn't fix things
In your Build Phase scripts / Xcode Project change
$FLUTTER_ROOT/packages/flutter_tools/...
to
${FLUTTER_ROOT}/packages/flutter_tools/...
Did the trick for me after the upgrade to the new version of flutter broke the Build.
i have this intermittently while setting up flavors havent got an answer on fixing it but the best explanation of the trail is here https://github.com/flutter/flutter/issues/49495
What helped me was going under PROJECT -> Info -> Configurations
setting the following:
Debug:
Runner - None
fRunner - Debug
Release:
Runner - None
fRunner - Release
Profile:
Runner - None
fRunner - Generated
What worked for me was:
Removing my project ios folder.
(Save it elsewhere, as you will probably want to keep your Info.plist file and Podfile.)
Run flutter create . to build a new ios folder.
Replace new Info.plist and Podfile with originals.
(If you have firebase in your app as I did you likely will have to go into xcode and right-click on runner, add files to runner, and add your GoogleService-Info.plist)
flutter clean , flutter run
I tried all solutions but no one worked :( , I think there is a something missing in the flutter folder so the fast simple solution is ;)
delete flutter folder
Download the stable branch straight from GitHub instead of using an archive (url: https://docs.flutter.dev/get-started/install/macos)
git clone https://github.com/flutter/flutter.git -b stable
Verify that the flutter/bin directory is in your PATH by running
echo $PATH
flutter upgrade
flutter config enable-ios
flutter config enable-android
flutter doctor --android-licenses
flutter doctor -v
cd path/your_project_name
flutter run ios -t lib/main.dart

Can't find React native project on iOS Simulator or Xcode project

I have deleted my project on Xcode may it be .xcworkspace or .xcodeproj.
Because of that, I had to delete IOS and android folders while downgrading, updating and re-upgrading my react version to re-install IOS and android folders.
Thanks to that the emulator is working but unfortunately the project isn't present in the emulator and is still absent with Xcode. One thing to point out is that the simulator only appears when ran in the integrated terminal and nor in general terminal after cd-ing in the project folder.
Can anyone please help re-integrating the project in the emulator and on Xcode, please.
Here is the error when the emulator is running in a general terminal:
Here is the error when the emulator is running in a general terminal:
error Command failed: xcrun instruments -s
xcrun: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk' (errno=No such file or directory)
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
Here is the error for building the project within emulator when ran from VS code integrated terminal:
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening project.xcodeproj
The process you need to follow is so similar to renaming a react native app. Basically you just need to run react-native upgrade in your root project directory. For further info you can check another question here. The instructions below explains how to create another react native project based on a copied one with a new name.
First copy the directory which your to-be-name-changed application exists. And go to your newly cloned directory.
Change the name at index.ios/android.js file which is given as a parameter to AppRegistry.
Change the name and version accordingly on package.json
Delete /ios and /android folders which are remaining from your older app.
Run $react-native upgrade to generate /ios and /android folders again.
Run $react-native link for any native dependency.
Finally run $react-native run-ios or anything you want.
Courtesy of
https://stackoverflow.com/questions/42506068/how-can-i-regenerate-ios-folder-in-react-native-project

Resources