admin管理员组文章数量:1305987
I have a c header file where I define a c enum that I use in some swift code as well as in some metal shader code. The file is defined in a package like this:
import PackageDescription
let package = Package(
name: "COREAPI",
platforms: [
.iOS("12.0"),
.macOS("10.10"),
.tvOS("9.0"),
.watchOS("2.0")
],
products: [
.library(
name: "COREAPI",
targets: ["COREAPI"]),
],
dependencies: [],
targets: [
.systemLibrary(
name: "SharedOpcodes",
path: "Sources/SharedOpcodes"
),
.target(
name: "COREAPI",
dependencies: ["SharedOpcodes"],
path: "Sources/COREAPI"
),
.testTarget(
name: "COREAPITests",
dependencies: ["COREAPI"]),
]
)
Where the directory is set up kinda like this:
COREAPI
--Package file
--SOURCES
----COREApi
------**here's all the swift code. This can access shared c header file no problem
----SharedOpCodes
------module.modulemap
------sharedopcodes.h
When I import add this package to another project, I can easily access the sharedopcodes with a simple import statement. HOWEVER when I try to access it in my metal shader, I cannot import it. I tried to add it to the metal compiler's header search path, but all of the relevant environment variables pointing to packages in the derived data directory go to the product directories, but the header is only available in the source directory. I tried to do some workarounds with adding a run script, but Xcode's aggressive sandboxing got in the way of symlinks, creating directories and copying files.
Any thoughts on how to make the metal compiler see this header from my Swift package??
本文标签: xcodeCan I import a c header from a swift package into a metal fileStack Overflow
版权声明:本文标题:xcode - Can I import a c header from a swift package into a .metal file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741812457a2398878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论