My apologies if the title of the question isn't clear enough, here is a better explanation of the problem I am facing, so I am trying to write a shell script to run on app center to deploy my application for tests/production. the script is as follows
#!/usr/bin/env bash
# fail if any command fails
set -e
# debug log
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=$(pwd)/flutter/bin:$PATH
flutter channel stable
flutter upgrade
flutter doctor
flutter clean
rm -f ios/Podfile.lock pubspec.lock
rm -rf ios/Pods ios/Runner.xcworkspace
flutter build ios --release --no-codesign
nothing much going around here, first of all, I install flutter then set the path to it,
make sure flutter is installed correctly, then clean up (just an extra thing I am doing) then remove the old podfile, public.lock pods and the runner.xcworkspace the reason is to make sure that every time I want to generate a brand new file for the build, anyways, running the script will fail and result in the following error message
lib/pages/reset_password_page.dart:24:62: Error: 'InputWidgetState' isn't a type.
final GlobalKey<InputWidgetState> _phoneNumKey = GlobalKey<InputWidgetState>();
^^^^^^^^^^^^^^^^
Failed to package /Users/muhammad/Desktop/test/OrbitFoodCustomerApp.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
/Users/muhammad/Desktop/test/OrbitFoodCustomerApp/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is
9.0 to 15.2.99. (in target 'libPhoneNumber-iOS' from project 'Pods')
the error message is longer than that but it is kind of repertative and that's the most important part. the really weird part for me is when I modify the script in the following way
#!/usr/bin/env bash
#Place this script in project/ios/
# fail if any command fails
set -e
# debug log
set -x
cd ..
# git clone -b beta https://github.com/flutter/flutter.git
# export PATH=$(pwd)/flutter/bin:$PATH
flutter channel stable
flutter upgrade
flutter doctor
flutter clean
rm -f ios/Podfile.lock pubspec.lock
rm -rf ios/Pods ios/Runner.xcworkspace
flutter build ios --release --no-codesign
note that the export path is commented out so this time the script will use the flutter installed on my machine, the script succeeds in building the app which I find very weird, I checked the flutter version of both flutters (the newly downloaded and the one on my machine) and they are exactly the same. same branch same version the same everything. but for some reason using my own flutter succeeds while using the downloaded flutter fails.
please note that both the scripts are being run on my own machine, the only difference is that I am specifying the flutter path in one script and I use my previously installed flutter in the other one, and I made sure to specify that targeted deployment ios version to be 12 anywhere possible.
any idea what's going on?! I am very confused. thank you in advance.
Related
I'm using M1 chip and xCode 13.4.1. I get the following React Native error while executing the app in the simulator:
The following build commands failed:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/Ibra/Library/Developer/Xcode/DerivedData/Mario-girhlsdkqiibhqhflwlyrybpo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-46EB2E110.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)
The problem persists even when I start a brand-new React Native project and try to execute it on iOS. What led to the error and how can it be fixed?
Thank you
Described answers didn't help me, but I started reading error description: and I found out that in error description on the line 2: my folder's name was written partially. Folder name consisted 2 words divided by 1 space example: "My folder" in the error was written just "My". I just changed folder's name to "MyFolder" and it helped me to fix the problem
it has multiple solutions:
to solve this run this command in terminal in ios folder , pod deintergrate and install pod with the commad pod install
Restart your Mac , it is some time due to cache, delete derived data and logs from XCode -> Prefrences and location
I faced same issue and I figured out following solutions:
What worked for me was npx react-native-clean-project and choosing y for all options, this will clean your React Native project by purging caches and modules, and reinstalling them again.
And here're some solutions that worked for others:
If you're using nvm, nvm unalias default could solve the issue.
This error could be due to Xcode can't find your node path, so try sudo ln -s $(which node) /usr/local/bin/node
Delete node_modules then cd ios && pod deintegrate then reinstall node modules and npx react-native start --reset-cache
I solve this issue with below procedure:
Keychain Access > Cetificates > Login
Find any Apple Certificate that has the blue + symbol
Change it to "Use System Defaults" and close it.
You'll see a pop up. Type in your password to update settings.
Close Keychain. Open your project, clean build files and run.
Note: Mac with M1, Xcode 14.1
Easy bounty here for grabs. Does not necessarily require any react-native experience. Problem seems to be in open source code, which is available out there:
Updated xcode, and now when I try to run my react-native app by issuing following command: react-native run-ios I get an error:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
error Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
debug Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnSimulator (project-root-dir/node_modules/#react-native-community/cli/build/commands/runIOS/runIOS.js:181:45)
Before those errors, the command prints out info about successful build, and that it is about to install the build:
info ** BUILD SUCCEEDED **
info Installing DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app
So it seems the build is ok, but when it tries to install the app it fails?
Think I've tried "everything" I found from other questions with this similar error message, but nothing has worked for me.
Some specs:
react-native: 0.59.10
react: 16.8.3
xcode-version: Version 12.2 (12B45b)
I know there are similar questions on stackoverflow. But since none of the solutions provided there worked for me, and I wish to get it fixed, I made this separate question.
I do not know where the Info.plist file is that it tries to find: DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plist
Inside my ios folder, there is a folder called DerivedData, but inside that there are no folder with a name Build. So I think it might be looking from a wrong location?
UPDATE:
I've been able to pinpoint where the cli launch goes wrong:
https://github.com/react-native-community/cli/blob/ba298d9c47af522f0377325bebc6c2075d41790a/packages/platform-ios/src/commands/runIOS/index.ts#L378
If I change that line let buildPath = build/${scheme}/Build/Products/${configuration}-${device}/${appName}.app
to -> build/${scheme}/Build/Products/${configuration}-${device}/MyAppRealName.app;
Then the dev launch works nicely, there's no problem. So it seems that getting the appName goes wrong. The appName is resolved here: https://github.com/react-native-community/cli/blob/ba298d9c47af522f0377325bebc6c2075d41790a/packages/platform-ios/src/commands/runIOS/index.ts#L387
const productNameMatch = /export FULL_PRODUCT_NAME="?(.+).app"?$/m.exec(buildOutput);
I could do a post install npm script that just sets the name of the app correct and call it a day. But that's pretty hacky way. I wonder if there's an alternative that works better? I see that the runIOS file has been updated from the version that I have quite much, but the function getProductName still remains the same. So Im not sure if updating just the cli would work, or if it would even be possible, because it might require a newer react-native version, which is not an option for me right now.
newer version of #react-native-community/cli is not working on older version react-native because in newer version they have change getProductName to getPlatformName. for more detail you can read summary of this PR
Solution
As a local workaround, patch the package by patch-package node_modules/#react-native-community/cli-platform-ios/build/commands/runIOS/index.js and edited getProductName (lines 362–365) to read:
function getProductName(buildOutput) {
const productNameMatch = /export FULL_PRODUCT_NAME\\?="?(.+).app"?$/m.exec(buildOutput);
return productNameMatch ? productNameMatch[1].replace(/(?:\\(.))/g, '$1') : null;
}
The result from react-native run-ios is:
DerivedData/Build/Products/Debug-iphonesimulator/MyAppName.app/Info.plist
The correct should be:
DerivedData/Build/Products/Debug-iphonesimulator/MyAppRealName.app/Info.plist
Then you could fix it by edit Xcode project as:
Open Product menu (status bar)
Scheme -> Edit Scheme
Under build section, add a post-action
In provide build settings from: choose target of your app
Use the script to copy wrongname.app to realname.app: cp ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app ${BUILT_PRODUCTS_DIR}/real_name.app
Or you can use symlinks instead of copying.
I'm somewhat new to react native and expo but I've been trying to deploy a test version to my phone but can't figure out how to get it to build.
For some extra context, I built most of it in Expo and then ejected it (yes I know this isn't the best choice but I liked the features Expo provided). I ejected it because I needed NFC support which isn't currently supported in Expo so I added that in manually in Xcode after I ejected.
When I open the Xcode workspace and try to deploy it to my phone I get the following error:
Error: Failed to connect to the packager server. If you did not start this build by running 'react-native run-android', you can start the packager manually by running 'react-native start' in the project directory. (Error: Request to packager server failed: 500)
at /Users/user/Downloads/honorProj-reactNatveFinal/honorProj/reactNative/ethelontisApp/node_modules/expo-updates/scripts/createManifest.js:40:11
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Command PhaseScriptExecution failed with a nonzero exit code
I know it says run react-native start in the project directory (although I'm not entirely what the at /Users/... is refering too) but what really threw me was that it mentioned react-native run-android which doesn't seem like it should be related at all.
Lastly I'm completely and utterly lost with what Command PhaseScriptExecution is.
Thanks for the help.
I was facing the exact same issue. So I just completed the set up the android development first.
But before doing anything, follow the below steps, it may solves the problem.
Step-1: Open terminal and navigate to your project directory example: cd Your project path.
Step-2: Type npx react-native start
Step-3: If you get any error like "error listen EADDRINUSE: address already in use :::8081"
Then follow step-4 to 6:
Step-4 : type sudo lsof -n -i4TCP:8081 // You will get PID from here
Step-5: type kill -9 PIDvalue
Step-6: Repeat the step 2 and 3 once again
If you will not get any error in step- 2 then type npx react-native run-android
and check if there is any error. If yes, then you have to set up the android development first to make it working - (As of now I found this way, but not sure if anyone can find any better way).
Else Open the code using xcode then clean the build and also clean the build folder then try to run.
Thanks, Hope it will help.
Hi I downloaded the last release of bazel 0.24.1 for windows and I did the same instructions But, when I run
./compile.sh
It shows the error as mentioned and I tried bazel build //src:bazel but it didn't work to it shows me
-bash: bazel: command not found
after searching I tried : bazel --output_user_root=c:\tmp build //src:bazel.exe
but the same error
-bash: bazel: command not found
Ps: I run it from msys64 any suggestions please thanks a lot for reacting
./compile.sh
🍃 Building Bazel from scratch ERROR: Must specify PROTOC if not
bootstrapping from the distribution artifact
-------------------------------------------------------------------------------- NOTE: This failure is likely occuring if you are trying to bootstrap
bazel from a developer checkout. Those checkouts do not include the
generated output of the protoc compiler (as we prefer not to version
generated files)
.
To build a developer version of bazel, do
bazel build //src:bazel
To bootstrap your first bazel binary, please download a dist archive from our release page at
https://github.com/bazelbuild/bazel/releases and run compile.sh on
the unpacked archive.
The full install instructions to install a release version of bazel
can be found at https://docs.bazel.build/install-compile-source.html
For a rationale, why the bootstrap process is organized in this way,
see https://bazel.build/designs/2016/10/11/distribution-artifact.html
I tried to change the bundle identifier in the Info.plist and the xcode itself. (in full empty project).
But for some reason I can't build it. Entry, ":CFBundleIdentifier", Does Not Exist. And what strange is that I can build it successfully in the xcode but not with the npm run ios. Any idea how to solve this?
Try the react-native-rename npm package.
npm install react-native-rename -g
On the root of your React Native project execute the following command
react-native-rename "ExampleApp" -b com.newname.newid
Check the docs > react-native-rename