"Error: Cannot read property ‘replace’ of undefined" for ios-sim

@shazron added an even better (inofficial) “solution” to use, that also works if you readd the ios platform:

In the meantime, I cherry-picked the ios-sim fix only and applied it to cordova-ios@4.4.0
To use:
cordova platform add https://github.com/apache/cordova-ios.git#4.4.0-ios-sim

This is not an official release of Apache Cordova.

TypeError: Cannot read property 'replace' of undefined (lib.js:282) · Issue #210 · ios-control/ios-sim · GitHub

3 Likes

Same Issue

global packages:

@ionic/cli-plugin-proxy : 1.3.0
@ionic/cli-utils        : 1.3.0-alpha.ba34a861
Cordova CLI             : 7.0.1 
Ionic CLI               : 3.3.0-alpha.ba34a861

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0-alpha.ba34a861
@ionic/cli-plugin-ionic-angular : 1.3.0-alpha.ba34a861
Cordova Platforms               : android 6.2.2 ios 4.4.0
Ionic Framework                 : ionic-angular 3.2.1

System:

Node       : v7.9.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 5.1.0 
npm        : 5.0.0

The solution for me was run ionic cordova build ios and after open Xcode to run in a simulator o in a device. is more slow but work for me, I hope Cordova release the solution in the next days.

1 Like

I did the steps from Sujan12 and it works, thank you.

1 Like

Why don’t you do this: “Error: Cannot read property ‘replace’ of undefined” for ios-sim

I followed the comment here and it worked great: https://github.com/phonegap/ios-sim/issues/210#issuecomment-307590994

cd platforms/ios/node_modules
npm i ios-sim@latest
2 Likes

hi, update all angular dependency as well as ionic cli

Hi I had the same issue. This fixed it form me:

4 Likes

This works for me too

Thank you! This took care of it for me as well.

Is anyone getting this problem when doing run android? Im getting this exact same error for android but not ios? Doing run ios works fine. All my sdk and jdks are properly configured in bash …

Yes, first result when you search for the error message in the forum:

1 Like

I am having the same problem when trying to emulate Android, I decided as follows:
I opened the android emulator by AndroidStudio
Then I ran the emulate android cordova command

And pammm worked

Worked for me :slight_smile: thx

I put the package.json there and did npm install ios-sim

now I get the following

[12:30:09]  Failed to read the projects ionic.config.json file: ENOENT: no such file or directory, open 
            '/Applications/MAMP/htdocs/ionic/newBuild/platforms/ios/cordova/ionic.config.json' 
[WARN] Error occurred during command execution from a CLI plugin
       (@ionic/cli-plugin-cordova). Your plugins may be out of date.
Error: /Applications/MAMP/htdocs/ionic/newBuild/platforms/ios/cordova/src/app/main.ts was not found. The "main.dev.ts" and "main.prod.ts" files have been deprecated. Please create a new file "main.ts" containing the content of "main.dev.ts", and then delete the deprecated files.
                            For more information, please see the default Ionic project main.ts file here:
                            https://github.com/driftyco/ionic2-app-base/tree/master/src/app/main.ts

global packages:

    @ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.0 
    Ionic CLI        : 3.5.0

local packages:

    @ionic/app-scripts              : 1.3.0
    @ionic/cli-plugin-cordova       : 1.4.1
    @ionic/cli-plugin-ionic-angular : 1.3.2
    Cordova Platforms               : android 6.2.3 browser 4.1.0 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.0.1

System:

    Node       : v8.0.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim    : 6.0.0 
    npm        : 5.0.0 


This is the only sustainable solution. Thanks.

Ty man, uninstalling glball ios-sim solved my problem

I think folder structure has changed to platforms/ios/cordova/node_modules.

But npm install ios-sim under folder platforms/ios/cordova/ worked for me.

Thanks @Sujan12 This fixed it for me. Bit of a shame that after 3 months this is still an issue.
I’d just started on ionic2 with a fresh install of everything and a simple ionic cordova emulate ios doesn’t work without this fix!

1 Like

That is actually an issue with Cordova in general, they are sometimes not that fast in releasing updates as not really that many people are working on it. As far as I understand the problem, it also depends on your local configuration so not all people get the error.