Skip to content

Embed whisper.cpp in Xcode project #46

@nickasd

Description

@nickasd

I tried out SwiftWhisper, but since it hasn't been updated in over 2 years and still uses the old 1.2.0 version of whisper.cpp, it has some issues, like crashes happening at whisper_model_load when using some of the models (Turbo, or any q_8_x). (Because of the lack of recent updates for this project, I'm posting this both here and on whisper.cpp.) So I was wondering how to make it use the most recent whisper.cpp release.

I tried the following:

  • Check out SwiftWhisper and open it in Xcode, but building it produces a compiler error No such module 'whisper_cpp'. The folder whisper.cpp, which, when adding SwiftWhisper as a package dependency to my main Xcode project, is populated with files, is in fact empty.
  • Check out SwiftWhisper and add it as a project dependency to my main Xcode project, but again I get the compiler error No such module 'whisper_cpp'. Also for the life of me I cannot figure out where SwiftWhisper declares the link where to check out whisper.cpp @ 95b02d7 which can be seen in the root folder on GitHub. Is this some setting in GitHub that is not saved in the project files?
  • Add the whisper.cpp .h and .cpp files to my main Xcode project like SwiftWhisper seems to do, but that doesn't seem to do anything. I would have assumed that a bridging header or something is necessary, but cannot see anything like that in SwiftWhisper.
  • Download the XCFramework as mentioned in README.md, add it to my main Xcode project, and add the .swift files from SwiftWhisper (and also replacing import whisper_cpp with import whisper), and while the project compiles, at runtime macOS shows a warning about not being able to check whisper.framework for malware and gives me the option to move it to the bin. To open it nonetheless, I can open System Settings > Privacy & Security and at the bottom click Open Anyway. Running the project again then makes it crash at runtime. After some research I found that adding the following entitlement solves the issue, but it doesn't feel right to include it in a production app (and perhaps it's not even allowed on the App Store). When running the project again, I get again the macOS malware warning and have to allow it again.
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
  • Research if it's possible to add a CMake project as an Xcode subproject, but couldn't find anything that worked.

Does anyone know how to include whisper.cpp in a Swift Xcode project? Ideally without using XCFramework, so that it can be debugged and possibly optimized. Thanks in advance for any input!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions