cli icon indicating copy to clipboard operation
cli copied to clipboard

Error: str.replace is not a function

Open JosueOlivero opened this issue 3 years ago • 16 comments

Environment

System: OS: macOS 13.2.1 CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz Memory: 116.00 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 14.17.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 6.14.13 - /usr/local/bin/npm Watchman: 2023.03.13.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.12.0 - /Users/jolivero/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9619390 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 18.0.1.1 - /usr/bin/javac npmPackages: @react-native-community/cli: ^10.2.1 => 10.2.1 react: ^18.2.0 => 18.2.0 react-native: ^0.71.4 => 0.71.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Description

Hello there, I'm trying a new app, and I got this error. Any idea?

image

Thanks!

JosueOlivero avatar Mar 21 '23 19:03 JosueOlivero

@JosueOlivero

try this, it helped me - https://stackoverflow.com/a/68579858/2005679

berikiushi avatar Mar 21 '23 23:03 berikiushi

@JosueOlivero

try this, it helped me - https://stackoverflow.com/a/68579858/2005679

I already have Command Line Tools selected. Just in case I re-select it again, but it didn't work.

JosueOlivero avatar Mar 22 '23 02:03 JosueOlivero

Same issue here

emilstepanian avatar Mar 22 '23 20:03 emilstepanian

same here, but I am using Windows image

pen1064 avatar Mar 25 '23 01:03 pen1064

hi, did you find solution to this problem? i have tried doing the command line tools thing but it's not working for me and this error is occurring after creating new project. Are you using js or ts as before i had created a project in TS and it was working fine. The issue is with iOS device only as it works fine in android devices

DEVARSHI-GOHEL avatar Mar 27 '23 05:03 DEVARSHI-GOHEL

looks like it throws an error because it cannot run xcodebuild command on your machines. Can you make sure you have XCode installed and running e.g. xcodebuild -list -json command in ios folder returns an output correctly?

In my opinion failing to read the project configuration should not prevent user from running an app. I'll prepare a fix that will only warn user about it and skip the check if configuration cannot be read

TMisiukiewicz avatar Mar 27 '23 07:03 TMisiukiewicz

Hi, running the app with sudo allows it to properly read the xcodeproj file. It seems that it was a permission issue. Running the app with sudo solved it. Thanks!

JosueOlivero avatar Mar 28 '23 15:03 JosueOlivero

Try this, it helped me - https://stackoverflow.com/a/68579858/2005679

Thanks @JosueOlivero your reference saved me as well, I was mad for a couple of days then I found this solution that fixed the issue like magic 😳

Stay blessed!!

mohammad-fahad avatar Apr 14 '23 21:04 mohammad-fahad

sudo xcode-select --switch /Applications/Xcode.app run this and you will be good to go

jaykksingh avatar Jun 09 '23 05:06 jaykksingh

Switching Xcode using xcode-select did not work for me.

Instead, this started happening for me after the xcode command line tools were updated through a software update. When I launched Xcode, it prompted me to accept an updated license agreement for the command line tools. After accepting the agreement the error went away. Hope this is useful to others running into this error.

Stormheg avatar Jun 27 '23 13:06 Stormheg

If anyone else is still having problems, for some reason I had two projects in my ios folder and I had to remove the wrong one. The output of xcodebuild -list -json in the ios folder was helpful.

Spencer1O1 avatar Jul 05 '23 19:07 Spencer1O1

In my case issue is caused by accidentally writing a few characters in the project.pbxproj file within my ios folder of the project. This results in the str.replace is not a function error.

To resolve this problem, you can follow these steps:

Open the project.pbxproj file located in the ios folder. Locate the lines or characters that you mistakenly added or modified. Correct the characters you added or revert the unnecessary changes. Save the file and close it. This fix should resolve the str.replace is not a function error. When you restart and run your project, you should no longer encounter the issue.

txMaestro avatar Jul 17 '23 02:07 txMaestro

In my case, i just had to open XCode to accept new licence agreements

image

AlexCods avatar Nov 21 '23 15:11 AlexCods

Try this, it helped me - https://stackoverflow.com/a/68579858/2005679

Thanks @JosueOlivero your reference saved me as well, I was mad for a couple of days then I found this solution that fixed the issue like magic 😳

Stay blessed!!

This fixed mine

abanoubamin avatar Jan 13 '24 08:01 abanoubamin

Make sure you have run pod install first

Nagibaba avatar Feb 10 '24 15:02 Nagibaba

I ran this:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

zacchaeuschok avatar Sep 13 '24 08:09 zacchaeuschok