1

I have a project in React Native that has two different build schemes and uses cocoapods. To compile it I run:

react-native run-ios --scheme="RNProject-(SCHEME_NAME)"

The resulting apps are for example:

./build/Build/Products/Debug/iphonesimulator/RNProject-customer1.app
./build/Build/Products/Debug/iphonesimulator/RNProject-customer2.app
  • Using the command it builds for one of the build schemes, but not for the other
  • Xcode always builds the project for both build schemes
  • Furthermore, build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app/Info.plist exists in that path and the file contains valid CFBundleIdentifier (it matches General > Identity > Bundle Identifier for each of the two build schemes)
  • Project settings seem to be correct for both schemes (after checking ios/RNProject.xcodeproj/project.pbxproj)
  • Schema-specific settings are located in ios/Pods/Target Support Files/Pods-RNProject-customer1 and ios/Pods/Target Support Files/Pods-RNProject-customer2

I tried different ways to solve it:

  • Running sudo react-native
  • Restarting RN packager
  • Manually editing Info.plist
  • Changing build locations

Console:

** BUILD SUCCEEDED **

Installing build/Build/Products/Debug-iphonesimulator/RNProject.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
child_process.js:509
    throw err;
    ^

Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/RNProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

    at checkExecSyncError (child_process.js:486:13)
    at Object.execFileSync (child_process.js:506:13)
    at ChildProcess.xcodeBuildProcess.on.code (node_modules/react-native/local-cli/runIOS/runIOS.js:109:36)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Peter G.
  • 7,816
  • 20
  • 80
  • 154

2 Answers2

1

The problem was with how React Native names labels the executable files.

My Xcode project created two executable files with different names based on Xcode project settings.

React Native on the other hand forms the executable filename from .xcworkspace filename in this script (./node_modules/react-native/local-cli/runIOS/runIOS.js:57):

const inferredSchemeName = path.basename(xcodeProject.name, path.extname(xcodeProject.name));

The two approaches are different and lead to two different executable file names (e.g. Xcode build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app vs React Native build/Build/Products/Debug-iphonesimulator/RNProject.app).

I had set custom value for inferredSchemeNameto match the filename created by Xcode.

Peter G.
  • 7,816
  • 20
  • 80
  • 154
0

My solution is similar:

  1. open ./node_modules/react-native/local-cli/runIOS.js file
  2. change the build path from:

    const getBuildPath = function(configuration = 'Debug', appName, isDevice) {  
      return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
    };
    

to

    const getBuildPath = function(configuration = 'Debug', appName, isDevice) {  
      return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
    };
  • remove "Build" in the path.

I'm using Xcode-beta 8.2

Micheal Vu
  • 1,478
  • 1
  • 11
  • 15