@bacons/apple-targets 0.1.3 → 0.1.5
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 +34 -0
- package/build/colorset/withIosColorset.d.ts +1 -1
- package/build/colorset/withIosColorset.js +1 -1
- package/build/config.d.ts +1 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +13 -1
- package/build/withXcodeChanges.js +9 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,6 +90,29 @@ module.exports = {
|
|
|
90
90
|
};
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
Finally, you can return a function that accepts the Expo Config and returns a target function for syncing app groups:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
/** @type {import('@bacons/apple-targets').ConfigFunction} */
|
|
97
|
+
module.exports = (config) => ({
|
|
98
|
+
type: "widget",
|
|
99
|
+
colors: {
|
|
100
|
+
$accent: "steelblue",
|
|
101
|
+
},
|
|
102
|
+
entitlements: {
|
|
103
|
+
// Use the same app groups:
|
|
104
|
+
"com.apple.security.application-groups":
|
|
105
|
+
config.ios.entitlements["com.apple.security.application-groups"],
|
|
106
|
+
// Or generate an app group:
|
|
107
|
+
"com.apple.security.application-groups": [
|
|
108
|
+
`group.${config.ios.bundleIdentifier}.widget`,
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> ESM and TypeScript are not supported in the target config. Stick to `require` for sharing variables across targets.
|
|
115
|
+
|
|
93
116
|
## Colors
|
|
94
117
|
|
|
95
118
|
There are certain values that are shared across targets. We use a predefined convention to map these values across targets.
|
|
@@ -278,3 +301,14 @@ You can also manually sign all sub-targets if you want, I'll light a candle for
|
|
|
278
301
|
## Xcode parsing
|
|
279
302
|
|
|
280
303
|
This plugin makes use of my proprietary Xcode parsing library, [`@bacons/xcode`](https://github.com/evanbacon/xcode). It's mostly typed, very untested, and possibly full of bugs––however, it's still 10x nicer than the alternative.
|
|
304
|
+
|
|
305
|
+
## Building Widgets
|
|
306
|
+
|
|
307
|
+
I've written a blog post about building widgets with this plugin: [Expo x Apple Widgets](https://evanbacon.dev/blog/apple-home-screen-widgets).
|
|
308
|
+
|
|
309
|
+
If you experience issues building widgets, it might be because React Native is shipped uncompiled which makes the build complexity much higher. This often leads to issues with the Swift compiler and SwiftUI previews.
|
|
310
|
+
|
|
311
|
+
Some workarounds:
|
|
312
|
+
|
|
313
|
+
- Prebuild without React Native: `npx expo prebuild --template node_modules/@bacons/apple-targets/prebuild-blank.tgz --clean`
|
|
314
|
+
- If the widget doesn't show on the home screen when building the app, use iOS 18. You can long press the app icon and select the widget display options to transform the app icon into the widget.
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.setColorAsync = exports.withIosColorset = void 0;
|
|
7
|
-
const config_plugins_1 = require("
|
|
7
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const customColorFromCSS_1 = require("./customColorFromCSS");
|
package/build/config.d.ts
CHANGED
|
@@ -109,3 +109,4 @@ export type Config = {
|
|
|
109
109
|
/** Should the release build export the JS bundle and embed. Intended for App Clips and Share Extensions where you may want to use React Native. */
|
|
110
110
|
exportJs?: boolean;
|
|
111
111
|
};
|
|
112
|
+
export type ConfigFunction = (config: import("expo/config").ExpoConfig) => Config;
|
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
-
import type { Config } from "./config";
|
|
2
|
+
import type { Config, ConfigFunction } from "./config";
|
|
3
3
|
export declare const withTargetsDir: ConfigPlugin<{
|
|
4
4
|
appleTeamId?: string;
|
|
5
5
|
match?: string;
|
|
6
6
|
root?: string;
|
|
7
7
|
} | void>;
|
|
8
|
-
export { Config };
|
|
8
|
+
export { Config, ConfigFunction };
|
package/build/index.js
CHANGED
|
@@ -22,9 +22,21 @@ const withTargetsDir = (config, _props) => {
|
|
|
22
22
|
absolute: true,
|
|
23
23
|
});
|
|
24
24
|
targets.forEach((configPath) => {
|
|
25
|
+
const targetConfig = require(configPath);
|
|
26
|
+
let evaluatedTargetConfigObject = targetConfig;
|
|
27
|
+
// If it's a function, evaluate it
|
|
28
|
+
if (typeof targetConfig === "function") {
|
|
29
|
+
evaluatedTargetConfigObject = targetConfig(config);
|
|
30
|
+
if (typeof evaluatedTargetConfigObject !== "object") {
|
|
31
|
+
throw new Error(`Expected target config function to return an object, but got ${typeof evaluatedTargetConfigObject}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (typeof targetConfig !== "object") {
|
|
35
|
+
throw new Error(`Expected target config to be an object or function that returns an object, but got ${typeof targetConfig}`);
|
|
36
|
+
}
|
|
25
37
|
config = (0, withWidget_1.default)(config, {
|
|
26
38
|
appleTeamId,
|
|
27
|
-
...
|
|
39
|
+
...evaluatedTargetConfigObject,
|
|
28
40
|
directory: path_1.default.relative(projectRoot, path_1.default.dirname(configPath)),
|
|
29
41
|
configPath,
|
|
30
42
|
});
|
|
@@ -821,18 +821,16 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
821
821
|
extensionTarget.getSourcesBuildPhase();
|
|
822
822
|
extensionTarget.getResourcesBuildPhase();
|
|
823
823
|
configureJsExport(extensionTarget);
|
|
824
|
-
const containerItemProxy = xcode_1.PBXContainerItemProxy.create(project, {
|
|
825
|
-
containerPortal: project.rootObject,
|
|
826
|
-
proxyType: 1,
|
|
827
|
-
remoteGlobalIDString: extensionTarget.uuid,
|
|
828
|
-
remoteInfo: productName,
|
|
829
|
-
});
|
|
830
|
-
const targetDependency = xcode_1.PBXTargetDependency.create(project, {
|
|
831
|
-
target: extensionTarget,
|
|
832
|
-
targetProxy: containerItemProxy,
|
|
833
|
-
});
|
|
834
824
|
// Add the target dependency to the main app, should be only one.
|
|
835
|
-
mainAppTarget.props.dependencies.push(
|
|
825
|
+
mainAppTarget.props.dependencies.push(xcode_1.PBXTargetDependency.create(project, {
|
|
826
|
+
target: extensionTarget,
|
|
827
|
+
targetProxy: xcode_1.PBXContainerItemProxy.create(project, {
|
|
828
|
+
containerPortal: project.rootObject,
|
|
829
|
+
proxyType: 1,
|
|
830
|
+
remoteGlobalIDString: extensionTarget.uuid,
|
|
831
|
+
remoteInfo: productName,
|
|
832
|
+
}),
|
|
833
|
+
}));
|
|
836
834
|
const WELL_KNOWN_COPY_EXTENSIONS_NAME = (() => {
|
|
837
835
|
switch (props.type) {
|
|
838
836
|
case "clip":
|