react native ios build succeeds but path to app bundle is wrong - ios

When I run react-native run-ios build succeeds and created build folder under ios. But after build, when installation starts, get the below error. The project runs successfully when I run it through xcode. What I observed is that path beginning 'DerivedData' is wrong. Instead it should be 'build'. When I rename my 'build' folder to 'DerivedData' and re-run 'react-native run-ios' the whole process completes successfully but of course with the previous build.
How can I change the 'DerivedData' to 'build'?
This error occurred immediately after I upgraded from 0.59.9 to 0.60.0.
Error:
info Installing "DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app"
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/mobileappname.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
. Run CLI with --verbose flag for more details.
Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.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 (/Users/armaneker/WebstormProjects/mobileappname/node_modules/#react-native-community/cli-platform-ios/build/commands/runIOS/index.js:189:45)
at process._tickCallback (internal/process/next_tick.js:68:7)
React Native version:
System:
OS: macOS 10.15
Binaries:
Node: 10.15.3 - /usr/local/bin/node
npm: 6.13.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.0 => 0.60.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Steps To Reproduce
used rn-diff-purge to upgrade from 0.59.9 to 0.60.0
android worked correctly
react-native run-ios build succeeded but installation of
app failed

The solution is not obvious, react-native-cli is trying to guess what xcode build configuration is currently setup on your computer which is what is happening on the function getBuildPath()
function getBuildPath(configuration, appName, isDevice, scheme) {
let device;
if (isDevice) {
device = 'iphoneos';
} else if (appName.toLowerCase().includes('tvos')) {
device = 'appletvsimulator';
} else {
device = 'iphonesimulator';
}
let buildPath = `build/${scheme}/Build/Products/${configuration}-${device}/${appName}.app`; // Check wether app file exist, sometimes `-derivedDataPath` option of `xcodebuild` not works as expected.
if (!_fs().default.existsSync(_path().default.join(buildPath))) {
return `DerivedData/Build/Products/${configuration}-${device}/${appName}.app`;
}
return buildPath;
}
The trick is not to patch this file, but to first setup your xcode configuration correctly Xcode > Preferences > Locations (see picture)
and Xcode > Preferences > Locations > Advanced
Once this is done, you have to cleanup your build folder, otherwise, react-native-cli will still assume that xcode is not behaving as expected, which will keep on producing the same error.
cd ios && rm -rf build
you can now execute npx react-native run-ios and everything should be fine again.
It took me quite some time to figure this out, I think that react-native-cli should output more details on what is going on under the hood for people not to be blocked.

Problem solved. I had to edit a file inside #react-native-community.
If anyone else has the same problem solution is below.
File location:
-> file:
-> node_modules
-> #react-native-community
-> cli-platform-ios
-> build
-> commands
-> runIOS
-> index.js line 314
Change:DerivedData/Build/Products/${configuration}-${device}/${appName}.app
To:build/Build/Products/${configuration}-${device}/${appName}.app
Cheers.

Related

React native build failed in iOS - PhaseScriptExecution

I am facing issue in react-native project. It's working fine in android but build failed in iOS version. I have already tried all possible solution, but didn't get any solution.
The main problem is PhaseScriptExecution.
Xcode version - 12.4
Mac OS version - 11.3 (Big Sur)
npm version - 7.10.0
react-native version - 0.64.0
react version - 17.0.1
For mode detail, i am attaching the screenshot.
/Users/mmdev1/Library/Developer/Xcode/DerivedData/PRJ22-edpcityjusyktkdaxtnvzawndbxa/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-99DF087F7D2E061B36AA638AA7C0AD26.sh: line 4: 16519 Segmentation fault: 11 bash -l -c 'SRCS_DIR=/Users/mmdev1/Documents/RN/PRJ22/node_modules/react-native/scripts/../Libraries CODEGEN_MODULES_OUTPUT_DIR=/Users/mmdev1/Documents/RN/PRJ22/node_modules/react-native/scripts/../React/FBReactNativeSpec/FBReactNativeSpec CODEGEN_MODULES_LIBRARY_NAME=FBReactNativeSpec /Users/mmdev1/Documents/RN/PRJ22/node_modules/react-native/scripts/generate-specs.sh' 2>&1
I was getting the same failure, and I have not been able to pinpoint exactly why this works, but in my package.json I changed
"scripts": {
"ios": "react-native run-ios",
}
to
"scripts": {
"ios": "unset PREFIX && react-native run-ios",
}
As I was seeing some issues regarding the PREFIX env variable when using Node Versioning Manager (nvm).

Xamarin on VS for Mac - iOS Build Fails resource-rules has been deprecated in Mac OS X >= 10.10! or invalid resource specification rule(s)

I'm trying to build my Xamarin iOS app on Mac and failing on an error related to a deprecated command line parameter.
I tried targeting iphone 10, 11 and above but still failing on same error.
I Updated NuGets to latest versions, also tried creating an empty ResourceRules.plist file.
Xcode 12.1 (17222)
Build 12A7403
=== Xamarin.Mac ===
Version: 6.22.1.26 (Visual Studio Community)
=== Xamarin.iOS ===
Version: 14.4.1.3 (Visual Studio Community)
=== Operating System ===
Mac OS X 10.15.7
Build Command from log:
Tool /Applications/Xcode.app/Contents/Developer/usr/bin/actool execution started with arguments: --errors --warnings --notices --output-format xml1 --output-partial-info-plist /Users/user182752/Downloads/App1/App1.iOS/obj/iPhone/Release/actool/partial-info.plist --app-icon AppIcon --compress-pngs --target-device iphone --target-device ipad --minimum-deployment-target 11.0 --platform iphoneos --compile /Users/user182752/Downloads/App1/App1.iOS/obj/iPhone/Release/actool/bundle /Users/user182752/Downloads/App1/App1.iOS/obj/iPhone/Release/actool/cloned-assets/Assets.xcassets
...
...
Copied /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/obj/iPhone/Release/mtouch-cache/arm64/Plugin.Settings.aotdata.arm64 to /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app/Plugin.Settings.aotdata.arm64
/Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app built successfully.
Creating "bin/iPhone/Release/mtouch.stamp" because "AlwaysCreate" was specified.
Target _CopyITunesArtwork:
Copying file from "/Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/iTunesArtwork#2x" to "/Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/iTunesArtwork#2x".
Target _CopyITunesArtwork:
Copying file from "/Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/iTunesArtwork" to "/Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/iTunesArtwork".
Target _CopyAppExtensionsToBundle:
Skipping target "_CopyAppExtensionsToBundle" because it has no inputs.
Target _GenerateAppExtensionDebugSymbols:
Directory "bin/iPhone/Release/MyDemoApp.iOS.app/../.dSYM" doesn't exist. Skipping.
Target _CollectFrameworks:
No Frameworks directory found.
Target _GenerateFrameworkDebugSymbols:
Skipping target "_GenerateFrameworkDebugSymbols" because it has no inputs.
Target _GenerateDebugSymbols:
Directory "bin/iPhone/Release/MyDemoApp.iOS.app.dSYM" doesn't exist. Skipping.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil -num-threads 4 -z -o bin/iPhone/Release/MyDemoApp.iOS.app.dSYM bin/iPhone/Release/MyDemoApp.iOS.app/MyDemoApp.iOS
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -i -s obj/iPhone/Release/mtouch-symbols.list bin/iPhone/Release/MyDemoApp.iOS.app/MyDemoApp.iOS
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: removing global symbols from a final linked no longer supported. Use -exported_symbols_list at link time when building: /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app/MyDemoApp.iOS
Touching "bin/iPhone/Release/MyDemoApp.iOS.app.dSYM/Contents/Info.plist".
/usr/bin/mdimport bin/iPhone/Release/MyDemoApp.iOS.app/../
Target _CodesignAppBundle:
Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign 5FC337A423A139F99B2D118EC7FA72D8D0D94ABE --resource-rules /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app/ResourceRules.plist --entitlements /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/obj/iPhone/Release/Entitlements.xcent /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app
bin/iPhone/Release/MyDemoApp.iOS.app : error : Warning: --resource-rules has been deprecated in Mac OS X >= 10.10!
bin/iPhone/Release/MyDemoApp.iOS.app : error : /Users/user182752/Downloads/MyDemoApp/MyDemoApp.iOS/bin/iPhone/Release/MyDemoApp.iOS.app: invalid resource specification rule(s)
Done building target "_CodesignAppBundle" in project "MyDemoApp.iOS.csproj" -- FAILED.
I saw some references to this error mainly in old posts referring to code signing but couldn't find a recent solution referring to Xamarin.
Any help would be appreciated.
Cheers,
Yuval

":CFBundleIdentifier", Does Not Exist: ReactNative 0.58 on Mac / iOS

I am following the ReactNative tutorial for 0.58. I do everything it says to do and I am crashing after running react-native run-ios. I have seen this extremely similar SO question from 2016.
I attempted react-native upgrade and it recommended doing react-native-git-upgrade.This did nothing. Same problem.
The bit on running ./configure in the question above after cd-ing into glog did nothing. There was no configure script there. In the path NewStupidProject/node_modules/react-native/scripts there is a script called ios-configure-glog.sh. I run bash ios-configure-glog.sh and it says ios-configure-glog.sh: line 31: ./configure: No such file or directory.
I have also attempted setting Xcode to use the legacy build system. This did not fix the issue. I am restarting my laptop now to see if that makes any of these changes take effect. No luck. At the top it says:
Found Xcode project NewStupidProject.xcodeproj Building using
"xcodebuild -project NewStupidProject.xcodeproj -configuration Debug
-scheme NewStupidProject -destination id=854019D1-8EE7-4D13-87E1-385E6CAC21BE -derivedDataPath build" User
defaults from command line:
IDEDerivedDataPathOverride = /Users/me/NewStupidProject/ios/build
Prepare build
note: Using legacy build system
=== BUILD TARGET double-conversion OF PROJECT React WITH CONFIGURATION Debug ===
When I go into the home directory and run react-native --version the output is:
[NewStupidProject](master)$ react-native --version
react-native-cli: 2.0.1
react-native: 0.58.4
[NewStupidProject](master)$
My output after crashing is:
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/me/native_react_apps/NewStupidProject/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)
Installing
build/Build/Products/Debug-iphonesimulator/NewStupidProject.app An
error was encountered processing the command
(domain=NSPOSIXErrorDomain, code=22): Failed to install the requested
application The bundle identifier of the application could not be
determined. Ensure that the application's Info.plist contains a value
for CFBundleIdentifier. Print: Entry, ":CFBundleIdentifier", Does Not
Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier
build/Build/Products/Debug-iphonesimulator/NewStupidProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Error: Command failed: /usr/libexec/PlistBuddy -c
Print:CFBundleIdentifier
build/Build/Products/Debug-iphonesimulator/NewStupidProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at Promise.then (/Users/me/native_react_apps/NewStupidProject/node_modules/react-native/local-cli/runIOS/runIOS.js:208:5)
How is it possible for the setup process to be this fraught with errors and this difficult?
WHY is this error message not in the Troubleshooting ReactNative setup?
HOW do I fix this? Is it possible to avoid this altogether in the future?
Other versioning info:
XCode: 10.1
Command Line Tools: 10.1
yarn: 0.27.5
watchman: 4.9.0
homebrew: 2.0.1
npm: 6.8.0
node: v11.9.0
macOS: 10.13.6
UPDATE:
I am trying to implement the solution in this issue in GitHub and I'm getting:
dyld: Library not loaded:
/usr/local/opt/readline/lib/libreadline.7.dylib Referenced from:
/usr/local/bin/awk Reason: image not found
./ios-install-third-party.sh: line 20: 24497 Broken pipe: 13
shasum -p "$cachedir/$file"
24498 Abort trap: 6 | awk -v hash="$hash" '{exit $1 != hash}' Incorrect hash: 61067502c5f9769d111ea1ee3f74e6ddf0a5f9cc
?/Users/me/.rncache/glog-0.3.5.tar.gz
UPDATE No. 2 I am trying to run the watchman watch-del-all command as recommended here to clear the cache for RN > 0.50 and the whole thing is hanging.
I tried modify the build system and it worked for me.
Detail:
Open your project workspace file in Xcode, and
File -> Workspace Settings -> Build system -> Legacy Build system

react-native run-ios can not find any simulator

I have been facing an issue where 'react-native run-ios' can not start, regardless of the simulator I add to the --simulator argument.
XCode has the correct location for the 'command line tools'
I am always getting the error:
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)
react-native info
> React Native Environment Info:
> System:
> OS: macOS 10.14.2
> CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU # 2.90GHz
> Memory: 6.76 GB / 32.00 GB
> Shell: 3.2.57 - /bin/bash
> Binaries:
> Node: 10.15.0 - /usr/local/bin/node
> Yarn: 1.13.0 - /usr/local/bin/yarn
> npm: 6.4.1 - /usr/local/bin/npm
> SDKs:
> iOS SDK:
> Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
> IDEs:
> Android Studio: 3.1 AI-173.4819257
> Xcode: 10.1/10B61 - /usr/bin/xcodebuild
> npmPackages:
> react: 16.6.3 => 16.6.3
> react-native: 0.57.8 => 0.57.8
> npmGlobalPackages:
> create-react-native-app: 1.0.0
> react-native-cli: 2.0.1
> react-native-git-upgrade: 0.2.7
Update
It is fixed in v1.9.8.
Update cli is the easy solution
npm install -g react-native-cli#latest
This issue is fixed but not released yet.
https://github.com/react-native-community/react-native-cli/pull/274
So it can be solved temporarily to fix the file below.
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Change this line
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
to
if (!version.includes('iOS') && !version.includes('tvOS')) {
Do not forget apply this again when you reinstall packages.
I've found a temporary fix:
In the following file:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
...change line 42 to:
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('tvOS')) {
I tried like below
Open Xcode. Then Preferences -> Select Components in Tabs.
Then install any one(or more) of the available simulators on the list. Preferably the recent one at the top.
It solves the problem.
Try this script from Terminal
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Now run
react-native run-ios
Just do
npm install
Then it will show warnings, then fix them by using following command
npm audit fix
Here is additional temporary fix too. I am using Catalina.
I this file:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Change line 42 to:
if (!version.includes('iOS') && !version.includes('tvOS')) {
Change line 52-53 from:
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
to:
simulator.isAvailable !== true
because the returned json list from command xcrun simctl list --json devices, the property isAvailable is boolean and didn't have property 'availability'.
Just modify the findMatchingSimulator.js in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js.
First boot a Simulator then run xcrun simctl list --json devices and search the one with "state" : "Booted",.
Then add at the top in the findMatchingSimulator function:
return {
udid: <uuid from booted device>, // 'BFA2D7D0-AD49-472F-8279-585DDBBF9151'
name: <Name of the booted simulator>, //"iPhone X"
booted: true,
version: "com.apple.CoreSimulator.SimRuntime.iOS-13-1",
}
I solved it by replacing line number 62 in YourProjectFolder/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
This line
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
With this one
if (
!simulator.isAvailable
) {
In some case there may be some different solutions for everyone just debug findMatchingSimulator.js file by putting console.log() so you'll know why it is not detecting simulator. In my case the xcrun simctl list devices --json command not providing simulator.availability and simulator.isAvailable is not string it's bool.
I printed the simulator list which command is returning through the following line
console.log(JSON.stringify(simulator.simulatorName));
console.log(simulator.isAvailable);
console.log('-------------------------------------------------------------');
The after running command react-native run-ios --simulator="iPhone SE" I got output in the terminal and fixed code according to console print. And my simulator was running.
try npm install --force if you don't want to break your app with npm audit fix

Flutter.io (dart) app fails to launch on iOS simulator

I have up-to-date OSX Sierra, up-to-date XCode with applicable plugins, and an iPhone 6 simulator open and ready.
I have followed all the directions at https://flutter.io/setup-macos/#ios-setup.
When I "flutter run" from Terminal, the app fails to install on the simulator with message:
Could not build the application for the simulator.
Error launching application on iPhone 6.
Here is what Terminal said...
Launching lib/main.dart on iPhone 6 in debug mode...
Running pod install... 8.5s
Running Xcode build... 24.1s
Failed to build iOS app
Error output from Xcode build:
↳
2017-11-22 13:13:38.122 xcodebuild[47659:25935636] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-13510/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/Runtime/PBXTargetBuildContext.mm:757
Details: unexpected successful exit code from cancelled command <C0009:'CpResource app.flx':P12>
Object: <PBXTargetBuildContext: 0x7fccf1235200>
Method: -createCommandInvocationRecordFromInvocation:
Thread: <NSThread: 0x7fccf2847ea0>{number = 16, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
The following build commands failed:
CopyPlistFile /Users/deborah/Desktop/chq_emulator/build/ios/Debug-iphonesimulator/Runner.app/GoogleService-Info.plist Runner/GoogleService-Info.plist
(1 failure)
Xcode's output:
↳
Build settings from command line:
ARCHS = x86_64
BUILD_DIR = /Users/deborah/Desktop/chq_emulator/build/ios
ONLY_ACTIVE_ARCH = YES
SDKROOT = iphonesimulator11.1
=== CLEAN TARGET leveldb-library OF PROJECT Pods WITH CONFIGURATION Debug ===
... list of subsidiary infomation ...
Could not build the application for the simulator.
Error launching application on iPhone 6.
Anyone else out there with advice for how to get Flutter going on the simulator?
Try running your Xcode first and make sure that it's up-to-date. Open the {flutter_project}/ios build on Xcode then try to run the iOS project on the Simulator from there.
If you're still having issues, you can run this command on your Terminal. This should set the path for the active developer directory.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Resources