Comcast / mamba

Mamba is a Swift iOS, tvOS and macOS framework to parse, validate and write HTTP Live Streaming (HLS) data.
Apache License 2.0
182 stars 40 forks source link

Enable module stability. Now can't use with Swift 5.3.2. #102

Open hlung opened 3 years ago

hlung commented 3 years ago

Description

Currently, I can't include it with Swift 5.3.2.

Screenshot 2021-02-22 at 6 10 26 PM

Since Swift 5.1, Apple provide module stability feature in Xcode. This enables a framework to be able to be included in targets with newer Swift versions. But BUILD_LIBRARY_FOR_DISTRIBUTION build setting has to be enabled.

Screenshot 2021-02-22 at 5 59 38 PM Screenshot 2021-02-22 at 5 53 34 PM

My current workaround is to add a Podfile post_install script to do so:

post_install do | installer |
  installer.pods_project.targets.each do |target|
    if target.name == 'mamba-iOS' || target.name == 'mamba-tvOS'
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

Tasks

References

dcoufal commented 3 years ago

This is a good idea. I'm not 100% sure of the consequences for users that are still using plain old frameworks. I'm sure we'll all be using xcframework soon, but not sure of adoption curves.

If you are a user with strong opinions on this or insight into building a framework with this option on, please comment in this thread.

jonnybach commented 3 years ago

I've began the work to update the project build settings and look further into what this build setting actually will do.

When set to YES, an additional file is created (.swiftInterface) which is a non binary description of the public API for the module. This is what will ensure ABI compatibility across swift versions. Verified that there is no impact on building regular frameworks via building a dummy library with mamba as a dependency (with this setting modified).

jonnybach commented 3 years ago

This issue should now be resolved in both the develop and develop_1.x branches.

hoangduoc0603 commented 2 years ago

Hi @jonnybach. My framework is a fat framework so can it have module stability enabled or i need to build it as xcframework?? Thanks!!

jonnybach commented 2 years ago

@hoangduoc0603 sorry for the delayed response. I have recently changed jobs so I was not active on GitHub with this account for a few weeks.

You may have already received your answer, but you don't have to build your framework as an xcframework b/c module stability has been enabled. However, I'd recommend you start supporting packaging any binaries of your frameworks as xcframeworks because:

  1. this is required if you wish to make your framework available for use with Swift Package Manager but wish to distribute it as a binary (as opposed to allowing SPM to build from source)
  2. you will never be able to provide a FAT framework that includes architectures for both Intel and ARM64 (M1/M2 chip) based Macs. This applies not only for frameworks for running on a Mac itself, but also for iOS simulators on Macs.

Hope this is helpful.