Swift Macro: Missing package product 'MyMacroApple'

In Xcode 15.0.0 I have created a package using a template Swift Macro. I have named it 'MyMacroApple'. The template comes with #stringify macro so I have created an new app and named it 'MyMacroApp' then copy pasted the code from 'MyMacroApple' main.swift file

import MyMacroApple

let a = 17
let b = 25

let (result, code) = #stringify(a + b)

then I have added Local package dependency to the app project and selected package product 'MyMacroApple' of Library kind to my 'pocMyApp' target.

When I run the project I get the error: "No such module 'MyMacroApple'"

  • Facing the same issue, it might be a bug. I can execute the command successfully when specifying "Mac" as the target, but encounter issues when attempting to do the same with iOS. EDIT: I tried to import the Macro as package in an empty project. It seems to work with iOS only in this way

  • Facing the same issue On Xcode 15/15.2-beta, https://github.com/capturecontext/swift-cocoa-extensions compiles in isolation, but not when it's imported as a dependency (both remote or local) to another package...

    I tried compiling for macOS and force disabled macro validation with

    defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES
    

    but nothing helps...

Add a Comment

Replies

Facing the same issue. Could be a XCode bug.

Facing the same issue, it might be a bug. I can execute the command successfully when specifying "Mac" as the target, but encounter issues when attempting to do the same with iOS.

I have two ideas that would fix the problem:

  • do not work with the app project and Swift macro package at the same time. Only one of them can be opened.
  • go to the issues navigator and find the issue that relates to 'Trust & Enable' the macro package.

Is one of them working for you?

  • Yes, only one of them can be accessed.

    In case you intend to utilize the package on iOS, you have the option to incorporate it into an external project and subsequently add it as a dependency. This happens to be the sole approach I have discovered for iOS compatibility.

    As for the second issue, I have been unable to locate any option labeled "Trust & Enable."

Add a Comment

In my experience, I solved the issue by taking the following steps:

  1. Closing the Macro Project.
  2. Resetting package caches: File -> Packages -> Reset Package Caches. Xcode will then automatically reinstall all the packages.