@bacons/apple-targets 0.1.7 → 0.1.8
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 +39 -25
- package/build/cli/cli.d.ts +1 -0
- package/build/cli/cli.js +2 -0
- package/build/target.js +16 -1
- package/build/withXcodeChanges.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,14 +9,30 @@ 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 and
|
|
12
|
+
> This plugin requires at least CocoaPods 1.16.2, Xcode 16, and Expo SDK +52.
|
|
13
|
+
|
|
14
|
+
Run the following command in your Expo project:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx create-target
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Select a target to generate, I recommend starting with a `widget`.
|
|
21
|
+
|
|
22
|
+
This will generate the required widget files in the `targets` directory.
|
|
23
|
+
|
|
24
|
+
Ensure the `ios.appleTeamId` property is set in your `app.json`, then run `npx expo prebuild -p ios --clean` to generate the Xcode project.
|
|
25
|
+
|
|
26
|
+
You can now open Xcode and develop the widget inside the `expo:targets` folder. When you're ready to build, run:
|
|
27
|
+
|
|
28
|
+
### Manual usage
|
|
13
29
|
|
|
14
30
|
- Add targets to `targets/` directory with an `expo-target.config.json` file.
|
|
15
|
-
-
|
|
31
|
+
- If you don't have an `Info.plist`, it'll be generated on `npx expo prebuild`. This may be changed in the future so if you have an `Info.plist` it'll be used, otherwise, it'll be generated.
|
|
16
32
|
- Any files in a top-level `target/*/assets` directory will be linked as resources of the target. This was added to support Safari Extensions.
|
|
17
33
|
- A single top-level `*.entitlements` file will be linked as the entitlements of the target. This is not currently used in EAS Capability signing, but may be in the future.
|
|
18
34
|
- All Swift files will be linked as build sources of the target. There is currently no support for storyboard or `.xib` files because I can't be bothered.
|
|
19
|
-
- All
|
|
35
|
+
- All `*.xcassets` files will be linked as resources, and accessible in the targets. If you add files outside of Xcode, you'll need to re-run `npx expo prebuild` to link them.
|
|
20
36
|
- In Expo SDK +52, set the `ios.appleTeamId`, for SDK 51 and below, set the `appleTeamId` prop in the Config Plugin in `app.config.js`:
|
|
21
37
|
|
|
22
38
|
```json
|
|
@@ -32,49 +48,43 @@ An experimental Expo Config Plugin that generates native Apple Targets like Widg
|
|
|
32
48
|
}
|
|
33
49
|
```
|
|
34
50
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Using React Native in Targets
|
|
38
|
-
|
|
39
|
-
I'm not sure, that's not the purpose of this plugin. I built this so I could easily build iOS widgets and other minor targets with SwiftUI. I imagine it would be straightforward to use React Native in share, notification, iMessage, Safari, and photo editing extensions, you can build that on top of this plugin if you want. Look at the App Clip example for a starting point.
|
|
40
|
-
|
|
41
|
-
## `expo-target.config.json`
|
|
51
|
+
## `expo-target.config.js`
|
|
42
52
|
|
|
43
53
|
This file can have the following properties:
|
|
44
54
|
|
|
45
|
-
```
|
|
46
|
-
{
|
|
47
|
-
|
|
55
|
+
```js
|
|
56
|
+
module.exports = {
|
|
57
|
+
type: "widget",
|
|
48
58
|
|
|
49
59
|
// Name of the target/product. Defaults to the directory name.
|
|
50
|
-
|
|
60
|
+
name: "My Widget",
|
|
51
61
|
|
|
52
62
|
// Generates colorset files for the target.
|
|
53
|
-
|
|
63
|
+
colors: {
|
|
54
64
|
// or "$accent": "red",
|
|
55
|
-
|
|
65
|
+
$accent: { color: "red", darkColor: "blue" },
|
|
56
66
|
},
|
|
57
|
-
|
|
67
|
+
icon: "../assets/icon.png",
|
|
58
68
|
// Can also be a URL
|
|
59
|
-
|
|
69
|
+
frameworks: [
|
|
60
70
|
// Frameworks without the extension, these will be added to the target.
|
|
61
|
-
"SwiftUI"
|
|
71
|
+
"SwiftUI",
|
|
62
72
|
],
|
|
63
|
-
|
|
73
|
+
entitlements: {
|
|
64
74
|
// Serialized entitlements. Useful for configuring with environment variables.
|
|
65
75
|
},
|
|
66
76
|
// Generates xcassets for the target.
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
images: {
|
|
78
|
+
thing: "../assets/thing.png",
|
|
69
79
|
},
|
|
70
80
|
|
|
71
81
|
// The iOS version fot the target.
|
|
72
|
-
|
|
82
|
+
deploymentTarget: "13.4",
|
|
73
83
|
|
|
74
84
|
// Optional bundle identifier for the target. Will default to a sanitized version of the root project bundle id + target name.
|
|
75
85
|
// If the specified bundle identifier is prefixed with a dot (.), the bundle identifier will be appended to the main app's bundle identifier.
|
|
76
|
-
|
|
77
|
-
}
|
|
86
|
+
bundleIdentifier: ".mywidget",
|
|
87
|
+
};
|
|
78
88
|
```
|
|
79
89
|
|
|
80
90
|
You can also use `.js` with the typedoc for autocomplete:
|
|
@@ -391,3 +401,7 @@ let defaults = UserDefaults(suiteName:
|
|
|
391
401
|
// Access the value you set:
|
|
392
402
|
let index = defaults?.string(forKey: "myKey")
|
|
393
403
|
```
|
|
404
|
+
|
|
405
|
+
## Using React Native in Targets
|
|
406
|
+
|
|
407
|
+
I'm not sure, that's not the purpose of this plugin. I built this so I could easily build iOS widgets and other minor targets with SwiftUI. I imagine it would be straightforward to use React Native in share, notification, iMessage, Safari, and photo editing extensions, you can build that on top of this plugin if you want. Look at the App Clip example for a starting point.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/cli/cli.js
ADDED
package/build/target.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.KNOWN_EXTENSION_POINT_IDENTIFIERS = {
|
|
|
23
23
|
"com.apple.authentication-services-account-authentication-modification-ui": "account-auth",
|
|
24
24
|
"com.apple.services": "action",
|
|
25
25
|
"com.apple.appintents-extension": "app-intent",
|
|
26
|
+
"com.apple.deviceactivity.monitor-extension": "device-activity-monitor",
|
|
26
27
|
// "com.apple.intents-service": "intents",
|
|
27
28
|
};
|
|
28
29
|
// TODO: Maybe we can replace `NSExtensionPrincipalClass` with the `@main` annotation that newer extensions use?
|
|
@@ -53,7 +54,14 @@ function getTargetInfoPlistForType(type) {
|
|
|
53
54
|
},
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
if (type === "
|
|
57
|
+
else if (type === "app-intent") {
|
|
58
|
+
return plist_1.default.build({
|
|
59
|
+
EXAppExtensionAttributes: {
|
|
60
|
+
EXExtensionPointIdentifier: "com.apple.appintents-extension",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else if (type === "clip") {
|
|
57
65
|
return plist_1.default.build({
|
|
58
66
|
CFBundleName: "$(PRODUCT_NAME)",
|
|
59
67
|
CFBundleIdentifier: "$(PRODUCT_BUNDLE_IDENTIFIER)",
|
|
@@ -66,6 +74,13 @@ function getTargetInfoPlistForType(type) {
|
|
|
66
74
|
NSAppClipRequestEphemeralUserNotification: false,
|
|
67
75
|
NSAppClipRequestLocationConfirmation: false,
|
|
68
76
|
},
|
|
77
|
+
NSAppTransportSecurity: {
|
|
78
|
+
NSAllowsArbitraryLoads: false,
|
|
79
|
+
NSAllowsLocalNetworking: true,
|
|
80
|
+
},
|
|
81
|
+
UILaunchStoryboardName: "SplashScreen",
|
|
82
|
+
UIUserInterfaceStyle: "Automatic",
|
|
83
|
+
UIViewControllerBasedStatusBarAppearance: false,
|
|
69
84
|
});
|
|
70
85
|
}
|
|
71
86
|
const NSExtensionPointIdentifier = Object.keys(exports.KNOWN_EXTENSION_POINT_IDENTIFIERS).find((key) => exports.KNOWN_EXTENSION_POINT_IDENTIFIERS[key] === type);
|
|
@@ -653,9 +653,14 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
653
653
|
console.log(`Target "${targetToUpdate.props.productName}" already exists, updating instead of creating a new one`);
|
|
654
654
|
}
|
|
655
655
|
const magicCwd = path_1.default.join(config._internal.projectRoot, "ios", props.cwd);
|
|
656
|
-
|
|
656
|
+
let developmentTeamId = (_b = props.teamId) !== null && _b !== void 0 ? _b : mainAppTarget.getDefaultBuildSetting("DEVELOPMENT_TEAM");
|
|
657
657
|
if (!developmentTeamId) {
|
|
658
|
-
|
|
658
|
+
console.error("Couldn't find DEVELOPMENT_TEAM in Xcode project and none were provided in the Expo config. Using placeholder value.");
|
|
659
|
+
// Using a placeholder gives users a chance to see the value in Xcode.
|
|
660
|
+
developmentTeamId = "XXXXXXXXXX";
|
|
661
|
+
// throw new Error(
|
|
662
|
+
// "Couldn't find DEVELOPMENT_TEAM in Xcode project and none were provided in the Expo config."
|
|
663
|
+
// );
|
|
659
664
|
}
|
|
660
665
|
function applyDevelopmentTeamIdToTargets() {
|
|
661
666
|
var _a, _b;
|