migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.19k stars 77 forks source link

pre-built SwiftGodot package not work #610

Open waci11 opened 1 week ago

waci11 commented 1 week ago

I follow this guide: https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot/your-first-extension But I am not do step3.

Instead of step 3 , I download the xcframework form: https://github.com/migueldeicaza/SwiftGodot/releases/download/0.45/SwiftGodot.xcframework.zip Then i copy it to my project root.

my package.swift:

import PackageDescription
let package = Package(
    name: "MyPlugin",
    platforms: [.iOS(.v15)],
    products: [
        .library(
            name: "MyPlugin",
            type: .dynamic,
            targets: ["MyPlugin"]),
    ],
    targets: [
        .binaryTarget(name:"SwiftGodot",path:"SwiftGodot.xcframework" ),
        .target(
            name: "MyPlugin",
            dependencies: ["SwiftGodot",],
            swiftSettings: [.unsafeFlags(["-suppress-warnings"])]
        ),

        .testTarget(
            name: "MyPluginTests",
            dependencies: ["MyPlugin"]),
    ]
)

but I got error : External macro implementation type 'SwiftGodotMacroLibrary.GodotMacro' could not be found for macro 'Godot' in

import SwiftGodot
@Godot
class ARcamera:Camera3D{}

and error : External macro implementation type 'SwiftGodotMacroLibrary.InitSwiftExtensionMacro' could not be found for macro 'initSwiftExtension(cdecl:types:)' in:

import SwiftGodot
#initSwiftExtension(cdecl: "swift_entry_point", types: [ARcamera.self])

then , I copy SwiftGodotMacroLibrary and SwiftGodotMacro to my project from SwiftGodotBinary(https://github.com/migueldeicaza/SwiftGodotBinary) the error disappear , but get new error:No such module 'SwiftCompilerPlugin'

I want to build a IOS plugin ,but I am not good at programing , So I spent a lot of time repeatedly building and trying . I think use the pre-built SwiftGodot package should be faster then source code . But I couldn't find any helpful documentation or tutorials, and I can not successfully build it . I hope someone can tell me where the problem is.

Mac OS 14.7.1 Xcode 15.4

compufox commented 19 hours ago

you need to add the SwiftGodotBinary repo to your dependencies instead of adding it as a target.

let package = Package(
  name: "TestPlugin",
  products: [
    .library(name: "TestPlugin", type: .dynamic, targets: ["TestPlugin"])
  ],
  dependencies: [
    .package(url: "https://github.com/migueldeicaza/SwiftGodotBinary", from: "0.4.6")
  ],
  targets: [
    .target(
      name: "TestPlugin",
      dependencies: [
        .product(name: "SwiftGodot", package: "swiftgodotbinary")
      ]
    )
  ]
)

hope this helps!