expo-cli icon indicating copy to clipboard operation
expo-cli copied to clipboard

uri-scheme: Cannot read properties of undefined (reading 'includes')

Open wojtekmaj opened this issue 2 years ago • 2 comments

Summary

I tried to run a command:

yarn dlx uri-scheme add myapp

or

npx uri-scheme add myapp

Environment

expo-env-info 1.0.2 environment info: System: OS: macOS 12.3.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.14.2 - /private/var/folders/7r/rpcp4wz97jngh5x0nk88p5br0000gp/T/xfs-5b2a7593/node Yarn: 3.1.0 - /private/var/folders/7r/rpcp4wz97jngh5x0nk88p5br0000gp/T/xfs-5b2a7593/yarn npm: 8.5.0 - /usr/local/bin/npm Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 IDEs: Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild npmPackages: react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 Expo Workflow: bare

Please specify your device/emulator/simulator platform, model and version

iPhone 13 iOS 15.4

Error output

Aborting run
An unexpected error was encountered. Please report it as a bug:
TypeError: Cannot read properties of undefined (reading 'includes')
    at /node_modules/uri-scheme/build/index.js:1:410051
    at Array.some (<anonymous>)
    at Object.appendScheme (/node_modules/uri-scheme/build/index.js:1:410018)
    at Object.addAsync (/node_modules/uri-scheme/build/index.js:1:448244)
    at Object.addAsync (/node_modules/uri-scheme/build/index.js:1:452504)
    at async Command.<anonymous> (/node_modules/uri-scheme/build/index.js:1:443948)

Reproducible demo or steps to reproduce from a blank project

.

wojtekmaj avatar Apr 15 '22 23:04 wojtekmaj

can you share the project you are running this in so we can reproduce?

here is the result of running this on an empty new project with an ios directory for me:

Need to install the following packages:
  uri-scheme
Ok to proceed? (y) y
› iOS: Added URI protocol "wojtekmaj" to project

adding an android directory (with expo prebuild -p android) and running again:

╰─$ npx uri-scheme add wojtekmaj
› iOS: URI scheme "wojtekmaj" already exists in Info.plist at: [redacted]/Info.plist
› Android: Added URI protocol "wojtekmaj" to project

brentvatne avatar Apr 15 '22 23:04 brentvatne

I think this just needs a null check. If you have <key>CFBundleURLTypes</key> array item but without <key>CFBundleURLSchemes</key> in your Info.plist (that's how it ended up looking when I changed some settings in Xcode), it will crash.

wojtekmaj avatar Apr 16 '22 05:04 wojtekmaj