{"id":134,"hash":"fff4245cfb2931f5e0c5258e9f60d28ff4316d0084a3044f5f4dc7c0b828a0c3","pattern":"Error: Cannot read property &#39;replace&#39; of undefined when building iOS Cordova","full_message":"I created a cordova project using cordova create project hello com.hello Hello.\n\nAnd added iOS platform using cordova platform add iOS.\nAnd tried to do cordova run ios after cordova build ios.\n\nBut it shows me this error(I used --d/ --verbose to get the details).\n\n  /usr/bin/codesign --force --sign - --timestamp=none\n  /Volumes/Untitled/Plot/PlotReel/platforms/ios/build/emulator/PlotReel.app\n  /Volumes/Untitled/Plot/PlotReel/platforms/ios/build/emulator/PlotReel.app:\n  replacing existing signature\n\n  \n  ** BUILD SUCCEEDED **\n\n  \n  No scripts found for hook \"before_deploy\". Error: TypeError: Cannot\n  read property 'replace' of undefined \n\nat remove (/Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/ios-sim/src/lib.js:282:70)\nat Array.forEach (native)\nat Object.getdevicetypes (/Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/ios-sim/src/lib.js:292:22)\nat Object.listEmulatorImages [as run] (/Volumes/Untitled/Plot/test/platforms/ios/cordova/lib/list-emulator-images:34:29)\nat deployToSim (/Volumes/Untitled/Plot/test/platforms/ios/cordova/lib/run.js:146:50)\nat /Volumes/Untitled/Plot/test/platforms/ios/cordova/lib/run.js:88:20\nat _fulfilled (/Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/q/q.js:834:54)\nat self.promiseDispatch.done (/Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/q/q.js:863:30)\nat Promise.promise.promiseDispatch (/Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/q/q.js:796:13)\nat /Volumes/Untitled/Plot/test/platforms/ios/cordova/node_modules/q/q.js:604:44\n\nI have tried uninstalling and installing cordova again, but the problem is still remaining.\n\nPlease help me.","ecosystem":"npm","package_name":"ios","package_version":null,"solution":"New solution\n\nThis issue is fixed in the latest version of the \"ios-sim\" package (so now this is probably the easier solution - compared to the old one which is listed below). In order to update the \"ios-sim\" package to the latest version run this in your terminal/cmd:\n\ncd platforms/ios/cordova/node_modules/\nsudo npm install -g ios-sim@latest\n\nOld solution\n\nThe problem is that the name_id_map[deviceName] returns undefined for \"iPad Pro (12.9-inch)\" and \"iPad Pro (10.5-inch)\".\n\nYou can check it with a console.log('name_id_map[ deviceName ]: ' + name_id_map[ deviceName ]);.\n\nI fixed this bug by adding an if statements which checks if the device is defined in \"platforms/ios/cordova/node_modules/ios-sim/src/lib.js:282\".\n\nI replaced this:\n\nlist = [];\n        var remove = function(runtime) {\n            // remove \"iOS\" prefix in runtime, remove prefix \"com.apple.CoreSimulator.SimDeviceType.\" in id\n            list.push(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));\n        };\n\nwith this:\n\nlist = [];\n        var remove = function(runtime) {\n            // remove \"iOS\" prefix in runtime, remove prefix \"com.apple.CoreSimulator.SimDeviceType.\" in id\n            if (name_id_map[deviceName] && runtime) {\n                list.push(util.format('%s, %s', name_id_map[deviceName].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));\n            }\n        };\n\nThe \"iPad Pro (10.5-inch)\" simulator won't be on the list (but it doesn't probably work anyway - didn't check).\n\nBug report on github: https://github.com/phonegap/ios-sim/issues/210","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/42350505/error-cannot-read-property-replace-of-undefined-when-building-ios-cordova","votes":44,"created_at":"2026-04-19T04:41:21.908777+00:00","updated_at":"2026-04-19T04:51:03.661113+00:00"}