Cli: Build fails to install when using the iOS 14 SDK

Created on 27 Jun 2020  ·  21Comments  ·  Source: react-native-community/cli

Environment

$ y react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.16
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Memory: 428.42 MB / 16.00 GB
    Shell: 5.8 - /usr/local/bin/zsh
  Binaries:
    Node: 14.4.0 - /private/var/folders/5w/5dc75xj91xx_mvq7prvkplx80000gn/T/xfs-f9519a63/node
    Yarn: 2.0.0-rc.33 - /private/var/folders/5w/5dc75xj91xx_mvq7prvkplx80000gn/T/xfs-f9519a63/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/lib/ruby/gems/2.7.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 20.0, macOS 10.16, tvOS 14.0, watchOS 7.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 12.0/12A6159 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 3.7.7 - /usr/local/opt/python/libexec/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: ^0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Description

When one uses the iOS 14 SDK to build the app for a simulator, e.g. yarn react-native run-ios, the build fails. As far as I can tell, the cli-platform-ios package fails to successfully capture the stdout from xcodebuild in this section: https://github.com/react-native-community/cli/blob/f76add94dcfb647dd55b59a5fad9a4d5363962fa/packages/platform-ios/src/commands/runIOS/index.ts#L312-L357. This causes getProductName https://github.com/react-native-community/cli/blob/f76add94dcfb647dd55b59a5fad9a4d5363962fa/packages/platform-ios/src/commands/runIOS/index.ts#L282-L287 to not get the correct app name, which causes the "wrong" .app to be installed, so the entire thing fails. I have the app name set to something other than the scheme name, so that's why this is an issue. To be sure, I've checked that the app builds successfully when using the release SDK and toolchain, so I know that the iOS 14 SDK is the cause of this.

Reproducible Demo

Any project whose App Name (in Xcode) is different than the scheme name.

bug report

Most helpful comment

Please check how to update the @react-native-community/cli to the latest version :)

All 21 comments

Also, is there a good way to be able to debug things like this without modifying the built JS in a project's node_modules? I'm sure there is using the example app, but I'm not familiar with monorepos.

Check out the contributing guide: https://github.com/react-native-community/cli/blob/master/CONTRIBUTING.md. Also, PRs to fix this welcome :)

Well, duh! Thanks for the guide. Unfortunately, I'm not very familiar with node's subprocesses, so I doubt I'd be able to do much good.

@SConaway I will try to help

Awesome thanks!

In my case, spaces in the path are removed which causes CFBundleIdentifier to not be found:

➜ /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/TeamRinse.app/Info.plist
File Doesn't Exist, Will Create: /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/TeamRinse.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

➜ /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/Team\ Rinse.app/Info.plist
com.rinse.Team-Rinse

In my case, spaces in the path are removed which causes CFBundleIdentifier to not be found:

➜ /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/TeamRinse.app/Info.plist
File Doesn't Exist, Will Create: /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/TeamRinse.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

➜ /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier /Users/brett/Library/Developer/Xcode/DerivedData/TeamRinse-ffewibhomghuqdfezikybtvxmzzd/Build/Products/Debug-iphonesimulator/Team\ Rinse.app/Info.plist
com.rinse.Team-Rinse

With this fix?

Let me try out the fix.

Yes, that fixes it!

What are your envs? on XCode

PRODUCT_BUNDLE_IDENTIFIER = paz.church;
PRODUCT_NAME = Paz.Church;

@oeduardoal

PRODUCT_BUNDLE_IDENTIFIER = com.rinse.Team-Rinse
PRODUCT_NAME = Team Rinse

@oeduardoal

PRODUCT_BUNDLE_IDENTIFIER = com.rinse.Team-Rinse
PRODUCT_NAME = Team Rinse

I'll try with this...

Hey @bjackson, I tried with these variables and it worked here. With the correction of this PR...

🐛 https://github.com/react-native-community/cli/pull/1236

Screen Shot 2020-08-08 at 15 34 09
Screen Shot 2020-08-08 at 15 33 59
Screen Shot 2020-08-08 at 15 31 12

Yeah, it worked for me when I used your PR.

For anyone else stumbling here in panic mode; I solved this by pinning the ios platform tool version based on the above mentioned PR (RN 0.62.2).

"resolutions": {
    "@react-native-community/cli-platform-ios": "4.13.0"
  },

Just be sure you clean all node modules, derived data, etc then rerun npm/yarn install.

Explicitly installing cli-platform-ios worked for me:

npm install @react-native-community/cli-platform-ios --only-dev

Please check how to update the @react-native-community/cli to the latest version :)

@thymikee That only works if you are on RN v0.62. I'm on 0.61.5 and it only updates to the latest v3 version and I presume that it's because on 0.61.5, react native it's constrained to the v3 version of the CLI.

Are there other solutions for those who are on v0.61 or lower?

@focux there are a few options:

  • you could port the PR #1236 that fixes it in v4 to v3 and send a PR to 3.x branch, then we publish a patch (or use patch-package locally)
  • pin the @react-native-community/cli-platform-ios to v4 (it likely works with v3, but haven't tested) with Yarn resolutions

@thymikee I took a stab at your first option to port the fix onto the 3.x branch in PR #1308. It seems to resolve the issue for my project locally.

Was this page helpful?
0 / 5 - 0 ratings