Skip to content

feat: update iOS examples for KMP SDK#40

Draft
iamstuffed wants to merge 4 commits intomainfrom
feat/ios-kmp-refactor
Draft

feat: update iOS examples for KMP SDK#40
iamstuffed wants to merge 4 commits intomainfrom
feat/ios-kmp-refactor

Conversation

@iamstuffed
Copy link
Contributor

Summary

  • Update all 4 iOS example apps (LeapChatExample, LeapAudioDemo, LeapSloganExample, RecipeGenerator) to use the KMP-based LeapSDK
  • Wire up SwiftSyntax macro targets (LeapSDKMacros, LeapSDKConstrainedGenerationPlugin) in Package.swift for constrained generation
  • Simplify examples using SDK-level convenience extensions from Liquid4All/leap-android-sdk#174

Key changes

  • KMP API migration: onEnum(of:) sealed class pattern, any Conversation/any ModelRunner protocol existentials, ChatMessage.Role enum, completion.fullMessage property
  • SDK convenience extensions: progress: callback with native Swift Double/Int64 (no more KotlinDouble), generateResponse(message:) without explicit generationOptions: nil, Leap.load() without explicit options: nil
  • Macro architecture: GeneratableType protocol and @Generatable macro moved from old pure-Swift SDK to LeapSDKMacros package target

Dependencies

  • Requires Liquid4All/leap-android-sdk#174 (SDK-level convenience extensions) to be merged and XCFrameworks rebuilt

Test plan

  • Build LeapChatExample — zero Swift compilation errors (linker only)
  • Build LeapAudioDemo — zero Swift compilation errors (linker only)
  • Build LeapSloganExample — zero Swift compilation errors (linker only)
  • Build RecipeGenerator — zero Swift compilation errors (linker only)
  • Runtime verification on device (requires native inference_engine lib)

Wire up SwiftSyntax macro targets in Package.swift and update all four
iOS example apps to match the latest KMP SDK API surface. Add
GeneratableType protocol and constrained generation macros in
LeapSDKMacros target. Use SKIE-bundled convenience extensions from the
SDK for Swift-friendly initializers and type conversions.
Remove KMP migration workarounds now handled by SDK convenience
extensions: .init() ChatMessage disambiguation (9 sites), explicit
generationOptions: nil / options: nil (5 sites), and
progress.doubleValue unwrapping (4 sites). Uses new progress: labeled
parameter with native Swift Double/Int64 types.
@iamstuffed iamstuffed force-pushed the feat/ios-kmp-refactor branch from 0de5a3f to b6aac6d Compare February 18, 2026 21:21
All four iOS example projects need the nested dylibs inside
LeapSDK.framework/Frameworks/ to be code-signed at build time and the
linker/runtime search paths updated so they can be found.

- Add LIBRARY_SEARCH_PATHS and LD_RUNPATH_SEARCH_PATHS for nested dylibs
- Add post-build script to codesign nested .dylib files in LeapSDK.framework
- Applied to LeapAudioDemo, LeapChatExample, LeapSloganExample, RecipeGenerator
- Pass options: nil for audio model load (audio engine rejects unknown extras fields)
- Stop tracking xcodeproj/project.pbxproj files (generated by xcodegen)
- Update .gitignore to exclude *.xcodeproj/project.pbxproj
LeapSDKMacros (@Generatable, @Guide, GeneratableType) now lives in the
SDK repo and is consumed as a second SPM package dependency rather than
being duplicated in the Examples repo.

- Remove iOS/Sources/ (macro sources deleted, now in SDK repo)
- Simplify iOS/Package.swift to only vend XCFramework binary targets
- Add LeapAndroidSDK package reference in LeapSloganExample and
  RecipeGenerator project.yml files pointing to the SDK worktree
- Replace setResponseFormat(type:) calls with direct jsonSchemaConstraint
  assignment (GenerationOptions extension removed from macro library to
  avoid linking two copies of LeapSDK)
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.

1 participant