Yerel Değişiklik Varsayılan iOS Simülatörü Cihazı


158

Bu komutu çalıştırdığımda:

react-native run-ios

Uygulamam iPhone6 ​​simülatör cihazında varsayılan olarak çalışır:

Found Xcode project RN.xcodeproj
Launching iPhone 6 (9.2)...

Uygulamanın varsayılan olarak farklı bir simülatör cihazında (iPhone5'ler gibi) çalışmasını nasıl sağlayabilirim?


Xcode -> Ürün -> Hedef ??
zipzit

2
Varsayılan cihazı nasıl kuracağımı bilmiyorum, ancak çalıştırdıktan sonra react-native run-ioscihazı değiştirebilirsiniz Simulator > Hardware > Device > iOS x.x > iPhone 5. Bu, simülatörden çıkana kadar çalışacaktır.
sealskej

Yanıtlar:


396

--simulatorBayrağını kullanarak bir simülatör belirtin .

Bunlar iOS 12.0 ve sonrası için mevcut cihazlar:

npx react-native run-ios --simulator="iPhone 5s"
npx react-native run-ios --simulator="iPhone 6"
npx react-native run-ios --simulator="iPhone 6 Plus"
npx react-native run-ios --simulator="iPhone 6s"
npx react-native run-ios --simulator="iPhone 6s Plus"
npx react-native run-ios --simulator="iPhone 7"
npx react-native run-ios --simulator="iPhone 7 Plus"
npx react-native run-ios --simulator="iPhone 8"
npx react-native run-ios --simulator="iPhone 8 Plus"
npx react-native run-ios --simulator="iPhone 11"
npx react-native run-ios --simulator="iPhone 11 Pro"
npx react-native run-ios --simulator="iPhone 11 Pro Max"
npx react-native run-ios --simulator="iPad Pro (9.7-inch)"
npx react-native run-ios --simulator="iPad (7th generation)"
npx react-native run-ios --simulator="iPad Pro (11-inch)"
npx react-native run-ios --simulator="iPad Pro (12.9-inch)"
npx react-native run-ios --simulator="iPad Air (3rd generation)"
npx react-native run-ios --simulator="iPad Pro (11-inch) (1st generation)"

Mevcut tüm iOS cihazlarını listeleyin:

xcrun simctl list devices

Şu anda bir varsayılan ayarlamanın bir yolu yoktur.

Yerli Belgeleri Tepki Etme: Simülatörde Koşma


thnx çok yardımcı oldu
Lakshaya Maheshwari

2
Ve eğer istersen; react-native run-ios --simulator="iPad Air"
Burak Tokak

22
Mevcut tüm cihazları görmek için buradaxcrun simctl list devices daha fazla bilgi kullanabilirsiniz
robd

1
Örneğin, ios 11 için iPhone 6s, ios 12 için iPhone 6s gibi aynı ada sahip birden fazla simülatörünüz varsa, Xcode -> Pencere -> Aygıtlar ve Simülatörler
Chirag Purohit

Neden birden fazla "iPad Pro"?
kojow7

48

Bunun için npm'yi dosyanızın scriptsöğesine bir giriş ekleyerek de kullanabilirsiniz package.json. Örneğin

"launch-ios": "react-native run-ios --simulator \"iPad Air 2\""

Sonra bunu kullanmak için: npm run launch-ios


3
IMHO, yapılandırmayı kod / sürüm kontrolünde saklamanıza izin verdiği için en iyi cevaptır. Komut satırı sözdizimini hatırlamanız gerekmediği anlamına gelir.
Nick

1
Bu yanıta katılıyorum. Ayrıca tek tırnak ile de alabilirsiniz: "launch-ios": "react-native run-ios --simulator 'iPad Air 2'"
lfkwtz

24

Avlanırsanız bir proje ayarı vardır:

{project}/node_modules/react-native/local-cli/runIOS/runIOS.js

İçeride module.exportsdahil olmak üzere bazı seçenekler vardır :

options: [{ command: '--simulator [string]', description: 'Explicitly set simulator to use', default: 'iPhone 7', }

Benimki 231 hattıydı, sadece geçerli bir yüklü simülatöre ayarlayın ve react-native run-iosvarsayılan olarak bu simülatöre çalıştıracak şekilde çalıştırın.


5
Dosya {project} / node_modules / tepki-yerel / yerel-cli / runIOS /
Matej Ukmar

Harika bir çözüm. Teşekkürler!
Ahmet Ardal

Aslında bu modül düğüm modülleri klasörü altında yok.
Abdul Sadik Yalcin

1
Evet, "runArguments": [ "--simulator", "iPhone 5s" ]lansman konfigürasyonuma ekleme mükemmel çalıştı.
Can Poyrazoğlu

22

~/.bash_profileDosyanızda bir takma ad oluşturabilirsiniz :

alias rn-ios="react-native run-ios --simulator \"iPhone 5s (10.0)\""

Ve sonra oluşturulan takma adı kullanarak reat-native komutunu çalıştırın:

$ rn-ios


15

1) Simülatörünüzü yeniden adlandırın, simülatör aynı ada ancak farklı iOS sürümüne sahipse

Xcode -> Window -> Devices and Simulators -> Simulators.

resim açıklamasını buraya girin

2) Reaksiyon yerel proje klasörünüzü açın

3) package.json dosyasını düzenleyin

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "flow": "node_modules/.bin/flow",
    "start-iphone6": "react-native run-ios --simulator \"iPhone 6 11.3\""
}

4) npm run start-iphone6


5

Ian L tarafından yanıtlandığı gibi, komut dosyalarımı yönetmek için NPM kullanıyorum.

Misal:

{
  "scripts": {
    "ios": "react-native run-ios --simulator=\"iPad Air 2\"",
    "devices": "xcrun simctl list devices"
  }
}

Bu şekilde ihtiyacım olanı hızlı bir şekilde alabilirim:

  1. Tüm cihazları listele: npm run devices
  2. Varsayılan simülatörü çalıştırın: npm run ios

3

İşte iOS simülatörünü değiştirmek için sadece değiştirmeniz gereken yeni yol

default: 'iPhone 6' or something else 

Yol:

<project_root>/node_modules/@react-native-community/cli/build/commands/runIOS/runIOS.js


0

XCode 10.2 ile doğru iOS simülatörü sürüm numarasını belirterek bir sorun yaşadım, bu yüzden kullanıldı:

react-native run-ios --simulator='iPhone X (com.apple.CoreSimulator.SimRuntime.iOS-12-1)'

0

Varsayılan cihazı değiştirmek istiyorsanız ve sadece reat-native run-ios'ları çalıştırmak zorundaysanız bulucuda "runios" anahtar sözcüğünü arayabilir ve ardından klasörü açıp sabit index.js dosyasını 'iphone X' değiştirerek cihazınıza değiştirebilirsiniz.

[1]: https://i.stack.imgur.com/BCtR1.png


0

Bu komutla cihaz listesini al

xcrun simctl list devices

Konsol

== Devices ==
-- iOS 13.5 --
    iPhone 6s (9981E5A5-48A8-4B48-B203-1C6E73243E83) (Shutdown) 
    iPhone 8 (FC540A6C-F374-4113-9E71-1291790C8C4C) (Shutting Down) 
    iPhone 8 Plus (CAC37462-D873-4EBB-9D71-7C6D0C915C12) (Shutdown) 
    iPhone 11 (347EFE28-9B41-4C1A-A4C3-D99B49300D8B) (Shutting Down) 
    iPhone 11 Pro (5AE964DC-201C-48C9-BFB5-4506E3A0018F) (Shutdown) 
    iPhone 11 Pro Max (48EE985A-39A6-426C-88A4-AA1E4AFA0133) (Shutdown) 
    iPhone SE (2nd generation) (48B78183-AFD7-4832-A80E-AF70844222BA) (Shutdown) 
    iPad Pro (9.7-inch) (2DEF27C4-6A18-4477-AC7F-FB31CCCB3960) (Shutdown) 
    iPad (7th generation) (36A4AF6B-1232-4BCB-B74F-226E025225E4) (Shutdown) 
    iPad Pro (11-inch) (2nd generation) (79391BD7-0E55-44C8-B1F9-AF92A1D57274) (Shutdown) 
    iPad Pro (12.9-inch) (4th generation) (ED90A31F-6B20-4A6B-9EE9-CF22C01E8793) (Shutdown) 
    iPad Air (3rd generation) (41AD1CF7-CB0D-4F18-AB1E-6F8B6261AD33) (Shutdown) 
-- tvOS 13.4 --
    Apple TV 4K (51925935-97F4-4242-902F-041F34A66B82) (Shutdown) 
-- watchOS 6.2 --
    Apple Watch Series 5 - 40mm (7C50F2E9-A52B-4E0D-8B81-A811FE995502) (Shutdown) 
    Apple Watch Series 5 - 44mm (F7D8C256-DC9F-4FDC-8E65-63275C222B87) (Shutdown) 

Kimliği olmayan Simülatör dizesini seçin burada bir örnek.

iPad Pro (12,9 inç) (4. nesil)

Son komut

iPhone

• iPhone 6s

react-native run-ios --simulator="iPhone 6s"

• iPhone 8

react-native run-ios --simulator="iPhone 8"

• iPhone 8 Plus

react-native run-ios --simulator="iPhone 8 Plus"

• iPhone 11

react-native run-ios --simulator="iPhone 11"

• iPhone 11 Pro

react-native run-ios --simulator="iPhone 11 Pro"

• iPhone 11 Pro Max

react-native run-ios --simulator="iPhone 11 Pro Max"

• iPhone SE (2. nesil)

react-native run-ios --simulator="iPhone SE (2nd generation)"

iPad

• iPad Pro (9,7 inç)

react-native run-ios --simulator="iPad Pro (9.7-inch)"

• iPad (7. nesil)

react-native run-ios --simulator="iPad (7th generation)"

• iPad Pro (11 inç) (2. nesil)

react-native run-ios --simulator="iPad Pro (11-inch) (2nd generation)"

• iPad Pro (12,9 inç) 4. nesil

react-native run-ios --simulator="iPad Pro (12.9-inch) (4th generation)"

• iPad Air (3. nesil)

react-native run-ios --simulator="iPad Air (3rd generation)"
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.