-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile bug: ios swift xcode build error when upgrade to llama : use cmake for swift build #10747
Comments
same issue |
Can confirm, same issue |
The way it works now is that you need to build llama.cpp with llama.cpp/.github/workflows/build.yml Lines 573 to 592 in 235f6e1
|
First of all, thank you for providing some clarification. I don't usually use Previously when developing for iOS and MacOS we could point Xcode to the llama.cpp swift package and it would "just work" which was pretty nice. If there are additional steps to be done now, can we have some additional documentation around the process? |
@pgorzelany Doing what the CI workflows do (see slaren's comment) should work. The CI workflows install the The process is a bit more involved than before, but it is more flexible and much easier to maintain. It would be useful to have step-by-step instructions added to the example, but I don't have much experience working with XCode (there is stuff like code signing, development teams, etc.), so I am hoping that people who are familiar will contribute and explain how to build a project correctly. So atm, if you are looking for a point-and-click solution - there isn't one yet. You will need to understand how CMake works and start using it. |
Thank you. Once I understand how to properly set it up I will try to contribute some documentation around it. This project is used in multiple iOS and MacOS apps and it was very convenient to use it with the Package.swift file, maybe there is a way to modify the Package.swift to work again. |
Hi @ggerganov after I follow the steps in CI, do the CMake and install and updated the search path to still getting different errors for Undefined symbols do you have any suggestions? |
after run dyld[61825]: Library not loaded: @rpath/libggml.dylib |
for iOS build, got error like "Building for 'iOS-simulator', but linking in dylib (/usr/local/lib/libggml.dylib) built for 'macOS'" while build. here is the script I am using to update and build
and use the package in the Xcode project. please let me know if anything I am missed |
Was anyone able to solve this issue? I have an iOS project using llama and can't update to the latest version because of this. Any help appreciated! |
Hi @slaren , thank you for the response. The issue is that we are not able to use it as a system library on iOS since we cannot install llama on iOS. On Mac it may work but we need to somehow embed llama into the iOS app bundle if we would like to ship it. Could you advise som possible ways around it? |
Could you provide a reference that shipping libraries on iOS is not possible? Seems hard to imagine that there is such a limitation. There must be some workaround. I just don't have a lot of experience and cannot suggest anything atm, but I doubt there is not way to fix this. |
Sorry for the drive-by, but my understanding is as follows; maybe it can provide some additional insights to avoid misunderstandings here: The blocking issue with the build system changes is that, while iOS does support linking against dynamic libraries, it only supports that through the use of Frameworks. I.e., you are not allowed to ships a So I think what needs to be done would be to add options to the llama.cpp's CMake build system to have it generate a ChatGPT conversation with extra information (the information about frame workssounds correct to me, but as always take this with a grain of salt, and I have no idea whether these CMake instructions would work): https://chatgpt.com/share/679ca58b-c498-8008-b9f7-a7527b5fd030 |
Thanks for the investigation. Maybe its possible to build llama as a static library and embed that in the iOS app? |
@MrMage To add to that, from an earlier discussion, CMake should support building frameworks through CMAKE_FRAMEWORK. So definitely look into this as well. |
Here are Apple docs describing the use of a systemLibrary target in a Swift package. The way I understand it, if you expose llama.cpp as a You can ship dynamic libraries as Frameworks as discussed above but I am not sure if there is a way to expose them as a Swift package. One possible route forward would be to build llama using CMake for all Apple platforms separately and then bundle that up in an XCFramework and then wrap that into a Swift package as a binaryTarget. |
For what it's worth, I am only using llama.cpp for my macOS app where
Now, I can't expect my Mac app's users to install llama.cpp on their own, but I found a way around this: I am still adding the llama.cpp Swift package to my macOS app, but I am also adding references to the built That way, I can have SwiftPM believe that it's using the system libraries, but in reality ship those libraries as part of the app bundle. I could imagine that a similar approach might work for iOS — but only if one can get llama.cpp to emit frameworks instead of |
I tried to make the XCFramework approach work for several hours but wasn’t able to. In the end I forked the project, reverted the Package.swift changes and adjusted it for the latest project structure. It now builds for iOS as before so it’s a potential workaround. |
Good to see more discussion on this topic! |
Git commit
$git rev-parse HEAD 43ed389
Operating systems
Mac
GGML backends
Metal
Problem description & steps to reproduce
ios swift xcode build error when upgrade to
Before the upgrade, the code compiled successfully. After the upgrade, it throws a compilation error: "Cannot find type 'xxx' in scope."
First Bad Commit
43ed389
Relevant log output
The text was updated successfully, but these errors were encountered: