expo-build-properties 0.4.1 → 0.5.1
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/CHANGELOG.md +13 -1
- package/README.md +6 -4
- package/build/android.d.ts +1 -0
- package/build/android.js +30 -1
- package/build/ios.js +13 -0
- package/build/pluginConfig.d.ts +85 -20
- package/build/pluginConfig.js +20 -5
- package/build/withBuildProperties.d.ts +4 -5
- package/build/withBuildProperties.js +4 -4
- package/package.json +2 -5
- package/src/android.ts +46 -1
- package/src/ios.ts +13 -0
- package/src/pluginConfig.ts +111 -35
- package/src/withBuildProperties.ts +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 0.
|
|
13
|
+
## 0.5.1 — 2023-02-09
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Add support for enabling [Flipper](https://fbflipper.com/) as bundled with react-native. ([#20890](https://github.com/expo/expo/pull/20861) by [@jakobo](https://github.com/jakobo))
|
|
18
|
+
|
|
19
|
+
## 0.5.0 — 2023-02-03
|
|
20
|
+
|
|
21
|
+
### 🎉 New features
|
|
22
|
+
|
|
23
|
+
- Add support for enabling [React Native new architecture mode](https://reactnative.dev/docs/new-architecture-intro). ([#20861](https://github.com/expo/expo/pull/20861) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
|
24
|
+
|
|
25
|
+
## 0.4.1 - 2022-11-24
|
|
14
26
|
|
|
15
27
|
### 🐛 Bug fixes
|
|
16
28
|
|
package/README.md
CHANGED
|
@@ -27,10 +27,12 @@ Add plugin to `app.json`. For example:
|
|
|
27
27
|
"android": {
|
|
28
28
|
"compileSdkVersion": 31,
|
|
29
29
|
"targetSdkVersion": 31,
|
|
30
|
-
"buildToolsVersion": "31.0.0"
|
|
30
|
+
"buildToolsVersion": "31.0.0",
|
|
31
|
+
"flipper": true
|
|
31
32
|
},
|
|
32
33
|
"ios": {
|
|
33
|
-
"deploymentTarget": "13.0"
|
|
34
|
+
"deploymentTarget": "13.0",
|
|
35
|
+
"flipper": true
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
]
|
|
@@ -41,9 +43,9 @@ Add plugin to `app.json`. For example:
|
|
|
41
43
|
|
|
42
44
|
## Contributing
|
|
43
45
|
|
|
44
|
-
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][contributing].
|
|
46
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][../../contributing.md].
|
|
45
47
|
|
|
46
|
-
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/build-properties.
|
|
48
|
+
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/build-properties.mdx
|
|
47
49
|
[docs-stable]: https://docs.expo.dev/versions/latest/sdk/build-properties/
|
|
48
50
|
[contributing]: https://github.com/expo/expo#contributing
|
|
49
51
|
[config-plugins]: https://docs.expo.dev/guides/config-plugins/
|
package/build/android.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
import type { PluginConfigType } from './pluginConfig';
|
|
3
3
|
export declare const withAndroidBuildProperties: ConfigPlugin<PluginConfigType>;
|
|
4
|
+
export declare const withAndroidFlipper: ConfigPlugin<PluginConfigType>;
|
|
4
5
|
/**
|
|
5
6
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
6
7
|
*/
|
package/build/android.js
CHANGED
|
@@ -3,13 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.updateAndroidProguardRules = exports.withAndroidPurgeProguardRulesOnce = exports.withAndroidProguardRules = exports.withAndroidBuildProperties = void 0;
|
|
6
|
+
exports.updateAndroidProguardRules = exports.withAndroidPurgeProguardRulesOnce = exports.withAndroidProguardRules = exports.withAndroidFlipper = exports.withAndroidBuildProperties = void 0;
|
|
7
7
|
const config_plugins_1 = require("expo/config-plugins");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const fileContentsUtils_1 = require("./fileContentsUtils");
|
|
11
11
|
const { createBuildGradlePropsConfigPlugin } = config_plugins_1.AndroidConfig.BuildProperties;
|
|
12
12
|
exports.withAndroidBuildProperties = createBuildGradlePropsConfigPlugin([
|
|
13
|
+
{
|
|
14
|
+
propName: 'newArchEnabled',
|
|
15
|
+
propValueGetter: (config) => config.android?.newArchEnabled?.toString(),
|
|
16
|
+
},
|
|
13
17
|
{
|
|
14
18
|
propName: 'android.minSdkVersion',
|
|
15
19
|
propValueGetter: (config) => config.android?.minSdkVersion?.toString(),
|
|
@@ -51,6 +55,31 @@ exports.withAndroidBuildProperties = createBuildGradlePropsConfigPlugin([
|
|
|
51
55
|
propValueGetter: (config) => config.android?.enableProguardInReleaseBuilds?.toString(),
|
|
52
56
|
},
|
|
53
57
|
], 'withAndroidBuildProperties');
|
|
58
|
+
const withAndroidFlipper = (config, props) => {
|
|
59
|
+
const ANDROID_FLIPPER_KEY = 'FLIPPER_VERSION';
|
|
60
|
+
const FLIPPER_FALLBACK = '0.125.0';
|
|
61
|
+
// when not set, make no changes
|
|
62
|
+
if (props.android?.flipper === undefined) {
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
return (0, config_plugins_1.withGradleProperties)(config, (c) => {
|
|
66
|
+
// check for Flipper version in package. If set, use that
|
|
67
|
+
let existing;
|
|
68
|
+
const found = c.modResults.find((item) => item.type === 'property' && item.key === ANDROID_FLIPPER_KEY);
|
|
69
|
+
if (found && found.type === 'property') {
|
|
70
|
+
existing = found.value;
|
|
71
|
+
}
|
|
72
|
+
// strip key and re-add based on setting
|
|
73
|
+
c.modResults = c.modResults.filter((item) => !(item.type === 'property' && item.key === ANDROID_FLIPPER_KEY));
|
|
74
|
+
c.modResults.push({
|
|
75
|
+
type: 'property',
|
|
76
|
+
key: ANDROID_FLIPPER_KEY,
|
|
77
|
+
value: (props.android?.flipper ?? existing ?? FLIPPER_FALLBACK),
|
|
78
|
+
});
|
|
79
|
+
return c;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.withAndroidFlipper = withAndroidFlipper;
|
|
54
83
|
/**
|
|
55
84
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
56
85
|
*/
|
package/build/ios.js
CHANGED
|
@@ -4,10 +4,23 @@ exports.withIosDeploymentTarget = exports.withIosBuildProperties = void 0;
|
|
|
4
4
|
const config_plugins_1 = require("expo/config-plugins");
|
|
5
5
|
const { createBuildPodfilePropsConfigPlugin } = config_plugins_1.IOSConfig.BuildProperties;
|
|
6
6
|
exports.withIosBuildProperties = createBuildPodfilePropsConfigPlugin([
|
|
7
|
+
{
|
|
8
|
+
propName: 'newArchEnabled',
|
|
9
|
+
propValueGetter: (config) => config.ios?.newArchEnabled?.toString(),
|
|
10
|
+
},
|
|
7
11
|
{
|
|
8
12
|
propName: 'ios.useFrameworks',
|
|
9
13
|
propValueGetter: (config) => config.ios?.useFrameworks,
|
|
10
14
|
},
|
|
15
|
+
{
|
|
16
|
+
propName: 'ios.flipper',
|
|
17
|
+
propValueGetter: (config) => {
|
|
18
|
+
if (typeof config.ios?.flipper === 'string' || typeof config.ios?.flipper === 'boolean') {
|
|
19
|
+
return config.ios.flipper.toString();
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
},
|
|
23
|
+
},
|
|
11
24
|
], 'withIosBuildProperties');
|
|
12
25
|
const withIosDeploymentTarget = (config, props) => {
|
|
13
26
|
const deploymentTarget = props.ios?.deploymentTarget;
|
package/build/pluginConfig.d.ts
CHANGED
|
@@ -1,55 +1,120 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Interface representing base build properties configuration.
|
|
3
3
|
*/
|
|
4
4
|
export interface PluginConfigType {
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing available configuration for Android native build properties.
|
|
7
|
+
* @platform android
|
|
8
|
+
*/
|
|
5
9
|
android?: PluginConfigTypeAndroid;
|
|
10
|
+
/**
|
|
11
|
+
* Interface representing available configuration for iOS native build properties.
|
|
12
|
+
* @platform ios
|
|
13
|
+
*/
|
|
6
14
|
ios?: PluginConfigTypeIos;
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
*
|
|
17
|
+
* Interface representing available configuration for Android native build properties.
|
|
18
|
+
* @platform android
|
|
10
19
|
*/
|
|
11
20
|
export interface PluginConfigTypeAndroid {
|
|
12
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Enable React Native new architecture for Android platform.
|
|
23
|
+
*/
|
|
24
|
+
newArchEnabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Override the default `minSdkVersion` version number in **build.gradle**.
|
|
27
|
+
* */
|
|
13
28
|
minSdkVersion?: number;
|
|
14
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Override the default `compileSdkVersion` version number in **build.gradle**.
|
|
31
|
+
*/
|
|
15
32
|
compileSdkVersion?: number;
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Override the default `targetSdkVersion` version number in **build.gradle**.
|
|
35
|
+
*/
|
|
17
36
|
targetSdkVersion?: number;
|
|
18
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Override the default `buildToolsVersion` version number in **build.gradle**.
|
|
39
|
+
*/
|
|
19
40
|
buildToolsVersion?: string;
|
|
20
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Override the Kotlin version used when building the app.
|
|
43
|
+
*/
|
|
21
44
|
kotlinVersion?: string;
|
|
22
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Enable [Proguard or R8](https://developer.android.com/studio/build/shrink-code) in release builds to obfuscate Java code and reduce app size.
|
|
47
|
+
*/
|
|
23
48
|
enableProguardInReleaseBuilds?: boolean;
|
|
24
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Append custom [Proguard rules](https://www.guardsquare.com/manual/configuration/usage) to **android/app/proguard-rules.pro**.
|
|
51
|
+
*/
|
|
25
52
|
extraProguardRules?: string;
|
|
26
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Interface representing available configuration for Android Gradle plugin [PackagingOptions](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/PackagingOptions).
|
|
55
|
+
*/
|
|
27
56
|
packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
|
|
59
|
+
* Flipper is by default enabled with the version that comes bundled with react-native.
|
|
60
|
+
* However, you can set the `flipper` property to a semver string and specify an
|
|
61
|
+
* alternate Flipper version.
|
|
62
|
+
*/
|
|
63
|
+
flipper?: string;
|
|
28
64
|
}
|
|
29
65
|
/**
|
|
30
|
-
*
|
|
66
|
+
* Interface representing available configuration for iOS native build properties.
|
|
67
|
+
* @platform ios
|
|
31
68
|
*/
|
|
32
69
|
export interface PluginConfigTypeIos {
|
|
33
70
|
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
71
|
+
* Enable React Native new architecture for iOS platform.
|
|
72
|
+
*/
|
|
73
|
+
newArchEnabled?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Override the default iOS "Deployment Target" version in the following projects:
|
|
76
|
+
* - in CocoaPods projects,
|
|
77
|
+
* - `PBXNativeTarget` with "com.apple.product-type.application" `productType` in the app project.
|
|
37
78
|
*/
|
|
38
79
|
deploymentTarget?: string;
|
|
39
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
|
|
82
|
+
* in `Podfile` to use frameworks instead of static libraries for Pods.
|
|
83
|
+
*
|
|
84
|
+
* Note: You cannot use `useFrameworks` and `flipper` at the same time
|
|
85
|
+
*/
|
|
40
86
|
useFrameworks?: 'static' | 'dynamic';
|
|
87
|
+
/**
|
|
88
|
+
* Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
|
|
89
|
+
* Debug mode. Setting `true` enables the default version of Flipper, while
|
|
90
|
+
* setting a semver string will enable a specific version of Flipper you've
|
|
91
|
+
* declared in your package.json. The default for this configuration is `false`.
|
|
92
|
+
*
|
|
93
|
+
* Note: You cannot use `flipper` at the same time as `useFrameworks`, and
|
|
94
|
+
* doing so will generate an error.
|
|
95
|
+
*/
|
|
96
|
+
flipper?: boolean | string;
|
|
41
97
|
}
|
|
42
98
|
/**
|
|
43
|
-
*
|
|
99
|
+
* Interface representing available configuration for Android Gradle plugin [PackagingOptions](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/PackagingOptions).
|
|
100
|
+
* @platform android
|
|
44
101
|
*/
|
|
45
102
|
export interface PluginConfigTypeAndroidPackagingOptions {
|
|
46
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Array of patterns for native libraries where only the first occurrence is packaged in the APK.
|
|
105
|
+
*/
|
|
47
106
|
pickFirst?: string[];
|
|
48
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Array of patterns for native libraries that should be excluded from being packaged in the APK.
|
|
109
|
+
*/
|
|
49
110
|
exclude?: string[];
|
|
50
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Array of patterns for native libraries where all occurrences are concatenated and packaged in the APK.
|
|
113
|
+
*/
|
|
51
114
|
merge?: string[];
|
|
52
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Array of patterns for native libraries that should not be stripped of debug symbols.
|
|
117
|
+
*/
|
|
53
118
|
doNotStrip?: string[];
|
|
54
119
|
}
|
|
55
120
|
/**
|
package/build/pluginConfig.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.validateConfig = void 0;
|
|
|
7
7
|
const ajv_1 = __importDefault(require("ajv"));
|
|
8
8
|
const semver_1 = __importDefault(require("semver"));
|
|
9
9
|
/**
|
|
10
|
-
* The minimal supported versions. These values should align to SDK
|
|
10
|
+
* The minimal supported versions. These values should align to SDK.
|
|
11
11
|
* @ignore
|
|
12
12
|
*/
|
|
13
13
|
const EXPO_SDK_MINIMAL_SUPPORTED_VERSIONS = {
|
|
@@ -27,6 +27,7 @@ const schema = {
|
|
|
27
27
|
android: {
|
|
28
28
|
type: 'object',
|
|
29
29
|
properties: {
|
|
30
|
+
newArchEnabled: { type: 'boolean', nullable: true },
|
|
30
31
|
minSdkVersion: { type: 'integer', nullable: true },
|
|
31
32
|
compileSdkVersion: { type: 'integer', nullable: true },
|
|
32
33
|
targetSdkVersion: { type: 'integer', nullable: true },
|
|
@@ -34,6 +35,10 @@ const schema = {
|
|
|
34
35
|
kotlinVersion: { type: 'string', nullable: true },
|
|
35
36
|
enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
|
|
36
37
|
extraProguardRules: { type: 'string', nullable: true },
|
|
38
|
+
flipper: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
nullable: true,
|
|
41
|
+
},
|
|
37
42
|
packagingOptions: {
|
|
38
43
|
type: 'object',
|
|
39
44
|
properties: {
|
|
@@ -50,19 +55,24 @@ const schema = {
|
|
|
50
55
|
ios: {
|
|
51
56
|
type: 'object',
|
|
52
57
|
properties: {
|
|
58
|
+
newArchEnabled: { type: 'boolean', nullable: true },
|
|
53
59
|
deploymentTarget: { type: 'string', pattern: '\\d+\\.\\d+', nullable: true },
|
|
54
60
|
useFrameworks: { type: 'string', enum: ['static', 'dynamic'], nullable: true },
|
|
61
|
+
flipper: {
|
|
62
|
+
type: ['boolean', 'string'],
|
|
63
|
+
nullable: true,
|
|
64
|
+
},
|
|
55
65
|
},
|
|
56
66
|
nullable: true,
|
|
57
67
|
},
|
|
58
68
|
},
|
|
59
69
|
};
|
|
70
|
+
// note(Kudo): For the implementation, we check items one by one because Ajv does not well support custom error message.
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
72
|
+
* Checks if specified versions meets Expo minimal supported versions.
|
|
62
73
|
* Will throw error message whenever there are invalid versions.
|
|
63
|
-
* For the implementation, we check items one by one because ajv does not well support custom error message.
|
|
64
74
|
*
|
|
65
|
-
* @param config
|
|
75
|
+
* @param config The validated config passed from Ajv.
|
|
66
76
|
* @ignore
|
|
67
77
|
*/
|
|
68
78
|
function maybeThrowInvalidVersions(config) {
|
|
@@ -110,11 +120,16 @@ function maybeThrowInvalidVersions(config) {
|
|
|
110
120
|
* @ignore
|
|
111
121
|
*/
|
|
112
122
|
function validateConfig(config) {
|
|
113
|
-
const validate = new ajv_1.default().compile(schema);
|
|
123
|
+
const validate = new ajv_1.default({ allowUnionTypes: true }).compile(schema);
|
|
114
124
|
if (!validate(config)) {
|
|
115
125
|
throw new Error('Invalid expo-build-properties config: ' + JSON.stringify(validate.errors));
|
|
116
126
|
}
|
|
117
127
|
maybeThrowInvalidVersions(config);
|
|
128
|
+
// explicitly block using use_frameworks and Flipper in iOS
|
|
129
|
+
// https://github.com/facebook/flipper/issues/2414
|
|
130
|
+
if (config?.ios?.flipper !== undefined && config?.ios?.useFrameworks !== undefined) {
|
|
131
|
+
throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
|
|
132
|
+
}
|
|
118
133
|
return config;
|
|
119
134
|
}
|
|
120
135
|
exports.validateConfig = validateConfig;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
import { PluginConfigType } from './pluginConfig';
|
|
3
3
|
/**
|
|
4
|
-
* Config plugin
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param props Configuration for the config plugin
|
|
4
|
+
* Config plugin allowing customizing native Android and iOS build properties for managed apps.
|
|
5
|
+
* @param config Expo config for application.
|
|
6
|
+
* @param props Configuration for the build properties plugin.
|
|
8
7
|
*/
|
|
9
8
|
export declare const withBuildProperties: ConfigPlugin<PluginConfigType>;
|
|
10
9
|
export default withBuildProperties;
|
|
@@ -5,10 +5,9 @@ const android_1 = require("./android");
|
|
|
5
5
|
const ios_1 = require("./ios");
|
|
6
6
|
const pluginConfig_1 = require("./pluginConfig");
|
|
7
7
|
/**
|
|
8
|
-
* Config plugin
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param props Configuration for the config plugin
|
|
8
|
+
* Config plugin allowing customizing native Android and iOS build properties for managed apps.
|
|
9
|
+
* @param config Expo config for application.
|
|
10
|
+
* @param props Configuration for the build properties plugin.
|
|
12
11
|
*/
|
|
13
12
|
const withBuildProperties = (config, props) => {
|
|
14
13
|
const pluginConfig = (0, pluginConfig_1.validateConfig)(props || {});
|
|
@@ -21,6 +20,7 @@ const withBuildProperties = (config, props) => {
|
|
|
21
20
|
//
|
|
22
21
|
// plugins order matter: the later one would run first
|
|
23
22
|
config = (0, android_1.withAndroidPurgeProguardRulesOnce)(config);
|
|
23
|
+
config = (0, android_1.withAndroidFlipper)(config, pluginConfig);
|
|
24
24
|
config = (0, ios_1.withIosBuildProperties)(config, pluginConfig);
|
|
25
25
|
config = (0, ios_1.withIosDeploymentTarget)(config, pluginConfig);
|
|
26
26
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-build-properties",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Config plugin to customize native build properties on prebuild",
|
|
5
5
|
"main": "build/withBuildProperties.js",
|
|
6
6
|
"types": "build/withBuildProperties.d.ts",
|
|
@@ -37,11 +37,8 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"expo-module-scripts": "^3.0.0"
|
|
39
39
|
},
|
|
40
|
-
"jest": {
|
|
41
|
-
"preset": "expo-module-scripts"
|
|
42
|
-
},
|
|
43
40
|
"peerDependencies": {
|
|
44
41
|
"expo": "*"
|
|
45
42
|
},
|
|
46
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
|
|
47
44
|
}
|
package/src/android.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AndroidConfig,
|
|
3
|
+
ConfigPlugin,
|
|
4
|
+
History,
|
|
5
|
+
withDangerousMod,
|
|
6
|
+
withGradleProperties,
|
|
7
|
+
} from 'expo/config-plugins';
|
|
2
8
|
import fs from 'fs';
|
|
3
9
|
import path from 'path';
|
|
4
10
|
|
|
@@ -9,6 +15,10 @@ const { createBuildGradlePropsConfigPlugin } = AndroidConfig.BuildProperties;
|
|
|
9
15
|
|
|
10
16
|
export const withAndroidBuildProperties = createBuildGradlePropsConfigPlugin<PluginConfigType>(
|
|
11
17
|
[
|
|
18
|
+
{
|
|
19
|
+
propName: 'newArchEnabled',
|
|
20
|
+
propValueGetter: (config) => config.android?.newArchEnabled?.toString(),
|
|
21
|
+
},
|
|
12
22
|
{
|
|
13
23
|
propName: 'android.minSdkVersion',
|
|
14
24
|
propValueGetter: (config) => config.android?.minSdkVersion?.toString(),
|
|
@@ -53,6 +63,41 @@ export const withAndroidBuildProperties = createBuildGradlePropsConfigPlugin<Plu
|
|
|
53
63
|
'withAndroidBuildProperties'
|
|
54
64
|
);
|
|
55
65
|
|
|
66
|
+
export const withAndroidFlipper: ConfigPlugin<PluginConfigType> = (config, props) => {
|
|
67
|
+
const ANDROID_FLIPPER_KEY = 'FLIPPER_VERSION';
|
|
68
|
+
const FLIPPER_FALLBACK = '0.125.0';
|
|
69
|
+
|
|
70
|
+
// when not set, make no changes
|
|
71
|
+
if (props.android?.flipper === undefined) {
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return withGradleProperties(config, (c) => {
|
|
76
|
+
// check for Flipper version in package. If set, use that
|
|
77
|
+
let existing: string | undefined;
|
|
78
|
+
|
|
79
|
+
const found = c.modResults.find(
|
|
80
|
+
(item) => item.type === 'property' && item.key === ANDROID_FLIPPER_KEY
|
|
81
|
+
);
|
|
82
|
+
if (found && found.type === 'property') {
|
|
83
|
+
existing = found.value;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// strip key and re-add based on setting
|
|
87
|
+
c.modResults = c.modResults.filter(
|
|
88
|
+
(item) => !(item.type === 'property' && item.key === ANDROID_FLIPPER_KEY)
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
c.modResults.push({
|
|
92
|
+
type: 'property',
|
|
93
|
+
key: ANDROID_FLIPPER_KEY,
|
|
94
|
+
value: (props.android?.flipper ?? existing ?? FLIPPER_FALLBACK) as string,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return c;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
56
101
|
/**
|
|
57
102
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
58
103
|
*/
|
package/src/ios.ts
CHANGED
|
@@ -6,10 +6,23 @@ const { createBuildPodfilePropsConfigPlugin } = IOSConfig.BuildProperties;
|
|
|
6
6
|
|
|
7
7
|
export const withIosBuildProperties = createBuildPodfilePropsConfigPlugin<PluginConfigType>(
|
|
8
8
|
[
|
|
9
|
+
{
|
|
10
|
+
propName: 'newArchEnabled',
|
|
11
|
+
propValueGetter: (config) => config.ios?.newArchEnabled?.toString(),
|
|
12
|
+
},
|
|
9
13
|
{
|
|
10
14
|
propName: 'ios.useFrameworks',
|
|
11
15
|
propValueGetter: (config) => config.ios?.useFrameworks,
|
|
12
16
|
},
|
|
17
|
+
{
|
|
18
|
+
propName: 'ios.flipper',
|
|
19
|
+
propValueGetter: (config) => {
|
|
20
|
+
if (typeof config.ios?.flipper === 'string' || typeof config.ios?.flipper === 'boolean') {
|
|
21
|
+
return config.ios.flipper.toString();
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
13
26
|
],
|
|
14
27
|
'withIosBuildProperties'
|
|
15
28
|
);
|
package/src/pluginConfig.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Ajv, { JSONSchemaType } from 'ajv';
|
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The minimal supported versions. These values should align to SDK
|
|
5
|
+
* The minimal supported versions. These values should align to SDK.
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
8
|
const EXPO_SDK_MINIMAL_SUPPORTED_VERSIONS = {
|
|
@@ -18,71 +18,128 @@ const EXPO_SDK_MINIMAL_SUPPORTED_VERSIONS = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Interface representing base build properties configuration.
|
|
22
22
|
*/
|
|
23
23
|
export interface PluginConfigType {
|
|
24
|
+
/**
|
|
25
|
+
* Interface representing available configuration for Android native build properties.
|
|
26
|
+
* @platform android
|
|
27
|
+
*/
|
|
24
28
|
android?: PluginConfigTypeAndroid;
|
|
29
|
+
/**
|
|
30
|
+
* Interface representing available configuration for iOS native build properties.
|
|
31
|
+
* @platform ios
|
|
32
|
+
*/
|
|
25
33
|
ios?: PluginConfigTypeIos;
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
/**
|
|
29
|
-
*
|
|
37
|
+
* Interface representing available configuration for Android native build properties.
|
|
38
|
+
* @platform android
|
|
30
39
|
*/
|
|
31
40
|
export interface PluginConfigTypeAndroid {
|
|
32
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Enable React Native new architecture for Android platform.
|
|
43
|
+
*/
|
|
44
|
+
newArchEnabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Override the default `minSdkVersion` version number in **build.gradle**.
|
|
47
|
+
* */
|
|
33
48
|
minSdkVersion?: number;
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Override the default `compileSdkVersion` version number in **build.gradle**.
|
|
51
|
+
*/
|
|
36
52
|
compileSdkVersion?: number;
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Override the default `targetSdkVersion` version number in **build.gradle**.
|
|
55
|
+
*/
|
|
39
56
|
targetSdkVersion?: number;
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Override the default `buildToolsVersion` version number in **build.gradle**.
|
|
59
|
+
*/
|
|
42
60
|
buildToolsVersion?: string;
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Override the Kotlin version used when building the app.
|
|
63
|
+
*/
|
|
45
64
|
kotlinVersion?: string;
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Enable [Proguard or R8](https://developer.android.com/studio/build/shrink-code) in release builds to obfuscate Java code and reduce app size.
|
|
67
|
+
*/
|
|
48
68
|
enableProguardInReleaseBuilds?: boolean;
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Append custom [Proguard rules](https://www.guardsquare.com/manual/configuration/usage) to **android/app/proguard-rules.pro**.
|
|
71
|
+
*/
|
|
51
72
|
extraProguardRules?: string;
|
|
52
|
-
|
|
53
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Interface representing available configuration for Android Gradle plugin [PackagingOptions](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/PackagingOptions).
|
|
75
|
+
*/
|
|
54
76
|
packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
|
|
80
|
+
* Flipper is by default enabled with the version that comes bundled with react-native.
|
|
81
|
+
* However, you can set the `flipper` property to a semver string and specify an
|
|
82
|
+
* alternate Flipper version.
|
|
83
|
+
*/
|
|
84
|
+
flipper?: string;
|
|
55
85
|
}
|
|
56
86
|
|
|
57
87
|
/**
|
|
58
|
-
*
|
|
88
|
+
* Interface representing available configuration for iOS native build properties.
|
|
89
|
+
* @platform ios
|
|
59
90
|
*/
|
|
60
91
|
export interface PluginConfigTypeIos {
|
|
61
92
|
/**
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
* Enable React Native new architecture for iOS platform.
|
|
94
|
+
*/
|
|
95
|
+
newArchEnabled?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Override the default iOS "Deployment Target" version in the following projects:
|
|
98
|
+
* - in CocoaPods projects,
|
|
99
|
+
* - `PBXNativeTarget` with "com.apple.product-type.application" `productType` in the app project.
|
|
65
100
|
*/
|
|
66
101
|
deploymentTarget?: string;
|
|
67
102
|
|
|
68
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
|
|
105
|
+
* in `Podfile` to use frameworks instead of static libraries for Pods.
|
|
106
|
+
*
|
|
107
|
+
* Note: You cannot use `useFrameworks` and `flipper` at the same time
|
|
108
|
+
*/
|
|
69
109
|
useFrameworks?: 'static' | 'dynamic';
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
|
|
113
|
+
* Debug mode. Setting `true` enables the default version of Flipper, while
|
|
114
|
+
* setting a semver string will enable a specific version of Flipper you've
|
|
115
|
+
* declared in your package.json. The default for this configuration is `false`.
|
|
116
|
+
*
|
|
117
|
+
* Note: You cannot use `flipper` at the same time as `useFrameworks`, and
|
|
118
|
+
* doing so will generate an error.
|
|
119
|
+
*/
|
|
120
|
+
flipper?: boolean | string;
|
|
70
121
|
}
|
|
71
122
|
|
|
72
123
|
/**
|
|
73
|
-
*
|
|
124
|
+
* Interface representing available configuration for Android Gradle plugin [PackagingOptions](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/PackagingOptions).
|
|
125
|
+
* @platform android
|
|
74
126
|
*/
|
|
75
127
|
export interface PluginConfigTypeAndroidPackagingOptions {
|
|
76
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Array of patterns for native libraries where only the first occurrence is packaged in the APK.
|
|
130
|
+
*/
|
|
77
131
|
pickFirst?: string[];
|
|
78
|
-
|
|
79
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Array of patterns for native libraries that should be excluded from being packaged in the APK.
|
|
134
|
+
*/
|
|
80
135
|
exclude?: string[];
|
|
81
|
-
|
|
82
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Array of patterns for native libraries where all occurrences are concatenated and packaged in the APK.
|
|
138
|
+
*/
|
|
83
139
|
merge?: string[];
|
|
84
|
-
|
|
85
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Array of patterns for native libraries that should not be stripped of debug symbols.
|
|
142
|
+
*/
|
|
86
143
|
doNotStrip?: string[];
|
|
87
144
|
}
|
|
88
145
|
|
|
@@ -92,6 +149,7 @@ const schema: JSONSchemaType<PluginConfigType> = {
|
|
|
92
149
|
android: {
|
|
93
150
|
type: 'object',
|
|
94
151
|
properties: {
|
|
152
|
+
newArchEnabled: { type: 'boolean', nullable: true },
|
|
95
153
|
minSdkVersion: { type: 'integer', nullable: true },
|
|
96
154
|
compileSdkVersion: { type: 'integer', nullable: true },
|
|
97
155
|
targetSdkVersion: { type: 'integer', nullable: true },
|
|
@@ -101,6 +159,11 @@ const schema: JSONSchemaType<PluginConfigType> = {
|
|
|
101
159
|
enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
|
|
102
160
|
extraProguardRules: { type: 'string', nullable: true },
|
|
103
161
|
|
|
162
|
+
flipper: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
nullable: true,
|
|
165
|
+
},
|
|
166
|
+
|
|
104
167
|
packagingOptions: {
|
|
105
168
|
type: 'object',
|
|
106
169
|
properties: {
|
|
@@ -117,20 +180,26 @@ const schema: JSONSchemaType<PluginConfigType> = {
|
|
|
117
180
|
ios: {
|
|
118
181
|
type: 'object',
|
|
119
182
|
properties: {
|
|
183
|
+
newArchEnabled: { type: 'boolean', nullable: true },
|
|
120
184
|
deploymentTarget: { type: 'string', pattern: '\\d+\\.\\d+', nullable: true },
|
|
121
185
|
useFrameworks: { type: 'string', enum: ['static', 'dynamic'], nullable: true },
|
|
186
|
+
|
|
187
|
+
flipper: {
|
|
188
|
+
type: ['boolean', 'string'],
|
|
189
|
+
nullable: true,
|
|
190
|
+
},
|
|
122
191
|
},
|
|
123
192
|
nullable: true,
|
|
124
193
|
},
|
|
125
194
|
},
|
|
126
195
|
};
|
|
127
196
|
|
|
197
|
+
// note(Kudo): For the implementation, we check items one by one because Ajv does not well support custom error message.
|
|
128
198
|
/**
|
|
129
|
-
*
|
|
199
|
+
* Checks if specified versions meets Expo minimal supported versions.
|
|
130
200
|
* Will throw error message whenever there are invalid versions.
|
|
131
|
-
* For the implementation, we check items one by one because ajv does not well support custom error message.
|
|
132
201
|
*
|
|
133
|
-
* @param config
|
|
202
|
+
* @param config The validated config passed from Ajv.
|
|
134
203
|
* @ignore
|
|
135
204
|
*/
|
|
136
205
|
function maybeThrowInvalidVersions(config: PluginConfigType) {
|
|
@@ -184,11 +253,18 @@ function maybeThrowInvalidVersions(config: PluginConfigType) {
|
|
|
184
253
|
* @ignore
|
|
185
254
|
*/
|
|
186
255
|
export function validateConfig(config: any): PluginConfigType {
|
|
187
|
-
const validate = new Ajv().compile(schema);
|
|
256
|
+
const validate = new Ajv({ allowUnionTypes: true }).compile(schema);
|
|
188
257
|
if (!validate(config)) {
|
|
189
258
|
throw new Error('Invalid expo-build-properties config: ' + JSON.stringify(validate.errors));
|
|
190
259
|
}
|
|
191
260
|
|
|
192
261
|
maybeThrowInvalidVersions(config);
|
|
262
|
+
|
|
263
|
+
// explicitly block using use_frameworks and Flipper in iOS
|
|
264
|
+
// https://github.com/facebook/flipper/issues/2414
|
|
265
|
+
if (config?.ios?.flipper !== undefined && config?.ios?.useFrameworks !== undefined) {
|
|
266
|
+
throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
|
|
267
|
+
}
|
|
268
|
+
|
|
193
269
|
return config;
|
|
194
270
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
withAndroidBuildProperties,
|
|
5
5
|
withAndroidProguardRules,
|
|
6
6
|
withAndroidPurgeProguardRulesOnce,
|
|
7
|
+
withAndroidFlipper,
|
|
7
8
|
} from './android';
|
|
8
9
|
import { withIosBuildProperties, withIosDeploymentTarget } from './ios';
|
|
9
10
|
import { PluginConfigType, validateConfig } from './pluginConfig';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Config plugin
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param props Configuration for the config plugin
|
|
13
|
+
* Config plugin allowing customizing native Android and iOS build properties for managed apps.
|
|
14
|
+
* @param config Expo config for application.
|
|
15
|
+
* @param props Configuration for the build properties plugin.
|
|
16
16
|
*/
|
|
17
17
|
export const withBuildProperties: ConfigPlugin<PluginConfigType> = (config, props) => {
|
|
18
18
|
const pluginConfig = validateConfig(props || {});
|
|
@@ -28,6 +28,7 @@ export const withBuildProperties: ConfigPlugin<PluginConfigType> = (config, prop
|
|
|
28
28
|
// plugins order matter: the later one would run first
|
|
29
29
|
config = withAndroidPurgeProguardRulesOnce(config);
|
|
30
30
|
|
|
31
|
+
config = withAndroidFlipper(config, pluginConfig);
|
|
31
32
|
config = withIosBuildProperties(config, pluginConfig);
|
|
32
33
|
config = withIosDeploymentTarget(config, pluginConfig);
|
|
33
34
|
|