Skip to content

whisper: add xcframework build script #2873

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

Merged
merged 4 commits into from
Mar 13, 2025
Merged

Conversation

mdestagnol
Copy link
Contributor

@mdestagnol mdestagnol commented Mar 12, 2025

This is adding xcframework support for Whisper; I followed the same strategy as the work done by @danbev on Llama ggml-org/llama.cpp#11996

I didn't yet ported the apple validation scripts; I'll have to check that part tomorrow but shouldn't be hard to add.

UPDATE: the Apple Validation scripts are added. We should be good to go.

@mdestagnol mdestagnol mentioned this pull request Mar 12, 2025
@danbev
Copy link
Collaborator

danbev commented Mar 12, 2025

I tried the whisper.swiftui and it worked perfectly 👍

whisper_swiftui_valid

Copy link
Collaborator

@danbev danbev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is just a minor change required for the validate scripts which are currently failing with the following error:

$ ./scripts/apple/validate-apps.sh
===== iOS Validation Process Started =====
Creating test iOS app project...
Copying XCFramework to test project...
Building and archiving test app...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:iOS, arch:arm64, id:00008030-001A0C4611EB402E, name:Daniels iPhone }
{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008122-000258CA0180001C, name:My Mac }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
/Users/danbev/work/ai/whisper.cpp/validation-builds/ios/temp/iOSWhisperTest/iOSWhisperTest/Sources/ContentView.swift:20:35: error: value of type 'whisper_context_params' has no member 'n_ctx'
            Text("n_ctx: \(params.n_ctx)")
                           ~~~~~~ ^~~~~
note: Using codesigning identity override: -
** ARCHIVE FAILED **

===== iOS Validation Process Failed =====

I've left a comment with a suggestion.

@mdestagnol mdestagnol requested a review from danbev March 13, 2025 07:53
@danbev danbev merged commit 5bb1d58 into ggml-org:master Mar 13, 2025
45 checks passed
@itsthisjustin
Copy link

Will this enable the swift package to work again without manually building via CMAKE?

@danbev
Copy link
Collaborator

danbev commented Mar 13, 2025

Will this enable the swift package to work again without manually building via CMAKE?

After the next release the xcframework should be available as an artifact in the release page. This will allow a swift project use the xframework like this:

// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyWhisperPackage",
    targets: [
        .executableTarget(
            name: "MyWhisperPackage",
            dependencies: [
                "WhisperFramework"
            ]),
        .binaryTarget(
            name: "WhisperFramework",
            url: "https://github.com/ggerganov/whisper.cpp/releases/download/bxxxx/whisper-bxxxx-xcframework.zip",
            checksum: "<checksum>"
        )
    ]
)

In the mean time one option is to build the xcframework locally by running the build-xcframework.sh script, and then using a local relative path to the xcframework. This is what I'm currently doing to try things out:

$ cat Package.swift
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "Whisper",
    targets: [
        .executableTarget(
            name: "Whisper",
            dependencies: [
                "WhisperFramework"
            ]),
        .binaryTarget(
            name: "WhisperFramework",
            path: "../../ai/whisper.cpp/build-apple/whisper.xcframework"
        )
    ]
)

@danbev
Copy link
Collaborator

danbev commented Mar 16, 2025

After the next release the xcframework should be available as an artifact in the release page.

Sorry I was wrong about this and we need to add the xcframework to the github releases first. This is tracked by #2886.

buxuku pushed a commit to buxuku/whisper.cpp that referenced this pull request Mar 26, 2025
* whisper: add xcframework build script

* added apple validation scripts

* fixed Readme

* validation script fix
@danbev danbev mentioned this pull request Apr 2, 2025
@Josscii
Copy link
Contributor

Josscii commented Apr 8, 2025

hi, currently this xcframework is not supporting Mac Catalyst, would you extend it to support it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants