@react-native-tvos/config-tv 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/build/types.d.ts +4 -0
- package/build/utils.d.ts +2 -1
- package/build/utils.js +7 -2
- package/build/withTVXcodeProject.d.ts +8 -7
- package/build/withTVXcodeProject.js +17 -15
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -36,7 +36,8 @@ or
|
|
|
36
36
|
"@react-native-tvos/config-tv",
|
|
37
37
|
{
|
|
38
38
|
"isTV": true,
|
|
39
|
-
"showVerboseWarnings": false
|
|
39
|
+
"showVerboseWarnings": false,
|
|
40
|
+
"tvosDeploymentTarget": "13.4"
|
|
40
41
|
}
|
|
41
42
|
]
|
|
42
43
|
]
|
|
@@ -50,6 +51,7 @@ _Plugin parameters_:
|
|
|
50
51
|
|
|
51
52
|
- `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.
|
|
52
53
|
- `showVerboseWarnings`: (optional boolean, default false) If true, verbose warnings will be shown during plugin execution.
|
|
54
|
+
- `tvosDeploymentTarget`: (optional string, default '13.4') Used to set the tvOS deployment target version in the Xcode project.
|
|
53
55
|
|
|
54
56
|
_Warning_:
|
|
55
57
|
|
package/build/types.d.ts
CHANGED
|
@@ -10,4 +10,8 @@ export type ConfigData = {
|
|
|
10
10
|
* If true, verbose warnings will be shown during plugin execution.
|
|
11
11
|
*/
|
|
12
12
|
showVerboseWarnings?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If set, this will be used as the tvOS deployment target version instead of the default (13.4).
|
|
15
|
+
*/
|
|
16
|
+
tvosDeploymentTarget?: string;
|
|
13
17
|
};
|
package/build/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { ConfigData } from
|
|
1
|
+
import { ConfigData } from './types';
|
|
2
2
|
export declare function isTVEnabled(params: ConfigData): boolean;
|
|
3
3
|
export declare function showVerboseWarnings(params: ConfigData): boolean;
|
|
4
|
+
export declare function tvosDeploymentTarget(params: ConfigData): string;
|
package/build/utils.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showVerboseWarnings = exports.isTVEnabled = void 0;
|
|
3
|
+
exports.tvosDeploymentTarget = exports.showVerboseWarnings = exports.isTVEnabled = void 0;
|
|
4
4
|
const getenv_1 = require("getenv");
|
|
5
5
|
class Env {
|
|
6
6
|
/** Enable prebuild for TV */
|
|
7
7
|
get EXPO_TV() {
|
|
8
|
-
return (0, getenv_1.boolish)(
|
|
8
|
+
return (0, getenv_1.boolish)('EXPO_TV', false);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
const env = new Env();
|
|
12
|
+
const defaultTvosDeploymentVersion = '13.4';
|
|
12
13
|
function isTVEnabled(params) {
|
|
13
14
|
return env.EXPO_TV || (params?.isTV ?? false);
|
|
14
15
|
}
|
|
@@ -17,3 +18,7 @@ function showVerboseWarnings(params) {
|
|
|
17
18
|
return params?.showVerboseWarnings ?? false;
|
|
18
19
|
}
|
|
19
20
|
exports.showVerboseWarnings = showVerboseWarnings;
|
|
21
|
+
function tvosDeploymentTarget(params) {
|
|
22
|
+
return params?.tvosDeploymentTarget ?? defaultTvosDeploymentVersion;
|
|
23
|
+
}
|
|
24
|
+
exports.tvosDeploymentTarget = tvosDeploymentTarget;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ExpoConfig } from
|
|
2
|
-
import { ConfigPlugin, XcodeProject } from
|
|
3
|
-
import { ConfigData } from
|
|
1
|
+
import { ExpoConfig } from '@expo/config-types';
|
|
2
|
+
import { ConfigPlugin, XcodeProject } from 'expo/config-plugins';
|
|
3
|
+
import { ConfigData } from './types';
|
|
4
4
|
export declare const withTVXcodeProject: ConfigPlugin<ConfigData>;
|
|
5
|
-
export declare function setXcodeProjectBuildSettings(config: Pick<ExpoConfig,
|
|
5
|
+
export declare function setXcodeProjectBuildSettings(config: Pick<ExpoConfig, 'ios'>, { project, isTV, verbose, deploymentTarget, }: {
|
|
6
6
|
project: XcodeProject;
|
|
7
7
|
isTV: boolean;
|
|
8
8
|
verbose: boolean;
|
|
9
|
+
deploymentTarget: string;
|
|
9
10
|
}): XcodeProject;
|
|
10
11
|
/**
|
|
11
12
|
* Wrapping the families in double quotes is the only way to set a value with a comma in it.
|
|
@@ -13,6 +14,6 @@ export declare function setXcodeProjectBuildSettings(config: Pick<ExpoConfig, "i
|
|
|
13
14
|
* @param deviceFamilies
|
|
14
15
|
*/
|
|
15
16
|
export declare function formatDeviceFamilies(deviceFamilies: number[]): string;
|
|
16
|
-
export declare function getSupportsTablet(config: Pick<ExpoConfig,
|
|
17
|
-
export declare function getIsTabletOnly(config: Pick<ExpoConfig,
|
|
18
|
-
export declare function getDeviceFamilies(config: Pick<ExpoConfig,
|
|
17
|
+
export declare function getSupportsTablet(config: Pick<ExpoConfig, 'ios'>): boolean;
|
|
18
|
+
export declare function getIsTabletOnly(config: Pick<ExpoConfig, 'ios'>): boolean;
|
|
19
|
+
export declare function getDeviceFamilies(config: Pick<ExpoConfig, 'ios'>): number[];
|
|
@@ -3,45 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getDeviceFamilies = exports.getIsTabletOnly = exports.getSupportsTablet = exports.formatDeviceFamilies = exports.setXcodeProjectBuildSettings = exports.withTVXcodeProject = void 0;
|
|
4
4
|
const config_plugins_1 = require("expo/config-plugins");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
const pkg = require(
|
|
6
|
+
const pkg = require('../package.json');
|
|
7
7
|
const withTVXcodeProject = (config, params) => {
|
|
8
8
|
const isTV = (0, utils_1.isTVEnabled)(params);
|
|
9
9
|
const verbose = (0, utils_1.showVerboseWarnings)(params);
|
|
10
|
+
const deploymentTarget = (0, utils_1.tvosDeploymentTarget)(params);
|
|
10
11
|
return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
|
|
11
12
|
config.modResults = await setXcodeProjectBuildSettings(config, {
|
|
12
13
|
project: config.modResults,
|
|
13
14
|
isTV,
|
|
14
15
|
verbose,
|
|
16
|
+
deploymentTarget,
|
|
15
17
|
});
|
|
16
18
|
return config;
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
21
|
exports.withTVXcodeProject = withTVXcodeProject;
|
|
20
|
-
function setXcodeProjectBuildSettings(config, { project, isTV, verbose, }) {
|
|
22
|
+
function setXcodeProjectBuildSettings(config, { project, isTV, verbose, deploymentTarget, }) {
|
|
21
23
|
const deviceFamilies = formatDeviceFamilies(getDeviceFamilies(config));
|
|
22
24
|
const configurations = project.pbxXCBuildConfigurationSection();
|
|
23
25
|
// @ts-ignore
|
|
24
26
|
for (const { buildSettings } of Object.values(configurations || {})) {
|
|
25
27
|
// Guessing that this is the best way to emulate Xcode.
|
|
26
28
|
// Using `project.addToBuildSettings` modifies too many targets.
|
|
27
|
-
if (typeof buildSettings?.PRODUCT_NAME !==
|
|
28
|
-
if (isTV && buildSettings.TARGETED_DEVICE_FAMILY !==
|
|
29
|
+
if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {
|
|
30
|
+
if (isTV && buildSettings.TARGETED_DEVICE_FAMILY !== '3') {
|
|
29
31
|
if (verbose) {
|
|
30
|
-
config_plugins_1.WarningAggregator.addWarningIOS(
|
|
32
|
+
config_plugins_1.WarningAggregator.addWarningIOS('xcodeproject', `${pkg.name}@${pkg.version}: modifying target ${buildSettings?.PRODUCT_NAME} for ${isTV ? 'tvOS' : 'iOS'}`);
|
|
31
33
|
}
|
|
32
|
-
buildSettings.TARGETED_DEVICE_FAMILY =
|
|
33
|
-
buildSettings.TVOS_DEPLOYMENT_TARGET =
|
|
34
|
-
buildSettings.SDKROOT =
|
|
35
|
-
if (typeof buildSettings?.IOS_DEPLOYMENT_TARGET !==
|
|
34
|
+
buildSettings.TARGETED_DEVICE_FAMILY = '3';
|
|
35
|
+
buildSettings.TVOS_DEPLOYMENT_TARGET = deploymentTarget;
|
|
36
|
+
buildSettings.SDKROOT = 'appletvos';
|
|
37
|
+
if (typeof buildSettings?.IOS_DEPLOYMENT_TARGET !== 'undefined') {
|
|
36
38
|
delete buildSettings?.IOS_DEPLOYMENT_TARGET;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
else if (!isTV && buildSettings.TARGETED_DEVICE_FAMILY ===
|
|
40
|
-
config_plugins_1.WarningAggregator.addWarningIOS(
|
|
41
|
+
else if (!isTV && buildSettings.TARGETED_DEVICE_FAMILY === '3') {
|
|
42
|
+
config_plugins_1.WarningAggregator.addWarningIOS('xcodeproject', `${pkg.name}@${pkg.version}: modifying target ${buildSettings?.PRODUCT_NAME} for ${isTV ? 'tvOS' : 'iOS'}`);
|
|
41
43
|
buildSettings.TARGETED_DEVICE_FAMILY = deviceFamilies;
|
|
42
|
-
buildSettings.IOS_DEPLOYMENT_TARGET =
|
|
43
|
-
buildSettings.SDKROOT =
|
|
44
|
-
if (typeof buildSettings?.TVOS_DEPLOYMENT_TARGET !==
|
|
44
|
+
buildSettings.IOS_DEPLOYMENT_TARGET = deploymentTarget;
|
|
45
|
+
buildSettings.SDKROOT = 'iphoneos';
|
|
46
|
+
if (typeof buildSettings?.TVOS_DEPLOYMENT_TARGET !== 'undefined') {
|
|
45
47
|
delete buildSettings?.TVOS_DEPLOYMENT_TARGET;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -56,7 +58,7 @@ exports.setXcodeProjectBuildSettings = setXcodeProjectBuildSettings;
|
|
|
56
58
|
* @param deviceFamilies
|
|
57
59
|
*/
|
|
58
60
|
function formatDeviceFamilies(deviceFamilies) {
|
|
59
|
-
return `"${deviceFamilies.join(
|
|
61
|
+
return `"${deviceFamilies.join(',')}"`;
|
|
60
62
|
}
|
|
61
63
|
exports.formatDeviceFamilies = formatDeviceFamilies;
|
|
62
64
|
function getSupportsTablet(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-tvos/config-tv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Config plugin to reconfigure native directories for Apple TV and Android TV development if needed",
|
|
5
5
|
"main": "build/withTV.js",
|
|
6
6
|
"types": "build/withTV.d.ts",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/getenv": "^1.0.1",
|
|
41
|
-
"expo-module-scripts": "^3.0.3"
|
|
41
|
+
"expo-module-scripts": "^3.0.3",
|
|
42
|
+
"jest": "^29.7.0"
|
|
42
43
|
},
|
|
43
44
|
"upstreamPackage": "tv",
|
|
44
45
|
"dependencies": {
|