Skip to content

Missing iOS bindings when building framework for macOS and iOS #82

@pronebird

Description

@pronebird

Consider that we have a lib with conditional compilation:

#[cfg(target_os = "ios")]
pub mod ios_module;

#[cfg(target_os = "macos")]
pub mod mac_module;

Now building a framework with:

cargo swift package --accept-all --platforms mac ios --name MyLib --xcframework-name MyLibUniffi --lib-type dynamic
  • Only outputs bindings for macOS
  • Builds dylib even for iOS!!!

Instead --platforms should be replaced with:

--platform <SINGLE_PLATFORM>

followed by:

--lib-type <THIS_PLATFORM_LIB_TYPE>

In such case it should be possible to build a framework that offers dylib for macOS, and static lib for iOS.

cargo swift package --accept-all --platform mac --lib-type dynamic --platform ios --lib-type static --name MyLib --xcframework-name MyLibUniffi

Swift bindings for iOS and macOS should be included conditionally.

Relevant issue: mozilla/uniffi-rs#2647

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