raycast / extensions-swift-tools

Utility to use Swift in a Raycast extension
82 stars 4 forks source link

Build failed with error: Unable to resolve build file: RaycastExtensionMacro #1

Closed vospennikov closed 1 year ago

vospennikov commented 1 year ago

Hi! I'm implementing a simple plugin for Raycast using Swift. The plugin parses internal files in macOS and will control Do Not Disturb mode by Raycast. The plugin works successfully in Xcode and successfully calls functions thanks to variables in the launch arguments. In addition, it's successfully built in release and debugging mode. I need help with integration in Node.js and Raycast. I get the following error:

?main ~/Development/raycast/do-not-disturb> npm install && npm run dev

up to date, audited 174 packages in 792ms

29 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> dev
> ray develop

info  -  generated extension's TypeScript definitions
info  -  entry points [src/show-focus-mode.tsx src/set-focus-mode.tsx]
build failed (src/show-focus-mode.tsx:3:21 import getFocus from "swift:../swift";): failed to compile swift: 0%: Compute target dependency graph
Building targets in dependency order
Target dependency graph (18 targets)
0%: Gather provisioning inputs
0%: Create build description
Build description signature: 18f2e449e40054aa0e2b53e78bf77010

Build description path: /Users/vospennikov/Development/raycast/do-not-disturb/swift/.raycast-swift-build/apple/Intermediates.noindex/XCBuildData/18f2e449e40054aa0e2b53e78bf77010.xcbuilddata

Unable to resolve build file: BuildFile<PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::2> (The workspace has a reference to a missing target with GUID 'PACKAGE-TARGET:MacroImplementation@11')
Unable to resolve build file: BuildFile<PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::2> (The workspace has a reference to a missing target with GUID 'PACKAGE-TARGET:MacroImplementation@11')
Build cancelled

exit status 1

If this is unexpected, try to delete the /Users/vospennikov/Development/raycast/do-not-disturb/swift/.raycast-swift-build folder and run this command again

I've explored SPM build manifest. We can see an error in the dependency reference phase: MacroImplementation@11.

"dependencies":
[
    {
        "guid": "PACKAGE-PRODUCT:SwiftCompilerPlugin@11"
    },
    {
        "guid": "PACKAGE-PRODUCT:SwiftSyntaxMacros@11"
    },
    {
        "guid": "PACKAGE-TARGET:MacroImplementation@11"
    },
    {
        "guid": "PACKAGE-TARGET:RaycastExtensionMacro@11"
    }
]
"frameworksBuildPhase":
{
    "buildFiles":
    [
        {
            "guid": "PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::0",
            "platformFilters":
            [],
            "targetReference": "PACKAGE-PRODUCT:SwiftCompilerPlugin@11"
        },
        {
            "guid": "PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::1",
            "platformFilters":
            [],
            "targetReference": "PACKAGE-PRODUCT:SwiftSyntaxMacros@11"
        },
        {
            "guid": "PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::2",
            "platformFilters":
            [],
            "targetReference": "PACKAGE-TARGET:MacroImplementation@11"
        },
        {
            "guid": "PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0::3",
            "platformFilters":
            [],
            "targetReference": "PACKAGE-TARGET:RaycastExtensionMacro@11"
        }
    ],
    "guid": "PACKAGE-PRODUCT:RaycastExtensionMacro::BUILDPHASE_0",
    "type": "com.apple.buildphase.frameworks"
}

But there is no MacroImplementation@11 build instruction in the manifest. In addition, if we read the build graph, we can see that this target didn't build.

Target dependency graph (18 targets)
Target 'AllExcludingTests' in project 'Aggregate'
➜ Explicit dependency on target 'do-not-disturb_1A3CB83CBB8C3789_PackageProduct' in project 'do-not-disturb'
Target 'do-not-disturb_1A3CB83CBB8C3789_PackageProduct' in project 'do-not-disturb'
➜ Explicit dependency on target 'RaycastExtensionMacro_-68D8C0B79733B665_PackageProduct' in project 'raycast-extension-macro'
Target 'RaycastExtensionMacro_-68D8C0B79733B665_PackageProduct' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'RaycastExtensionMacro' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct' in project 'swift-syntax'
➜ Explicit dependency on target 'SwiftSyntaxMacros_-64DCF49FA38391F6_PackageProduct' in project 'swift-syntax'
Target 'RaycastExtensionMacro' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct' in project 'swift-syntax'
➜ Explicit dependency on target 'SwiftSyntaxMacros_-64DCF49FA38391F6_PackageProduct' in project 'swift-syntax'

This is built graph log by swift build -c release

Target 'RaycastExtensionMacro' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'RaycastExtensionMacro' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'MacroImplementation' in project 'raycast-extension-macro'
Target 'RaycastExtensionMacro' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'MacroImplementation' in project 'raycast-extension-macro'
Target 'MacroImplementation' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'SwiftSyntaxMacros' in project 'swift-syntax'
➜ Explicit dependency on target 'SwiftCompilerPlugin' in project 'swift-syntax'
Target 'MacroImplementation' in project 'raycast-extension-macro'
➜ Explicit dependency on target 'SwiftSyntaxMacros' in project 'swift-syntax'
➜ Explicit dependency on target 'SwiftCompilerPlugin' in project 'swift-syntax'

I tried clear DriveData and .raycast-swift-build I posted the plugin on GitHub. It may help.

I've attached the log files. manifest.txt target-graph.txt

dingari commented 1 year ago

I'm getting this error as well trying to piece together the color-picker example in the readme.

mathieudutour commented 1 year ago

This project isn't ready yet

multivac61 commented 11 months ago

When will it be ready?

mathieudutour commented 11 months ago

It should be ready now: https://raycastcommunity.slack.com/archives/C02HEMAF2SJ/p1697640157326539