ml-explore/mlx-swift-examples

Xcode refuses to build or do anything after adding https://github.com/ml-explore/mlx-swift-examples/ as dependency

Closed this issue · 9 comments

created a new project in Xcode, completely blank slate, added the

https://github.com/ml-explore/mlx-swift-examples/

dependency as the readme says, and the build just refuses to build. no error or anything, just doesnt do anything?

edit: randomly decides to build, but when i try to "import LLM" it says no such module LLM

You will need to set up targets in your project and set dependencies on the libraries provided by mlx-swift-examples. S something like this:

image

I'm also hitting the "no such module 'LLM'" error and am quite baffled as to why.

If you are getting it via the swiftpm file (Package.swift) then it is called MLXLLM (to better match the mlx-swift libraries):

        .library(
            name: "LLM",
            targets: ["MLXLLM"]),

I am working on VLM support in #151 and part of that will make this much more consistent.

I've added it as a package dependency in my xcodeproj using Xcode 15.4. Xcode recognizes the LLM product and can add it as a dependency to my other targets, but when I compile it has the missing module error. I think this might be flaw in the Xcode build system related to the mismatch between the library name ("LLM") and the target name ("MLXLLM"). I'm continuing to investigate.

OK, let me know what you find out -- I think we should probably make the directory/target/library/module all match. The mismatch was from the Project.swift but I think whoever set that up had the better idea.

ok, so I just tried a private fork of mlx-swift-examples that only changed the library name from LLM to MLXLLM and Xcode 15.4 had no problems.

I faced the same problem of no no such module LLM. I am running Xcode 16.1/16.2 Changing the name from LLM to MLXLLM worked for both adding it directly to a new Xcode project and to an existing Swift Package. Thanks @davedelong!

Follow up on this: I tried in an existing/new project and if I use import MLXLLM instead of import LLM and use MLXLLM.generate etc, it works fine. Even in a Swift package.

The naming differences have been corrected -- it is import MLXLLM everywhere now. Hopefully that clears up a lot of confusion (that was not at all obvious!)