skip to Main Content

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.

2

Answers


  1. 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:

    1. Open Product menu (status bar)
    2. Scheme -> Edit Scheme
    3. Under build section, add a post-action
    4. In provide build settings from: choose target of your app
    5. 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.

    enter image description here

    Login or Signup to reply.
  2. 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;
     }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search