Target both iPhone and iPad with React Native

Chris Achard
InstructorChris Achard
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 6 years ago

By default, React Native only targets iPhone - so if you run on an iPad, it will show up as a scaled app, and won't look like a native iPad app.

To target both iPhone and iPad, you have to change the xcode project to build it as a universal app. Do that by finding the Deployment Info section of the General tab in the app target - and switch that from iPhone to Universal.

Then, you can run your app in either the iPhone or iPad simulator, and change the styling based on the current device.

Instructor: [00:00] In a React native projects root folder, go into the iOS folder, and then open the Xcode project. Select your application target, and under the general tab, find the deployment info section.

[00:18] By default, React native projects only support iPhone. To support both iPhone and iPad, select the universal devices option, then select your supported device orientations for both iPhone and iPad.

[00:38] You can launch the app in the iPad simulator by switching the target device to iPad, and then pressing the play button. You can run the iPhone and the iPad simulator side by side, which is very convenient when doing development for multiple devices.

[00:59] Now that you're running on both iPhone and iPad, you can do things like change how you style or lay out a screen based on the device that you're running on. For example, here I'm making this scrolling list show two images side by side if the screen is wide enough.

egghead
egghead
~ a minute ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today