How to debug metal source inside a dependency lib in another project

I put my metal source files in project A, then build to a shared lib "liba", and "default.metallib" as the Metal lib. Project B depends on "liba", and "default.metallib", I can include A's project file to debug source codes of A inside B, but if I change codes in A's Metal files, I have to rebuild project A, and copy the new "default.metallib" file to project B. Is there any solution that I don't have to rebuild A and copy the new "default.metallib" to B?

Replies

Hi Elvislee,

I sounds like your use case can be described as a situation where Project A is a shared "Engine" Library and Project B is a game/pro app depending on the metal library from this "Engine". Currently the best way to deal with this use case is by turning Project A into a Framework instead of a library and making Project B depended on this framework. This will allow you to access the metal library from project in the following way:

NSBundle * engineBundle = [NSBundle bundleWithIdentifier:@"com.myapp.ProjectA"];
_defaultLibrary = [_device newDefaultLibraryWithBundle:engineBundle error:&error];

Using a framework you no longer have copy "default.metallib" manually and since the metal source codes of default.metallib remain in projectA, the dependency tracking system should automatically rebuild projectA when the sources change. Also source level debugging should just work as expected.

We are investigating to improve the use case where project A is a shared library, but hopefully using frameworks will provide a solution in the meantime.

Hope this answers your question.