swift/README.md
Swift Package for Moonshine Voice that supports both iOS and macOS.
The Moonshine.xcframework currently only contains iOS slices. To use this package on macOS, you need to build a macOS framework and add it to the xcframework.
cd core
mkdir -p build/build-macos
cd build/build-macos
cmake -G Xcode -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 ..
cmake --build . --config Release
# The framework should be at: core/build/build-macos/Release/moonshine.framework
# Or if built as a library, create a framework structure
cd ../../ios
xcodebuild -create-xcframework \
-framework ../core/build/build-macos/Release/moonshine.framework \
-framework Moonshine.xcframework/ios-arm64/moonshine.framework \
-framework Moonshine.xcframework/ios-arm64_x86_64-simulator/moonshine.framework \
-output Moonshine.xcframework
The package includes a system library target for macOS that links against libmoonshine.dylib. To use this:
cd core
mkdir -p build
cd build
cmake ..
cmake --build . --config Release
# This creates libmoonshine.dylib in the build directory
/usr/local/lib/, orDYLD_LIBRARY_PATH to include the build directory, orimport Moonshine
let transcriber = try Transcriber(modelPath: "...", modelArch: .base)
import Moonshine
let transcriber = try Transcriber(modelPath: "...", modelArch: .base)
The package automatically uses the correct underlying library (framework for iOS, dylib for macOS).