@bacons/apple-targets 0.2.1 → 3.0.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/LICENSE +1 -1
- package/README.md +5 -3
- package/build/ExtensionStorage.d.ts +2 -0
- package/build/ExtensionStorage.js +9 -2
- package/ios/ExtensionStorageModule.swift +18 -0
- package/package.json +2 -2
- package/prebuild-blank.tgz +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ An experimental Expo Config Plugin that generates native Apple Targets like Widg
|
|
|
9
9
|
|
|
10
10
|
## 🚀 How to use
|
|
11
11
|
|
|
12
|
-
> This plugin requires at least CocoaPods 1.16.2 (ruby 3.2.0), Xcode 16 (macOS 15 Sequoia), and Expo SDK +
|
|
12
|
+
> This plugin requires at least CocoaPods 1.16.2 (ruby 3.2.0), Xcode 16 (macOS 15 Sequoia), and Expo SDK +53.
|
|
13
13
|
|
|
14
14
|
1. Run `npx create-target` in your Expo project to generate an Apple target.
|
|
15
15
|
2. Select a target to generate, I recommend starting with a `widget` (e.g. `npx create-target widget`). This will generate the required widget files in the root `/targets` directory, install `@bacons/apple-targets`, and add the Expo Config Plugin to your project.
|
|
@@ -42,7 +42,7 @@ Some targets have special entitlements behavior:
|
|
|
42
42
|
Any changes you make outside of the `expo:targets` directory in Xcode are subject to being overwritten by the next `npx expo prebuild --clean`. Check to see if the settings you want to toggle are available in the Info.plist or the `expo-target.config.js` file.
|
|
43
43
|
If you modify the `expo-target.config.js` or your root `app.json`, you will need to re-run `npx expo prebuild --clean` to sync the changes.
|
|
44
44
|
|
|
45
|
-
You can use the custom Prebuild template `--template node_modules/@bacons/apple-targets/prebuild-blank.tgz` to create a build without React Native, this can make development a bit faster since there's less to compile. This is an advanced technique for development **NOT PRODUCTION** and is not intended to be used with third-party Config Plugins.
|
|
45
|
+
You can use the custom Prebuild template `--template ./node_modules/@bacons/apple-targets/prebuild-blank.tgz` to create a build without React Native, this can make development a bit faster since there's less to compile. This is an advanced technique for development **NOT PRODUCTION** and is not intended to be used with third-party Config Plugins.
|
|
46
46
|
|
|
47
47
|
## Target config
|
|
48
48
|
|
|
@@ -320,7 +320,7 @@ If you experience issues building widgets, it might be because React Native is s
|
|
|
320
320
|
Some workarounds:
|
|
321
321
|
|
|
322
322
|
- Clear the SwiftUI previews cache: `xcrun simctl --set previews delete all`
|
|
323
|
-
- Prebuild without React Native: `npx expo prebuild --template node_modules/@bacons/apple-targets/prebuild-blank.tgz --clean`
|
|
323
|
+
- Prebuild without React Native: `npx expo prebuild --template ./node_modules/@bacons/apple-targets/prebuild-blank.tgz --clean`
|
|
324
324
|
- 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.
|
|
325
325
|
|
|
326
326
|
## Sharing data between targets
|
|
@@ -388,6 +388,8 @@ ExtensionStorage.reloadWidget();
|
|
|
388
388
|
|
|
389
389
|
- `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
390
|
- `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)`.
|
|
391
|
+
- `remove(key: string): void` - A method for removing the key from the shared storage.
|
|
392
|
+
- `get(key: string): string | null` - A static method for getting the value from the shared storage.
|
|
391
393
|
|
|
392
394
|
### Accessing shared data
|
|
393
395
|
|
|
@@ -3,4 +3,6 @@ export declare class ExtensionStorage {
|
|
|
3
3
|
static reloadWidget(name?: string): void;
|
|
4
4
|
constructor(appGroup: string);
|
|
5
5
|
set(key: string, value?: string | number | Record<string, string | number> | Array<Record<string, string | number>>): void;
|
|
6
|
+
get(key: string): string | null;
|
|
7
|
+
remove(key: string): void;
|
|
6
8
|
}
|
|
@@ -7,10 +7,11 @@ 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
10
|
setObject() { },
|
|
12
|
-
remove() { },
|
|
13
11
|
setArray() { },
|
|
12
|
+
reloadWidget() { },
|
|
13
|
+
get() { },
|
|
14
|
+
remove() { },
|
|
14
15
|
};
|
|
15
16
|
const originalSetObject = nativeModule.setObject;
|
|
16
17
|
// Sweet API doesn't support doing this natively.
|
|
@@ -44,5 +45,11 @@ class ExtensionStorage {
|
|
|
44
45
|
nativeModule.setObject(key, value, this.appGroup);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
get(key) {
|
|
49
|
+
return nativeModule.get(key, this.appGroup);
|
|
50
|
+
}
|
|
51
|
+
remove(key) {
|
|
52
|
+
nativeModule.remove(key, this.appGroup);
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
exports.ExtensionStorage = ExtensionStorage;
|
|
@@ -48,6 +48,24 @@ public class ExtensionStorageModule: Module {
|
|
|
48
48
|
Function("setString") { (key: String, value: String, group: String?) in
|
|
49
49
|
let userDefaults = UserDefaults(suiteName: group)
|
|
50
50
|
userDefaults?.set(value, forKey: key)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Function("get") { (key: String, group: String?) -> String? in
|
|
54
|
+
let userDefaults = UserDefaults(suiteName: group)
|
|
55
|
+
if let data = userDefaults?.data(forKey: key) {
|
|
56
|
+
do {
|
|
57
|
+
let jsonObject = try JSONSerialization.jsonObject(with: data, options: [])
|
|
58
|
+
let jsonData = try JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted])
|
|
59
|
+
return String(data: jsonData, encoding: .utf8)
|
|
60
|
+
} catch {
|
|
61
|
+
return nil
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if let value = userDefaults?.object(forKey: key) {
|
|
66
|
+
return String(describing: value)
|
|
67
|
+
}
|
|
68
|
+
return nil
|
|
51
69
|
}
|
|
52
70
|
}
|
|
53
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bacons/apple-targets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Generate Apple Targets with Expo Prebuild",
|
|
5
5
|
"main": "build/ExtensionStorage.js",
|
|
6
6
|
"types": "build/ExtensionStorage.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@bacons/xcode": "1.0.0-alpha.24",
|
|
37
|
-
"@react-native/normalize-colors": "^0.
|
|
37
|
+
"@react-native/normalize-colors": "^0.79.2",
|
|
38
38
|
"glob": "^10.4.2",
|
|
39
39
|
"debug": "^4.3.4"
|
|
40
40
|
},
|
package/prebuild-blank.tgz
CHANGED
|
Binary file
|