Post

Replies

Boosts

Views

Activity

Reply to Accessing Resources of other package targets or dependencies using Swift Package Manager
Solution to my question is as follows: "Child" package with C++ code now contains only ‘.c’ and ‘.h’ files linked to each other; «Рarent» package with Swift code contains ‘*.metal’ file with the shaders (now in root directory, but this is easy to fix); Necessary headers in the .metal file are now accessed like this:  #include "../XRKitDefenitions/include/VertexAttributes.h" #include "../XRKitDefenitions/include/TextureIndices.h" Complete ‘Package.swift’ code now looks like this: let package = Package(     name: "XRKit",     platforms: [.macOS(.v10_15), .iOS(.v13)],     products: [         .library(name: "XRKit", targets: ["XRKit"]),         .library(name: "XRKitDefenitions", targets: ["XRKitDefenitions"])     ],     targets: [         .target(             name: "XRKitDefenitions",             path: "Sources/XRKitDefenitions",             cxxSettings: [                 .headerSearchPath("../include/")             ]         ),         .target(             name: "XRKit",             dependencies: ["XRKitDefenitions"],             path: "Sources/XRKit",             resources: [                 .copy("Shaders.metal"),             ]         )     ] ) Create MTLLibrary like this: self.mtlDevice.makeDefaultLibrary(bundle: .module); It was interesting to figure out on my own how it could work for my case :)
Topic: Graphics & Games SubTopic: Metal Tags:
May ’22