Skip to content

[ios] Support bundling shared libraries into frameworks #96664

Closed

Description

@ivanpovazan

Description

Currently, we support building shared iOS libraries:

without depending on iOS workloads and pulling in Xamarin SDK.

This means that when users write their class libraries that do not have a dependency on iOS-specific API, can build such libraries by using the standard target framework and iOS-specific runtime identifier (e.g.,-f net8.0 -r ios-arm64) in order to produce a shared native library - *.dylib.

However, in order to properly consume a shared iOS library, one has to bundle it into a framework - Technical Note TN2435 which in most simplistic case comes down to generating the following bundle:

mylib.framework
    |_ mylib.dylib
    |_ Info.plist

This was also reported in: #93366

Approaches

At this point, I can think of two possible approaches we could take (there might be other solutions):

  1. Lift up Xamarin SDK bundling logic from OS-specific framework and extend it to also be capable of producing framework bundles
  2. Refactor and productise AppleAppBuilder which will have minimal viable set of features (a subset of Xamarin bundler) for producing minimal app/framework bundles, and which will be available with the standard target framework.

Activity

  1. added this to the 9.0.0 milestone on Jan 9, 2024
  2. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Jan 9, 2024
  3. ivanpovazan commented on Jan 9, 2024

    @ivanpovazan
    MemberAuthor

    @rolfbjarne @steveisok what are your thoughts on the proposed approaches?

  4. rolfbjarne commented on Jan 9, 2024

    @rolfbjarne
    Member

    Creating a .framework isn't very difficult:

    1. Create the correct directory structure (differs between iOS/tvOS and MacCatalyst/macOS).
    2. Add the native library + any other files the native library depends on (the assembly maybe?) in the correct location.
    3. Add an Info.plist in the correct location.

    The biggest complication is probably the Info.plist: should it be completely user-provided? do you generate a default file if the developer doesn't specify one? Note that the developer should at least be able to override any defaults.

    IMHO this the simplest is just to create your own logic, no need to copy/move ours (it's not trivially extractable anyway).

  5. added and removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Jan 9, 2024
  6. jkotas commented on Jan 9, 2024

    @jkotas
    Member

    Creating a .framework isn't very difficult:

    If it is that simple, do we need the whole AppleAppBuilder for it? Can it be just a few lines of build targets (for native AOT at least)?

  7. modified the milestones: 9.0.0, 10.0.0 on Aug 22, 2024
  8. ivanpovazan commented on Nov 24, 2024

    @ivanpovazan
    MemberAuthor

    Since we provided documentation on required steps to create and consume custom frameworks from shared native libraries, I will close this issue as out-of-scope.

    If it becomes necessary to automate these steps as part of the build, we can reopen the issue.

  9. locked and limited conversation to collaborators on Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions