Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
hlung opened this issue Feb 22, 2021 · 5 comments
Open
1 task

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

hlung opened this issue Feb 22, 2021 · 5 comments
Assignees

Comments

@hlung
Copy link

hlung commented Feb 22, 2021

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

  • Set BUILD_LIBRARY_FOR_DISTRIBUTION build setting to Yes

References

@dcoufal
Copy link
Contributor

dcoufal commented Feb 23, 2021

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 jonnybach self-assigned this Jul 23, 2021
@jonnybach
Copy link
Member

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
Copy link
Member

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

@hoangduoc0603
Copy link

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
Copy link
Member

jonnybach commented Jun 9, 2022

@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.

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

No branches or pull requests

4 participants