douglowder / TestConfigPluginTV

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TestConfigPluginTV

A test app to try out @react-native-tvos/config-tv.

Includes code to exercise EAS Update, and show a video using expo-video.

Quick start

yarn
eas init
eas build:configure
eas update:configure

Build on your desktop

# Set up to build for TV
export EXPO_TV=1
npx expo prebuild

# Build debug app with packager
yarn ios

# Build release app for EAS update testing
yarn ios --configuration Release

# Now switch back to building for phone
unset EXPO_TV
npx expo prebuild --clean

yarn ios

yarn ios --configuration Release

You can also use yarn android to build an Android app for either a TV emulator or a phone emulator.

Build on EAS

# Build an iOS simulator app
eas build -e preview -p ios

# Build an Apple TV simulator app
eas build -e preview_tv -p ios

# Build an Android phone app
eas build -e preview -p android

# Build an Android TV app
eas build -e preview_tv -p android

There are also profiles to build development apps for TV that can run against the packager with npx expo start.

Expo Config Plugin to auto-configure the native directories for TV

Expo installation

Tested against Expo SDK 50 alpha

This package cannot be used in the "Expo Go" app because Expo Go does not support TV.

npx expo install tv @react-native-tvos/config-tv

After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js:

{
  "expo": {
    "plugins": ["@react-native-tvos/config-tv"]
  }
}

or

{
  "expo": {
    "plugins": [
      [
        "@react-native-tvos/config-tv",
        {
          "isTV": true,
          "showVerboseWarnings": false
        }
      ]
    ]
  }
}

Usage

Plugin parameters:

  • isTV: (optional boolean, default false) If true, prebuild should generate or modify Android and iOS files to build for TV (Android TV and Apple TV). If false, the default phone-appropriate files should be generated, and if existing files contain TV changes, they will be reverted. Setting the environment variable EXPO_TV to "true" or "1" will override this value and force a TV build.
  • showVerboseWarnings: (optional boolean, default false) If true, verbose warnings will be shown during plugin execution.

Warning:

When this plugin is used to generate files in the iOS directory that build an Apple TV or Android TV app, your React Native dependency in package.json must be set to the React Native TV fork, as shown in the example below:

{
  "dependencies": {
    "react-native": "npm:react-native-tvos@^0.72.4-0"
  }
}

If this is not the case, the plugin will run successfully, but Cocoapods installation will fail, since React Native core repo does not support Apple TV. Android TV build will succeed, but will not contain native changes needed to correctly navigate the screen using a TV remote, and may have other problems.

About


Languages

Language:TypeScript 98.4%Language:JavaScript 1.6%