@bacons/apple-targets 3.0.1 → 3.0.3
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
CHANGED
|
@@ -178,6 +178,8 @@ The name of the target must match the name of the target directory.
|
|
|
178
178
|
|
|
179
179
|
Some files are required to be linked to both your target and the main target. To support this, you can add a top-level `_shared` directory. Any file in this directory will be linked to both the main target and the sub-target. You'll need to re-run prebuild every time you add, rename, or remove a file in this directory.
|
|
180
180
|
|
|
181
|
+
You can additionally add a `_shared` directory inside of the root `targets/_shared` directory. This will link files to all targets in your project.
|
|
182
|
+
|
|
181
183
|
## `exportJs`
|
|
182
184
|
|
|
183
185
|
The `exportJs` option should be used when the target uses React Native (App Clip, Share extension). It works by linking the main target's `Bundle React Native code and images` build phase to the target. This will ensure that production builds (`Release`) bundle the main JS entry file with Metro, and embed the bundle/assets for offline use.
|
|
@@ -388,6 +390,7 @@ ExtensionStorage.reloadWidget();
|
|
|
388
390
|
|
|
389
391
|
- `set(key: string, value: string | number | Record<string, string | number> | Array<Record<string, string | number>> | undefined): void` - Sets a value in the shared storage for a given key. Setting `undefined` will remove the key.
|
|
390
392
|
- `ExtensionStorage.reloadWidget(name?: string): void` - A static method for reloading the widget. Behind the scenes, this calls `WidgetCenter.shared.reloadAllTimelines()`. If given a name, it will reload a specific widget using `WidgetCenter.shared.reloadTimelines(ofKind: timeline)`.
|
|
393
|
+
- `ExtensionStorage.reloadControls(name?: string): void` - A static method for reloading the controls. Behind the scenes, this calls `ControlCenter.shared.reloadAllControls(): void`. If given a name, it will reload a specific widget using `ControlCenter.shared.reloadControls(ofKind?: string): void`.
|
|
391
394
|
- `remove(key: string): void` - A method for removing the key from the shared storage.
|
|
392
395
|
- `get(key: string): string | null` - A static method for getting the value from the shared storage.
|
|
393
396
|
|
|
@@ -478,6 +481,14 @@ struct OpenAppIntent0: ControlConfigurationIntent {
|
|
|
478
481
|
|
|
479
482
|
You should copy the intents into your main `WidgetBundle` struct.
|
|
480
483
|
|
|
484
|
+
**Reloading Controls from Your App**
|
|
485
|
+
|
|
486
|
+
Changes in your app’s state may affect control displays. You can request a reload of specific controls or all controls using
|
|
487
|
+
|
|
488
|
+
```js
|
|
489
|
+
ExtensionStorage.reloadControls();
|
|
490
|
+
```
|
|
491
|
+
|
|
481
492
|
Custom images can be used but they must be SF Symbols, you can use a tool like [Create Custom Symbols](https://github.com/jaywcjlove/create-custom-symbols) to do this. Then simply add to the Assets.xcassets folder and reference it in the `Label`.
|
|
482
493
|
|
|
483
494
|
You can do a lot of things with Control Widgets like launching a custom UI instead of opening the app. This plugin should allow for most of these things to work.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare class ExtensionStorage {
|
|
2
2
|
private readonly appGroup;
|
|
3
3
|
static reloadWidget(name?: string): void;
|
|
4
|
+
static reloadControls(name?: string): void;
|
|
4
5
|
constructor(appGroup: string);
|
|
5
6
|
set(key: string, value?: string | number | Record<string, string | number> | Array<Record<string, string | number>>): void;
|
|
6
7
|
get(key: string): string | null;
|
|
@@ -7,9 +7,10 @@ const ExtensionStorageModule = (_a = expo === null || expo === void 0 ? void 0 :
|
|
|
7
7
|
const nativeModule = ExtensionStorageModule !== null && ExtensionStorageModule !== void 0 ? ExtensionStorageModule : {
|
|
8
8
|
setInt() { },
|
|
9
9
|
setString() { },
|
|
10
|
+
reloadWidget() { },
|
|
11
|
+
reloadControls() { },
|
|
10
12
|
setObject() { },
|
|
11
13
|
setArray() { },
|
|
12
|
-
reloadWidget() { },
|
|
13
14
|
get() { },
|
|
14
15
|
remove() { },
|
|
15
16
|
};
|
|
@@ -25,6 +26,9 @@ class ExtensionStorage {
|
|
|
25
26
|
static reloadWidget(name) {
|
|
26
27
|
nativeModule.reloadWidget(name);
|
|
27
28
|
}
|
|
29
|
+
static reloadControls(name) {
|
|
30
|
+
nativeModule.reloadControls(name);
|
|
31
|
+
}
|
|
28
32
|
constructor(appGroup) {
|
|
29
33
|
this.appGroup = appGroup;
|
|
30
34
|
}
|
|
@@ -877,6 +877,12 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
877
877
|
absolute: false,
|
|
878
878
|
cwd: magicCwd,
|
|
879
879
|
});
|
|
880
|
+
// Also look for global shared assets in the parent targets/_shared directory
|
|
881
|
+
const targetsDir = path_1.default.dirname(magicCwd);
|
|
882
|
+
const globalSharedAssets = (0, glob_1.globSync)("_shared/*", {
|
|
883
|
+
absolute: false,
|
|
884
|
+
cwd: targetsDir,
|
|
885
|
+
});
|
|
880
886
|
let syncRootGroup = protectedGroup.props.children.find((child) => child.props.path === path_1.default.basename(props.cwd));
|
|
881
887
|
if (!syncRootGroup) {
|
|
882
888
|
syncRootGroup = xcode_1.PBXFileSystemSynchronizedRootGroup.create(project, {
|
|
@@ -923,6 +929,84 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
923
929
|
// Remove the exception set if there are no shared assets.
|
|
924
930
|
existingExceptionSet === null || existingExceptionSet === void 0 ? void 0 : existingExceptionSet.removeFromProject();
|
|
925
931
|
}
|
|
932
|
+
function configureTargetWithGlobalSharedAssets(target) {
|
|
933
|
+
var _a;
|
|
934
|
+
var _b;
|
|
935
|
+
if (!globalSharedAssets.length)
|
|
936
|
+
return;
|
|
937
|
+
// Create or find the global shared synchronized root group
|
|
938
|
+
let globalSharedSyncGroup = protectedGroup.props.children.find((child) => child.props.path === "_shared" && child instanceof xcode_1.PBXFileSystemSynchronizedRootGroup);
|
|
939
|
+
if (!globalSharedSyncGroup) {
|
|
940
|
+
globalSharedSyncGroup = xcode_1.PBXFileSystemSynchronizedRootGroup.create(project, {
|
|
941
|
+
path: "_shared",
|
|
942
|
+
exceptions: [
|
|
943
|
+
// Create exception set for the main app target
|
|
944
|
+
xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet.create(project, {
|
|
945
|
+
target: mainAppTarget,
|
|
946
|
+
membershipExceptions: globalSharedAssets.sort(),
|
|
947
|
+
}),
|
|
948
|
+
// Create exception set for the extension target
|
|
949
|
+
xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet.create(project, {
|
|
950
|
+
target: target,
|
|
951
|
+
membershipExceptions: globalSharedAssets.sort(),
|
|
952
|
+
}),
|
|
953
|
+
],
|
|
954
|
+
explicitFileTypes: {},
|
|
955
|
+
explicitFolders: [],
|
|
956
|
+
sourceTree: "<group>",
|
|
957
|
+
});
|
|
958
|
+
// Add to both targets' fileSystemSynchronizedGroups
|
|
959
|
+
if (!mainAppTarget.props.fileSystemSynchronizedGroups) {
|
|
960
|
+
mainAppTarget.props.fileSystemSynchronizedGroups = [];
|
|
961
|
+
}
|
|
962
|
+
mainAppTarget.props.fileSystemSynchronizedGroups.push(globalSharedSyncGroup);
|
|
963
|
+
if (!target.props.fileSystemSynchronizedGroups) {
|
|
964
|
+
target.props.fileSystemSynchronizedGroups = [];
|
|
965
|
+
}
|
|
966
|
+
target.props.fileSystemSynchronizedGroups.push(globalSharedSyncGroup);
|
|
967
|
+
protectedGroup.props.children.push(globalSharedSyncGroup);
|
|
968
|
+
}
|
|
969
|
+
else {
|
|
970
|
+
// Update existing synchronized group with current global shared assets
|
|
971
|
+
(_a = (_b = globalSharedSyncGroup.props).exceptions) !== null && _a !== void 0 ? _a : (_b.exceptions = []);
|
|
972
|
+
// Update or create exception set for main app target
|
|
973
|
+
let mainAppExceptionSet = globalSharedSyncGroup.props.exceptions.find((exception) => exception instanceof xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet &&
|
|
974
|
+
exception.props.target === mainAppTarget);
|
|
975
|
+
if (!mainAppExceptionSet) {
|
|
976
|
+
mainAppExceptionSet = xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet.create(project, {
|
|
977
|
+
target: mainAppTarget,
|
|
978
|
+
membershipExceptions: globalSharedAssets.sort(),
|
|
979
|
+
});
|
|
980
|
+
globalSharedSyncGroup.props.exceptions.push(mainAppExceptionSet);
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
mainAppExceptionSet.props.membershipExceptions = globalSharedAssets.sort();
|
|
984
|
+
}
|
|
985
|
+
// Update or create exception set for extension target
|
|
986
|
+
let extensionExceptionSet = globalSharedSyncGroup.props.exceptions.find((exception) => exception instanceof xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet &&
|
|
987
|
+
exception.props.target === target);
|
|
988
|
+
if (!extensionExceptionSet) {
|
|
989
|
+
extensionExceptionSet = xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet.create(project, {
|
|
990
|
+
target: target,
|
|
991
|
+
membershipExceptions: globalSharedAssets.sort(),
|
|
992
|
+
});
|
|
993
|
+
globalSharedSyncGroup.props.exceptions.push(extensionExceptionSet);
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
extensionExceptionSet.props.membershipExceptions = globalSharedAssets.sort();
|
|
997
|
+
}
|
|
998
|
+
// Ensure the current target has the synchronized group in its fileSystemSynchronizedGroups
|
|
999
|
+
if (!target.props.fileSystemSynchronizedGroups) {
|
|
1000
|
+
target.props.fileSystemSynchronizedGroups = [];
|
|
1001
|
+
}
|
|
1002
|
+
// Check if this target already has the synchronized group
|
|
1003
|
+
const hasGroup = target.props.fileSystemSynchronizedGroups.some((group) => group === globalSharedSyncGroup);
|
|
1004
|
+
if (!hasGroup) {
|
|
1005
|
+
target.props.fileSystemSynchronizedGroups.push(globalSharedSyncGroup);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
configureTargetWithGlobalSharedAssets(targetToUpdate);
|
|
926
1010
|
applyDevelopmentTeamIdToTargets();
|
|
927
1011
|
syncMarketingVersions();
|
|
928
1012
|
return project;
|
|
@@ -17,6 +17,16 @@ public class ExtensionStorageModule: Module {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
Function("reloadControls") { (kind: String?) in
|
|
21
|
+
if #available(iOS 18.0, *) {
|
|
22
|
+
if let kind = kind {
|
|
23
|
+
ControlCenter.shared.reloadControls(ofKind: kind)
|
|
24
|
+
} else {
|
|
25
|
+
ControlCenter.shared.reloadAllControls()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
Function("setArray") { (forKey: String, data: [[String: Any]], suiteName: String?) -> Bool in
|
|
21
31
|
// Convert the incoming array of dictionaries directly to JSON data
|
|
22
32
|
do {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bacons/apple-targets",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Generate Apple Targets with Expo Prebuild",
|
|
5
5
|
"main": "build/ExtensionStorage.js",
|
|
6
6
|
"types": "build/ExtensionStorage.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "Evan Bacon",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bacons/xcode": "1.0.0-alpha.
|
|
36
|
+
"@bacons/xcode": "1.0.0-alpha.27",
|
|
37
37
|
"@react-native/normalize-colors": "^0.79.2",
|
|
38
38
|
"glob": "^10.4.2",
|
|
39
39
|
"debug": "^4.3.4"
|