`react-native run-ios` returns Error: Could not find iPhone X simulator
`react-native run-ios` returns Error: Could not find iPhone X simulator
每当我 运行 react-native run-ios
,我得到
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (calendarPractice/node_modules/react-native/local-cli/cliEntry.js:117:22)
然而,当我 运行 在 Xcode 上时,它工作正常
{
"devicetypes" : [
{
"name" : "iPhone 4s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 4s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-4s"
},
{
"name" : "iPhone 5",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5"
},
{
"name" : "iPhone 5s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"
},
{
"name" : "iPhone 6",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6"
},
{
"name" : "iPhone 6 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus"
},
{
"name" : "iPhone 6s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s"
},
{
"name" : "iPhone 6s Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus"
},
{
"name" : "iPhone 7",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7"
},
{
"name" : "iPhone 7 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus"
},
{
"name" : "iPhone 8",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8"
},
{
"name" : "iPhone 8 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus"
},
{
"name" : "iPhone SE",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone SE.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
},
{
"name" : "iPhone X",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone X.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-X"
},
{
"name" : "iPhone Xs",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS"
},
{
"name" : "iPhone Xs Max",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs Max.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max"
},
{
"name" : "iPhone Xʀ",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xʀ.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XR"
},
{
"name" : "iPad 2",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad 2.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-2"
},
{
"name" : "iPad Retina",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Retina.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Retina"
},
{
"name" : "iPad Air",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air"
},
{
"name" : "iPad Air 2",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air 2.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air-2"
},
{
"name" : "iPad (5th generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (5th generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-"
},
{
"name" : "iPad Pro (9.7-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (9.7-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-"
},
{
"name" : "iPad Pro (12.9-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro"
},
{
"name" : "iPad Pro (12.9-inch) (2nd generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (2nd generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-"
},
{
"name" : "iPad Pro (10.5-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (10.5-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-"
},
{
"name" : "iPad (6th generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (6th generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-"
},
{
"name" : "iPad Pro (11-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (11-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-"
},
{
"name" : "iPad Pro (12.9-inch) (3rd generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (3rd generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-"
},
{
"name" : "Apple TV",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p"
},
{
"name" : "Apple TV 4K",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K"
},
{
"name" : "Apple TV 4K (at 1080p)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K (at 1080p).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p"
},
{
"name" : "Apple Watch - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm"
},
{
"name" : "Apple Watch - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm"
},
{
"name" : "Apple Watch Series 2 - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm"
},
{
"name" : "Apple Watch Series 2 - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm"
},
{
"name" : "Apple Watch Series 3 - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm"
},
{
"name" : "Apple Watch Series 3 - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm"
},
{
"name" : "Apple Watch Series 4 - 40mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 40mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm"
},
{
"name" : "Apple Watch Series 4 - 44mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 44mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm"
}
],
"runtimes" : [
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
"availabilityError" : "",
"buildversion" : "16B91",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-12-1",
"version" : "12.1",
"name" : "iOS 12.1"
},
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/tvOS.simruntime",
"availabilityError" : "",
"buildversion" : "16J602",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-12-1",
"version" : "12.1",
"name" : "tvOS 12.1"
},
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/watchOS.simruntime",
"availabilityError" : "",
"buildversion" : "16R591",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-5-1",
"version" : "5.1",
"name" : "watchOS 5.1"
}
],
"devices" : {
"com.apple.CoreSimulator.SimRuntime.watchOS-5-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 2 - 38mm",
"udid" : "01AFDEF7-63B6-465C-A02A-44EE4A07EABA",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 2 - 42mm",
"udid" : "BE62C985-DEE2-46EC-8962-A582D537EEE0",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 3 - 38mm",
"udid" : "078BF157-30FA-41D1-94FA-6B1686E03085",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 3 - 42mm",
"udid" : "E4CE652E-0185-4C59-B965-BED5FCEE7C76",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 40mm",
"udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 44mm",
"udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
"availabilityError" : ""
}
],
"com.apple.CoreSimulator.SimRuntime.tvOS-12-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV",
"udid" : "AFAA21B8-BD4A-45EA-B0FF-E9915FE9B926",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K",
"udid" : "EBB88F2E-CFFE-4981-A736-7A7C0B85643D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K (at 1080p)",
"udid" : "F0B73E8A-986E-447E-B37A-2F46096DEFF6",
"availabilityError" : ""
}
],
"com.apple.CoreSimulator.SimRuntime.iOS-12-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "F870B7FA-6DDA-4336-89AD-68A402844188",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "6627ADE5-F8C1-4AE5-BD6F-3AEDDC0B7B63",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6",
"udid" : "05574997-ACAD-40CA-A3D7-5624D53F00FA",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6 Plus",
"udid" : "93237078-CA6D-4F97-93F9-779809700018",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6s",
"udid" : "9B50FE18-4F49-4EA4-80F0-DF498A667D33",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6s Plus",
"udid" : "D4640B6D-97DC-4CA1-BE63-C5403159A3D4",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7",
"udid" : "6E9EEC00-3291-42B4-B04A-BA3487F9CD5F",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7 Plus",
"udid" : "6DA1C3CF-1D1F-4DEF-9B74-2C40D5FB5881",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8",
"udid" : "E19386B9-469A-450B-9CD2-B4FE8687DCF9",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8 Plus",
"udid" : "6D36DF76-8ED9-41A2-9E1A-0BA48B92C26E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone SE",
"udid" : "EE4818DF-F817-4441-8A1C-BE1B99303E10",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "85B78A8F-C32B-4493-BDD1-65ECA3F77C86",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "CA12C337-4F66-4C6C-ACE5-7F7EACCBC39A",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XS",
"udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XS Max",
"udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XR",
"udid" : "28D12ABE-3355-4862-960A-0FE5FFE41C7B",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air",
"udid" : "94485C88-BCEB-456A-95DC-5F8C3DA8D181",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air 2",
"udid" : "CF2C787D-A378-4AB9-B334-F7B24E94AF4D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (5th generation)",
"udid" : "DFE602A5-EC68-4585-8AB0-C045A9843D29",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (9.7-inch)",
"udid" : "5A3F3EAC-F788-49F1-A753-5D34A9990F0B",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch)",
"udid" : "EF6EBE34-0A85-4FF0-8A45-7BA418A0CC0C",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (2nd generation)",
"udid" : "FBA940F8-FD85-4D5E-A570-EB4F3A56E1F9",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (10.5-inch)",
"udid" : "8AE4AAED-ECE0-4984-9679-8D3022064692",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (6th generation)",
"udid" : "1121363D-EF49-4AC0-9E46-5C30318A24A2",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (11-inch)",
"udid" : "038FECC0-8711-46E3-B601-8F88F2F4AD7D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (3rd generation)",
"udid" : "12DC911F-2F45-4767-BC1A-6F1D0C8D9F3D",
"availabilityError" : ""
}
]
},
"pairs" : {
"C9B69F4A-6A9D-44F3-A6BC-56BFA2F8B83F" : {
"watch" : {
"name" : "Apple Watch Series 4 - 44mm",
"udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
"state" : "Shutdown"
},
"phone" : {
"name" : "iPhone XS Max",
"udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
"state" : "Shutdown"
},
"state" : "(active, disconnected)"
},
"5327B65F-29E7-42D0-9861-FF31428F3218" : {
"watch" : {
"name" : "Apple Watch Series 4 - 40mm",
"udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
"state" : "Shutdown"
},
"phone" : {
"name" : "iPhone XS",
"udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
"state" : "Shutdown"
},
"state" : "(active, disconnected)"
}
}
已编辑:
我复制了你输出的设备部分 JSON 并嵌入到我自己的 /node_modules/react-native/local-cli/runIOS/runIOS.js
function runOnSimulator(xcodeProject, args, scheme) {
return new Promise(resolve => {
try {
var simulators = {devices section of your json}; //Here
} catch (e) {
console.log("e", e);
throw new Error('Could not parse the simulator list output');
}
const selectedSimulator = findMatchingSimulator(simulators, args.simulator);
console.log("selected", selectedSimulator);
if (!selectedSimulator) {
throw new Error(`Could not find ${args.simulator} simulator`);
}
...
最后,它给出了和你一样的错误。所以我发现设备的解析版本不同。在您的设备中,版本是;
"com.apple.CoreSimulator.SimRuntime.tvOS-12-1" //for tvOS
"com.apple.CoreSimulator.SimRuntime.iOS-12-1" // for iOS
但是在 react-native 中检查这个版本值是这样的(/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
);
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
所以react-native无法识别
如果我们用这个更改此代码;
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
continue;
}
问题已解决。我在我的电脑上用你的 JSON 数据检查过,它有效。
要修复此错误,只需使用 npm
重新安装项目和节点模块
npm install
然后它将显示警告列表,并使用以下命令修复它们:
npm audit fix
这应该可以解决所有问题,并允许您 运行 iOS 模拟器
react-native run-ios
临时修复:
步骤 1:打开文件 /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
第2步:改一行代码,出自:
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
对此:
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
continue;
}
第 3 步:运行 react-native run-ios
(你可能需要 运行 两次,别忘了杀死 Metro Bundler [在后台 运行ning 的控制台] 如果它是 运行ning 来自你之前不成功的构建!)
问题是在 Xcode 更新后 - 模拟器名称空间被添加到设备的版本列表中。 React Native 构建不期望这些名称空间 - 因此构建中断。
打开文件/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
!version.startsWith('iOS') - > !version.包括('iOS')
在我的例子中,我 运行 脚本:
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
它奏效了。
也适合不会更新的人react-native
更新到 Xcode 11 xcrun returns true or false 而不是之前的 YES 或 NO。
转到/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js并在
找到
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
continue;
}
并将其更改为
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== true
) {
continue;
}
如果在 runSimulator.js.
中替换以下代码行后,如果找不到模拟器仍然存在
Path for runSimulator.js ->
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) { continue; }
用这个
if ( !version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS') ) { continue; }
替换后评论以下行
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue; }
它将毫无问题地启动 iPhone 模拟器。
和更新到 XCode 11
后的第二种方法
Xcode 11 xcrun returns true 或 false,而不是 YES 或 NO for isAvailable 属性 和以前一样。
您可以使用以下命令检查
xcrun simctl list devices --json
above command will print all available devices like following
"com.apple.CoreSimulator.SimRuntime.iOS-12-2" : [
{
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "E53748D1-628B-4A99-A419-4D7AE7CE4745"
}
]
Replace YES with true in following code
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue; }
like this
if ( simulator.availability !== '(available)' && simulator.isAvailable !== true ) { continue; }
我的问题是iPhone没有安装X模拟器
您可以查看安装了哪些模拟器
xcrun simctl list devices | grep iPhone | grep -v unavailable | cut -d'(' -f1
然后运行
react-native run-ios --simulator="iPhone Xs"
对于 react-native-cli 2.0.1,您可能只想重命名您的模拟器。默认情况下 Xcode 将以 <DeviceName> (<DeviceSize>)
格式命名一些设备。但是,此版本的 CLI 会将括号中的任何内容解释为 iOS 版本。
在尝试 运行 名为 iPad Pro (10.5-inch)
的模拟器时,我只需将模拟器重命名为 iPad Pro [10.5-inch]
即可将其设置为 运行。
您可以使用模拟器应用的 Hardware
->Device
->Manage Devices...
菜单和 right-clicking 您的其中一个模拟器(在 Xcode 10.2.1)
我在更新 Xcode 时遇到了这个问题。所有的模拟器都不是 available/uninstalled。我正在重新安装它们。
只需重新启动计算机并再次 运行 命令。
我每次更新 Xcode 都会遇到同样的问题。
我 运行 这个命令:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
然后我又运行react-native run-ios
问题
如果你用最新的 Xcode (11) 试试这个,没有 iPhone X!
运行 模拟器本身,在顶部菜单中,查看硬件、设备、iOS 13.0。
你会看到有:
- iPhone 8
- iPhone 8 加
- iPhone XS
- iPhone XS Max
- iPhone XR
- ...还有一些 iPads
当你执行 run-ios
时,react-native 被设计为匹配请求的设备。
内部硬编码默认值是 iPhone X。
尝试匹配所请求设备的函数在:
/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js
这个函数的设计目的是让你可以给它一个设备,以及一个可选的版本号。
如果找不到给定的设备和版本,它将return默认使用列表中的第一个设备进行匹配。
但是...实际上,第一个设备是手表,任何手表都被排除在匹配之外,所以这个函数将return null。
解决方案 1 - 使用现有的 Xcode 设备
运行 首先是模拟器本身,如上所述,然后记下你想要的 iPhone 或 iPad。
然后将此名称作为可选参数传递给 运行-ios 命令行命令,如下所示:
react-native run-ios --simulator="iPhone 8"
解决方案 2 - 添加新的 Xcode iOS 设备
"Xcode no longer creates every available iOS simulator device by default. Instead a set of the most commonly used devices are created. To create other devices — or multiple instances of a device — open the Devices window, select Simulators, click the + button, enter a name, and select the relevant device type and OS version. In Terminal, execute the xcrun simctl create command, for example xcrun simctl create "我的 iPhone 7" "iPhone 7" iOS13.0. (49428617)"
在Xcode中,您需要添加一个名为"iPhone X"的新设备。
我也在这里回答:React Native Issue #2328
轻松解决...
Xcode -> 首选项 -> 组件安装 ios 12.2 sumulator
您的机器上没有 iPhone X 模拟器,很可能是因为您更新了 Xcode。您可以简单地传递可用模拟器的名称,如下所示:
react-native run-ios --simulator="iPhone 11"
要检查可用的模拟器,您可以打开 Xcode 并检查设备列表,如下所示:
我也没有在 Xcode 上安装 iPhone X 作为模拟器。我所要做的就是在 Xcode 中添加 iPhone X 作为新模拟器,一切都很好。
在 Xcode 中:转到 Window
然后 Devices and Simulators
。单击模拟器选项卡。点击左下角的+
按钮,添加iPhone X.
我希望这个修复对你和我一样简单。
改变
/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
文件
options: [{
name: '--simulator [string]',
description: 'Explicitly set simulator to use. Optionally include iOS version between' + 'parenthesis at the end to match an exact version: "iPhone 6 (10.0)"',
default: 'iPhone X'
}
到
options: [{
name: '--simulator [string]',
description: 'Explicitly set simulator to use. Optionally include iOS version between' + 'parenthesis at the end to match an exact version: "iPhone 6 (10.0)"',
default: 'iPhone 8'
}
我将 Xcode 10 升级到 Xcode 11 时遇到了同样的错误,但是指定模拟器版本对我来说恰好是一个快速修复。
首先列出所有可用的 ios 模拟器
xcrun simctl list devices | grep iPhone | grep -v unavailable | cut -d'(' -f1
结果
然后 select 一个到 运行 react-native with,例如
react-native run-ios --simulator='iPhone 11 Pro Max'
我更新Xcode到版本11后,遇到了同样的问题。
一个解决方案是将 iPhone X 模拟器添加到您的列表中。
选择模拟器 -> 硬件 -> 管理设备(你会看到一个弹出窗口)
选择"Simulators" ->(左下角)+("Filter"旁边的加号图标)然后添加一个新的模拟器,
模拟器名称:iPhone X
设备类型:选择iPhone X.
对我有用
对于 Xcode 11.2 和 iOS 13.2,这是我对 运行 模拟器中的应用所做的更改
在findMatchingSimulator.js
第 43 行:
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
到
if (!version.includes('iOS') && !version.includes('tvOS')) {
行
第 52 行
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
continue;
}
到
if (
simulator.isAvailable != true
) {
continue;
}
P.S.
React 项目广告的第一天已经降价了! (否)
就我而言,我已经尝试过其他解决方案,但没有任何效果。
然后我尝试将 react-native 从 0.59.5
升级到 0.59.10
然后它就解决了
对我来说,我必须通过 运行 npx react-native-git-upgrade
.
将 React Native 更新到 0.60
我在尝试将 React Native 从 0.59.8
升级到 0.59.9
后遇到了这个问题。
事实证明(根据以上答案),我们需要更新 @react-native-community/cli
模块:
- 将其从锁定文件中删除(
yarn.lock
或 package-lock.json
)
- 运行
yarn
或 npm install
重新安装。
参考:https://github.com/react-native-community/rn-diff-purge/issues/21#issuecomment-507645945
我遇到了同样的问题
npm audit fix
这对我有用
为我解决的问题是没有设置 Xcode 命令行工具(xcrun simctl
失败。)如果您刚刚重新安装 Xcode,您可能会遇到这个问题。
有关如何设置命令行工具的信息,请参见this post。之后,尝试 运行 react-native run-ios --simulator="iPhone 11"
(或任何您的模拟器名称)。
每当我 运行 react-native run-ios
,我得到
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (calendarPractice/node_modules/react-native/local-cli/cliEntry.js:117:22)
然而,当我 运行 在 Xcode 上时,它工作正常
{
"devicetypes" : [
{
"name" : "iPhone 4s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 4s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-4s"
},
{
"name" : "iPhone 5",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5"
},
{
"name" : "iPhone 5s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"
},
{
"name" : "iPhone 6",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6"
},
{
"name" : "iPhone 6 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus"
},
{
"name" : "iPhone 6s",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s"
},
{
"name" : "iPhone 6s Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus"
},
{
"name" : "iPhone 7",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7"
},
{
"name" : "iPhone 7 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus"
},
{
"name" : "iPhone 8",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8"
},
{
"name" : "iPhone 8 Plus",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8 Plus.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus"
},
{
"name" : "iPhone SE",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone SE.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
},
{
"name" : "iPhone X",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone X.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-X"
},
{
"name" : "iPhone Xs",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS"
},
{
"name" : "iPhone Xs Max",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs Max.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max"
},
{
"name" : "iPhone Xʀ",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xʀ.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XR"
},
{
"name" : "iPad 2",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad 2.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-2"
},
{
"name" : "iPad Retina",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Retina.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Retina"
},
{
"name" : "iPad Air",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air"
},
{
"name" : "iPad Air 2",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air 2.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air-2"
},
{
"name" : "iPad (5th generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (5th generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-"
},
{
"name" : "iPad Pro (9.7-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (9.7-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-"
},
{
"name" : "iPad Pro (12.9-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro"
},
{
"name" : "iPad Pro (12.9-inch) (2nd generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (2nd generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-"
},
{
"name" : "iPad Pro (10.5-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (10.5-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-"
},
{
"name" : "iPad (6th generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (6th generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-"
},
{
"name" : "iPad Pro (11-inch)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (11-inch).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-"
},
{
"name" : "iPad Pro (12.9-inch) (3rd generation)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (3rd generation).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-"
},
{
"name" : "Apple TV",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p"
},
{
"name" : "Apple TV 4K",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K"
},
{
"name" : "Apple TV 4K (at 1080p)",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K (at 1080p).simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p"
},
{
"name" : "Apple Watch - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm"
},
{
"name" : "Apple Watch - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm"
},
{
"name" : "Apple Watch Series 2 - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm"
},
{
"name" : "Apple Watch Series 2 - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm"
},
{
"name" : "Apple Watch Series 3 - 38mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 38mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm"
},
{
"name" : "Apple Watch Series 3 - 42mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 42mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm"
},
{
"name" : "Apple Watch Series 4 - 40mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 40mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm"
},
{
"name" : "Apple Watch Series 4 - 44mm",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 44mm.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm"
}
],
"runtimes" : [
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
"availabilityError" : "",
"buildversion" : "16B91",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-12-1",
"version" : "12.1",
"name" : "iOS 12.1"
},
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/tvOS.simruntime",
"availabilityError" : "",
"buildversion" : "16J602",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-12-1",
"version" : "12.1",
"name" : "tvOS 12.1"
},
{
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/watchOS.simruntime",
"availabilityError" : "",
"buildversion" : "16R591",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-5-1",
"version" : "5.1",
"name" : "watchOS 5.1"
}
],
"devices" : {
"com.apple.CoreSimulator.SimRuntime.watchOS-5-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 2 - 38mm",
"udid" : "01AFDEF7-63B6-465C-A02A-44EE4A07EABA",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 2 - 42mm",
"udid" : "BE62C985-DEE2-46EC-8962-A582D537EEE0",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 3 - 38mm",
"udid" : "078BF157-30FA-41D1-94FA-6B1686E03085",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 3 - 42mm",
"udid" : "E4CE652E-0185-4C59-B965-BED5FCEE7C76",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 40mm",
"udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple Watch Series 4 - 44mm",
"udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
"availabilityError" : ""
}
],
"com.apple.CoreSimulator.SimRuntime.tvOS-12-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV",
"udid" : "AFAA21B8-BD4A-45EA-B0FF-E9915FE9B926",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K",
"udid" : "EBB88F2E-CFFE-4981-A736-7A7C0B85643D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "Apple TV 4K (at 1080p)",
"udid" : "F0B73E8A-986E-447E-B37A-2F46096DEFF6",
"availabilityError" : ""
}
],
"com.apple.CoreSimulator.SimRuntime.iOS-12-1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "F870B7FA-6DDA-4336-89AD-68A402844188",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "6627ADE5-F8C1-4AE5-BD6F-3AEDDC0B7B63",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6",
"udid" : "05574997-ACAD-40CA-A3D7-5624D53F00FA",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6 Plus",
"udid" : "93237078-CA6D-4F97-93F9-779809700018",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6s",
"udid" : "9B50FE18-4F49-4EA4-80F0-DF498A667D33",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 6s Plus",
"udid" : "D4640B6D-97DC-4CA1-BE63-C5403159A3D4",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7",
"udid" : "6E9EEC00-3291-42B4-B04A-BA3487F9CD5F",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 7 Plus",
"udid" : "6DA1C3CF-1D1F-4DEF-9B74-2C40D5FB5881",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8",
"udid" : "E19386B9-469A-450B-9CD2-B4FE8687DCF9",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 8 Plus",
"udid" : "6D36DF76-8ED9-41A2-9E1A-0BA48B92C26E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone SE",
"udid" : "EE4818DF-F817-4441-8A1C-BE1B99303E10",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "85B78A8F-C32B-4493-BDD1-65ECA3F77C86",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "CA12C337-4F66-4C6C-ACE5-7F7EACCBC39A",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XS",
"udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XS Max",
"udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone XR",
"udid" : "28D12ABE-3355-4862-960A-0FE5FFE41C7B",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air",
"udid" : "94485C88-BCEB-456A-95DC-5F8C3DA8D181",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Air 2",
"udid" : "CF2C787D-A378-4AB9-B334-F7B24E94AF4D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (5th generation)",
"udid" : "DFE602A5-EC68-4585-8AB0-C045A9843D29",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (9.7-inch)",
"udid" : "5A3F3EAC-F788-49F1-A753-5D34A9990F0B",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch)",
"udid" : "EF6EBE34-0A85-4FF0-8A45-7BA418A0CC0C",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (2nd generation)",
"udid" : "FBA940F8-FD85-4D5E-A570-EB4F3A56E1F9",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (10.5-inch)",
"udid" : "8AE4AAED-ECE0-4984-9679-8D3022064692",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad (6th generation)",
"udid" : "1121363D-EF49-4AC0-9E46-5C30318A24A2",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (11-inch)",
"udid" : "038FECC0-8711-46E3-B601-8F88F2F4AD7D",
"availabilityError" : ""
},
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro (12.9-inch) (3rd generation)",
"udid" : "12DC911F-2F45-4767-BC1A-6F1D0C8D9F3D",
"availabilityError" : ""
}
]
},
"pairs" : {
"C9B69F4A-6A9D-44F3-A6BC-56BFA2F8B83F" : {
"watch" : {
"name" : "Apple Watch Series 4 - 44mm",
"udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
"state" : "Shutdown"
},
"phone" : {
"name" : "iPhone XS Max",
"udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
"state" : "Shutdown"
},
"state" : "(active, disconnected)"
},
"5327B65F-29E7-42D0-9861-FF31428F3218" : {
"watch" : {
"name" : "Apple Watch Series 4 - 40mm",
"udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
"state" : "Shutdown"
},
"phone" : {
"name" : "iPhone XS",
"udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
"state" : "Shutdown"
},
"state" : "(active, disconnected)"
}
}
已编辑:
我复制了你输出的设备部分 JSON 并嵌入到我自己的 /node_modules/react-native/local-cli/runIOS/runIOS.js
function runOnSimulator(xcodeProject, args, scheme) {
return new Promise(resolve => {
try {
var simulators = {devices section of your json}; //Here
} catch (e) {
console.log("e", e);
throw new Error('Could not parse the simulator list output');
}
const selectedSimulator = findMatchingSimulator(simulators, args.simulator);
console.log("selected", selectedSimulator);
if (!selectedSimulator) {
throw new Error(`Could not find ${args.simulator} simulator`);
}
...
最后,它给出了和你一样的错误。所以我发现设备的解析版本不同。在您的设备中,版本是;
"com.apple.CoreSimulator.SimRuntime.tvOS-12-1" //for tvOS
"com.apple.CoreSimulator.SimRuntime.iOS-12-1" // for iOS
但是在 react-native 中检查这个版本值是这样的(/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
);
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
所以react-native无法识别
如果我们用这个更改此代码;
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
continue;
}
问题已解决。我在我的电脑上用你的 JSON 数据检查过,它有效。
要修复此错误,只需使用 npm
重新安装项目和节点模块npm install
然后它将显示警告列表,并使用以下命令修复它们:
npm audit fix
这应该可以解决所有问题,并允许您 运行 iOS 模拟器
react-native run-ios
临时修复:
步骤 1:打开文件 /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
第2步:改一行代码,出自:
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
对此:
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
continue;
}
第 3 步:运行 react-native run-ios
(你可能需要 运行 两次,别忘了杀死 Metro Bundler [在后台 运行ning 的控制台] 如果它是 运行ning 来自你之前不成功的构建!)
问题是在 Xcode 更新后 - 模拟器名称空间被添加到设备的版本列表中。 React Native 构建不期望这些名称空间 - 因此构建中断。
打开文件/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
!version.startsWith('iOS') - > !version.包括('iOS')
在我的例子中,我 运行 脚本: sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 它奏效了。 也适合不会更新的人react-native
更新到 Xcode 11 xcrun returns true or false 而不是之前的 YES 或 NO。
转到/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js并在
找到
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
continue;
}
并将其更改为
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== true
) {
continue;
}
如果在 runSimulator.js.
中替换以下代码行后,如果找不到模拟器仍然存在Path for runSimulator.js -> /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) { continue; }
用这个
if ( !version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS') ) { continue; }
替换后评论以下行
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue; }
它将毫无问题地启动 iPhone 模拟器。
和更新到 XCode 11
后的第二种方法Xcode 11 xcrun returns true 或 false,而不是 YES 或 NO for isAvailable 属性 和以前一样。 您可以使用以下命令检查
xcrun simctl list devices --json
above command will print all available devices like following
"com.apple.CoreSimulator.SimRuntime.iOS-12-2" : [
{
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "E53748D1-628B-4A99-A419-4D7AE7CE4745"
}
]
Replace YES with true in following code
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue; }
like this
if ( simulator.availability !== '(available)' && simulator.isAvailable !== true ) { continue; }
我的问题是iPhone没有安装X模拟器
您可以查看安装了哪些模拟器
xcrun simctl list devices | grep iPhone | grep -v unavailable | cut -d'(' -f1
然后运行
react-native run-ios --simulator="iPhone Xs"
对于 react-native-cli 2.0.1,您可能只想重命名您的模拟器。默认情况下 Xcode 将以 <DeviceName> (<DeviceSize>)
格式命名一些设备。但是,此版本的 CLI 会将括号中的任何内容解释为 iOS 版本。
在尝试 运行 名为 iPad Pro (10.5-inch)
的模拟器时,我只需将模拟器重命名为 iPad Pro [10.5-inch]
即可将其设置为 运行。
您可以使用模拟器应用的 Hardware
->Device
->Manage Devices...
菜单和 right-clicking 您的其中一个模拟器(在 Xcode 10.2.1)
我在更新 Xcode 时遇到了这个问题。所有的模拟器都不是 available/uninstalled。我正在重新安装它们。
只需重新启动计算机并再次 运行 命令。
我每次更新 Xcode 都会遇到同样的问题。
我 运行 这个命令:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
然后我又运行react-native run-ios
问题
如果你用最新的 Xcode (11) 试试这个,没有 iPhone X!
运行 模拟器本身,在顶部菜单中,查看硬件、设备、iOS 13.0。 你会看到有:
- iPhone 8
- iPhone 8 加
- iPhone XS
- iPhone XS Max
- iPhone XR
- ...还有一些 iPads
当你执行 run-ios
时,react-native 被设计为匹配请求的设备。
内部硬编码默认值是 iPhone X。
尝试匹配所请求设备的函数在:
/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js
这个函数的设计目的是让你可以给它一个设备,以及一个可选的版本号。
如果找不到给定的设备和版本,它将return默认使用列表中的第一个设备进行匹配。
但是...实际上,第一个设备是手表,任何手表都被排除在匹配之外,所以这个函数将return null。
解决方案 1 - 使用现有的 Xcode 设备
运行 首先是模拟器本身,如上所述,然后记下你想要的 iPhone 或 iPad。
然后将此名称作为可选参数传递给 运行-ios 命令行命令,如下所示:
react-native run-ios --simulator="iPhone 8"
解决方案 2 - 添加新的 Xcode iOS 设备
"Xcode no longer creates every available iOS simulator device by default. Instead a set of the most commonly used devices are created. To create other devices — or multiple instances of a device — open the Devices window, select Simulators, click the + button, enter a name, and select the relevant device type and OS version. In Terminal, execute the xcrun simctl create command, for example xcrun simctl create "我的 iPhone 7" "iPhone 7" iOS13.0. (49428617)"
在Xcode中,您需要添加一个名为"iPhone X"的新设备。
我也在这里回答:React Native Issue #2328
轻松解决...
Xcode -> 首选项 -> 组件安装 ios 12.2 sumulator
您的机器上没有 iPhone X 模拟器,很可能是因为您更新了 Xcode。您可以简单地传递可用模拟器的名称,如下所示:
react-native run-ios --simulator="iPhone 11"
要检查可用的模拟器,您可以打开 Xcode 并检查设备列表,如下所示:
我也没有在 Xcode 上安装 iPhone X 作为模拟器。我所要做的就是在 Xcode 中添加 iPhone X 作为新模拟器,一切都很好。
在 Xcode 中:转到 Window
然后 Devices and Simulators
。单击模拟器选项卡。点击左下角的+
按钮,添加iPhone X.
我希望这个修复对你和我一样简单。
改变
/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
文件
options: [{
name: '--simulator [string]',
description: 'Explicitly set simulator to use. Optionally include iOS version between' + 'parenthesis at the end to match an exact version: "iPhone 6 (10.0)"',
default: 'iPhone X'
}
到
options: [{
name: '--simulator [string]',
description: 'Explicitly set simulator to use. Optionally include iOS version between' + 'parenthesis at the end to match an exact version: "iPhone 6 (10.0)"',
default: 'iPhone 8'
}
我将 Xcode 10 升级到 Xcode 11 时遇到了同样的错误,但是指定模拟器版本对我来说恰好是一个快速修复。
首先列出所有可用的 ios 模拟器
xcrun simctl list devices | grep iPhone | grep -v unavailable | cut -d'(' -f1
结果
然后 select 一个到 运行 react-native with,例如
react-native run-ios --simulator='iPhone 11 Pro Max'
我更新Xcode到版本11后,遇到了同样的问题。
一个解决方案是将 iPhone X 模拟器添加到您的列表中。
选择模拟器 -> 硬件 -> 管理设备(你会看到一个弹出窗口)
选择"Simulators" ->(左下角)+("Filter"旁边的加号图标)然后添加一个新的模拟器,
模拟器名称:iPhone X 设备类型:选择iPhone X.
对我有用
对于 Xcode 11.2 和 iOS 13.2,这是我对 运行 模拟器中的应用所做的更改
在findMatchingSimulator.js
第 43 行:
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
到
if (!version.includes('iOS') && !version.includes('tvOS')) {
行
第 52 行
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
continue;
}
到
if (
simulator.isAvailable != true
) {
continue;
}
P.S.
React 项目广告的第一天已经降价了! (否)
就我而言,我已经尝试过其他解决方案,但没有任何效果。
然后我尝试将 react-native 从 0.59.5
升级到 0.59.10
然后它就解决了
对我来说,我必须通过 运行 npx react-native-git-upgrade
.
我在尝试将 React Native 从 0.59.8
升级到 0.59.9
后遇到了这个问题。
事实证明(根据以上答案),我们需要更新 @react-native-community/cli
模块:
- 将其从锁定文件中删除(
yarn.lock
或package-lock.json
) - 运行
yarn
或npm install
重新安装。
参考:https://github.com/react-native-community/rn-diff-purge/issues/21#issuecomment-507645945
我遇到了同样的问题
npm audit fix
这对我有用
为我解决的问题是没有设置 Xcode 命令行工具(xcrun simctl
失败。)如果您刚刚重新安装 Xcode,您可能会遇到这个问题。
有关如何设置命令行工具的信息,请参见this post。之后,尝试 运行 react-native run-ios --simulator="iPhone 11"
(或任何您的模拟器名称)。