Skip to content

Commit 281a1dc

Browse files
committed
Internalize config plugin
1 parent 39def78 commit 281a1dc

File tree

13 files changed

+966
-643
lines changed

13 files changed

+966
-643
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-device-activity
22

3-
Provide access to Apples DeviceActivity API
3+
Provides access to Apples DeviceActivity API. It does require a Custom Dev Client to work with Expo.
44

55
# API documentation
66

@@ -11,6 +11,26 @@ Provide access to Apples DeviceActivity API
1111

1212
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
1313

14+
The package requires native code, which includes a custom app target. Currently it requires targeting iOS 15 or higher, so populate app.json/app.config.json as follows:
15+
```
16+
"plugins": [
17+
[
18+
"expo-build-properties",
19+
{
20+
"ios": {
21+
"deploymentTarget": "15.0"
22+
},
23+
},
24+
],
25+
[
26+
"../app.plugin.js",
27+
{
28+
"appleTeamId": "34SE8X7Q58"
29+
},
30+
]
31+
],
32+
```
33+
1434
# Installation in bare React Native projects
1535

1636
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.

app.plugin.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/** @type {import('@kingstinct/expo-apple-targets/target-plugin/config').Config} */
2+
const withTargetPlugin =
3+
require("@kingstinct/expo-apple-targets/target-plugin/build").default;
4+
const { createRunOncePlugin } = require("expo/config-plugins");
5+
const fs = require("fs");
6+
7+
const pkg = require("./package.json");
8+
9+
/** @type {import('@expo/config-plugins').ConfigPlugin} */
10+
const withCopyTargetFolder = (config) => {
11+
const projectRoot = config._internal.projectRoot;
12+
// eslint-disable-next-line no-undef
13+
const packageTargetFolderPath = __dirname + "/targets";
14+
const projectTargetFolderPath = projectRoot + "/targets";
15+
16+
if (!fs.existsSync(projectTargetFolderPath)) {
17+
fs.mkdirSync(projectTargetFolderPath);
18+
}
19+
20+
fs.cpSync(packageTargetFolderPath, projectTargetFolderPath, {
21+
recursive: true,
22+
});
23+
24+
return config;
25+
};
26+
27+
/** @type {import('@expo/config-plugins').ConfigPlugin<{ appleTeamId: string; match?: string; }>} */
28+
const withActivityMonitorExtensionPlugin = (config, props) => {
29+
return withCopyTargetFolder(withTargetPlugin(config, props));
30+
};
31+
32+
module.exports = createRunOncePlugin(
33+
withActivityMonitorExtensionPlugin,
34+
pkg.name,
35+
pkg.version
36+
);

example/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
],
4444
[
45-
"@kingstinct/expo-apple-targets/app.plugin.js",
45+
"../app.plugin.js",
4646
{
4747
"appleTeamId": "34SE8X7Q58"
4848
},

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PODS:
99
- ExpoModulesCore
1010
- EXFont (11.1.1):
1111
- ExpoModulesCore
12-
- Expo (48.0.19):
12+
- Expo (48.0.20):
1313
- ExpoModulesCore
1414
- ExpoKeepAwake (12.0.1):
1515
- ExpoModulesCore
@@ -520,7 +520,7 @@ SPEC CHECKSUMS:
520520
EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9
521521
EXFileSystem: 844e86ca9b5375486ecc4ef06d3838d5597d895d
522522
EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272
523-
Expo: 8448e3a2aa1b295f029c81551e1ab6d986517fdb
523+
Expo: b7d2843b0a0027d0ce76121a63085764355a16ed
524524
ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a
525525
ExpoModulesCore: 653958063a301098b541ae4dfed1ac0b98db607b
526526
EXSplashScreen: 0e0a9ba0cf7553094e93213099bd7b42e6e237e9

0 commit comments

Comments
 (0)