Skip to content

Problem with including macros to project locallyΒ #1501

Open
@timoninas

Description

Here I try to include my macros locally into the project. But eventually have this issue in logs:
Error: external macro implementation type 'MyLocalMcr.MockekeMacro' could not be found for macro 'Mockeke()'

I'm using 2.42.0 XcodeGen

My yml config:

name: TemplateProject
options:
  deploymentTarget:
    iOS: "15.0"

settings:
  base:
    MARKETING_VERSION: 1.0

targetTemplates:
  Framework:
    type: framework
    platform: iOS
    settings:
      BUILD_LIBRARY_FOR_DISTRIBUTION: true
    info:
      path: Info.plist

packages:
  MyLocalMcr:
    path: ./../MyLocalMcr   // Here I try to include it

targets:
  TemplateProjectDemo:
    type: application
    platform: iOS
    deploymentTarget: "15.0"
    info:
      path: TemplateProjectDemo/Info.plist
      properties:
        NSAppTransportSecurity:
          NSAllowsArbitraryLoads: true
    sources:
      - TemplateProjectDemo
    dependencies:
      - framework: Products/xc/TemplateProject.xcframework
      - package: MyLocalMcr
        linkType: static
        destinationFilters: [iOS, macOS]
      - framework: Products/xc/OtherFramework1.xcframework
      - framework: Products/xc/OtherFramework1.xcframework
      - framework: Products/xc/OtherFramework1.xcframework

Could you please provide examples: how to include macros into the project (as local package, or as target, etc)
Because I have faced it today and it's stumbling block for my project :(

MyLocalMcr is SPM package

import CompilerPluginSupport
import PackageDescription

let package = Package(
    name: "MyLocalMcr",
    platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .macCatalyst(.v13)],
    products: [
        .library(
            name: "MyLocalMcr",
            targets: ["MyLocalMcr"]
        )
    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0")
    ],
    targets: [
        .macro(
            name: "MyLocalMcrMacros",
            dependencies: [
                .product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
                .product(name: "SwiftCompilerPlugin", package: "swift-syntax")
            ]
        ),

        .target(name: "MyLocalMcr", dependencies: ["MyLocalMcrMacros"])
    ]
)

XcodeGen macros error
Macros doesn't work with XcodeGen

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions