swift - Static linking of Metal library in Xcode - Stack Overflow

Status quo:I have an Xcode "Command Line Tool" project written mainly in Swift. In that same

Status quo: I have an Xcode "Command Line Tool" project written mainly in Swift. In that same project there's a .metal file with some image manipulation code. When I build and archive that project, Xcode produces an executable binary plus a default.metallib library that is needed to run the executable.

What I want to achieve: I want Xcode to produce a single executable binary. The default.metallib should be statically linked.

I tried to add the compiled default.metallib to "Frameworks and Libraries" in the project "General" settings, which also added that lib to "Link Binary With Libraries" in "Build Phases", but that did nothing.

Is this even possible or do I have a completely wrong idea about the whole workflow?

Status quo: I have an Xcode "Command Line Tool" project written mainly in Swift. In that same project there's a .metal file with some image manipulation code. When I build and archive that project, Xcode produces an executable binary plus a default.metallib library that is needed to run the executable.

What I want to achieve: I want Xcode to produce a single executable binary. The default.metallib should be statically linked.

I tried to add the compiled default.metallib to "Frameworks and Libraries" in the project "General" settings, which also added that lib to "Link Binary With Libraries" in "Build Phases", but that did nothing.

Is this even possible or do I have a completely wrong idea about the whole workflow?

Share Improve this question asked Mar 3 at 13:23 limebagellimebagel 213 bronze badges 1
  • What you want is not to link the metallic file into your executable, which makes no sense, but to embed it. Check out this question stackoverflow/questions/34641373/… – Spo1ler Commented Mar 3 at 16:16
Add a comment  | 

1 Answer 1

Reset to default 1

You cannot link the binary with the .metallib file, but you could include the Metal shader source in the source code, using a raw string, and create the library with:

func makeLibrary(
    source: String,
    options: MTLCompileOptions?
) throws -> any MTLLibrary

Reference.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745092705a4610787.html

相关推荐

  • swift - Static linking of Metal library in Xcode - Stack Overflow

    Status quo:I have an Xcode "Command Line Tool" project written mainly in Swift. In that same

    13小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信