Requirements
- macOS with Xcode
- CMake
- Bison 3.8+ (install via Homebrew:
brew install bison)
Building the iOS framework
Step 1: Build libsndfile
First, build libsndfile for iOS targets:Step 2: Build Csound framework
- Configures CMake with iOS-specific settings
- Builds for both arm64 (device) and x86_64 (simulator)
- Creates an XCFramework containing both architectures
- Copies the framework to
Csound-For-iOS/
Step 3: Create release package
Build configuration
The iOS build uses custom CMake configuration (custom.cmake.ios):
USE_DOUBLE=0: Uses 32-bit floats for better performanceBUILD_STATIC_LIBRARY=1: Builds static libraryDCMAKE_OSX_ARCHITECTURES="arm64;x86_64": Supports both device and simulator
XCFramework structure
The build producesCsoundiOS.xcframework with:
Using in Xcode projects
Add the framework
- Drag
CsoundiOS.xcframeworkinto your Xcode project - In target settings, add to “Frameworks, Libraries, and Embedded Content”
- Set to “Do Not Embed” (static framework)
Objective-C usage
Swift usage
Create a bridging header:Audio session configuration
Configure AVAudioSession for iOS:Control channels
Communicate with running Csound code:Real-time audio
iOS uses CoreAudio for low-latency audio:MIDI support
iOS supports CoreMIDI:Example projects
TheCsound-for-iOS directory includes example projects:
- Objective-C example: Basic Csound integration
- Swift example: Modern Swift implementation
Performance considerations
- Use
USE_DOUBLE=0for better performance on mobile - Set appropriate buffer sizes (-b, -B options)
- Test on actual devices, not just simulator
- Monitor CPU usage in Instruments
Background audio
Enable background audio in your app:- Add “Audio, AirPlay, and Picture in Picture” capability
- Set audio session category to
.playback - Handle audio interruptions: