EvanBacon / expo-apple-targets

Config Plugin to setup Apple targets
308 stars 30 forks source link

feat: add watch-widget type target #16

Open hannojg opened 10 months ago

hannojg commented 10 months ago

With this change its possible to set the type to watch-widget.

Addresses: #6

To get watch widgets working, it depends on:

bwees commented 2 months ago

What is the best way of implementing this? I tried merging all 3 PRs into my own fork and then adding that as a dependency but many errors are thrown:

ommand failed
npm error npm error command sh -c expo-module prepare
npm error npm error Configuring module
npm error npm error expo-module-scripts: README.md exists, not updating
npm error npm error src/icon/withImageAsset.ts(297,5): error TS2345: Argument of type '{ filename: string; idiom: "universal"; platform: string; size: string; }' is not assignable to parameter of type 'ContentsJsonImage'.
npm error npm error   Object literal may only specify known properties, and 'platform' does not exist in type 'ContentsJsonImage'.
npm error npm error src/icon/withIosIcon.ts(243,5): error TS2345: Argument of type '{ filename: string; idiom: "universal"; platform: string; size: string; }' is not assignable to parameter of type 'ContentsJsonImage'.
npm error npm error   Object literal may only specify known properties, and 'platform' does not exist in type 'ContentsJsonImage'.
npm error npm error src/withXcodeChanges.ts(75,29): error TS2345: Argument of type 'ExportedConfigWithProps<XcodeProject>' is not assignable to parameter of type 'ExpoConfig'.
npm error npm error   Types of property 'scheme' are incompatible.
npm error npm error     Type 'string | string[] | undefined' is not assignable to type 'string | undefined'.
npm error npm error       Type 'string[]' is not assignable to type 'string'.
npm error npm error Tried to guess the docs homepage for @bacons/apple-targets; add it under the "homepage" entry in package.json
npm error npm error npm warn using --force Recommended protections disabled.
npm error npm error npm warn invalid config include="\"dev\\n\\npeer\\n\\noptional\"" set in environment
npm error npm error npm warn invalid config Must be one or more of: prod, dev, optional, peer
bwees commented 2 months ago

I have added a few @ts-expect-error tags on the offending lines in my branch, however when I do the expo prebuild, I get the following error and Xcode is unable to compile:

You're using an experimental Config Plugin that is subject to breaking changes and has no E2E tests.
✔ Config synced
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: An error occurred while processing the post-install hook of the Podfile.

[Xcodeproj] Consistency issue: no parent for object `SwiftUI.framework`: `FrameworksBuildPhase`, `FrameworksBuildPhase`

It also appears that the Info.plist file is not generated properly (missing the NSExtensionPointIdentifier) but that is able to be added easily by just creating the file myself.

here is my config for the watch widget:

/** @type {import('@bacons/apple-targets').Config} */
module.exports = {
    type: "watch-widget",
    name: "watchwidget",
    bundleIdentifier: ".widget",
};

and the watch app:

/** @type {import('@bacons/apple-targets').Config} */
module.exports = {
  type: "watch",
  name: "Maroon Rides Watch App",
  identifier: "com.bwees.reveille-rides.watch",
  deploymentTarget: "9.0",
  icon: "../../assets/icon.png",
  frameworks: [
    "SwiftUI"
  ],
  dependencyTargets: ["watchwidget"]
};

@hannojg are you able to advise on what a correct config file would look like and if there is something else I need to fix?

bwees commented 2 months ago

it appears that it may be getting confused with multiple targets requesting SwiftUI. If I remove the main watch app's SwiftUI framework declaration, it appears to complete rebuild correctly