drmohundro / SWXMLHash

Simple XML parsing in Swift
MIT License
1.4k stars 203 forks source link

add module stability by enabling library evolution support #230

Closed divaproduct closed 4 years ago

divaproduct commented 4 years ago

Hi,

If you try to use SWXMLHash as a dependency in a Swift 5.1 based framework you will get the warning:

Module 'SWXMLHash' was not compiled with library evolution support; using it means binary compatibility for 'MyFramework' can't be guaranteed

To be able to use SWXMLHash using Swift >= 5.1 it need to be built with the flag BUILD_LIBRARY_FOR_DISTRIBUTION = YES. This PR enable it on both the xcodeproj and on the podspec. This is because otherwise during the pod install phase it will be ignored by cocoapods (see #9232)

For more information check this: ABI Stability and More and this: Binary Frameworks in Swift

Tested using Swift 5.1.3 and XCode 11.3 targetting an iOS project

Regards, R.

drmohundro commented 4 years ago

Hi @divaproduct, thanks for the PR - I'm commenting to 1) let you know I did see this and 2) to let you know I'm sitting on this for a bit... I read a few other comments on this (like https://github.com/Alamofire/Alamofire/issues/2990) where they're holding off on it because of the "the rather extreme restrictions it places on the library's evolution"... I'm admittedly not as familiar with what those extreme restrictions are, but I'd like to understand them prior to enabling this setting. Can you (or anyone else) elaborate on the pros and cons of the setting? Also, it looks like the CocoaPods issue referenced mentions that they might handle this with a future version out of the box?

divaproduct commented 4 years ago

I am not sure what are the "rather extreme limitations" of enabling this flag. They way I see it is that if you enable it you can keep distributing the lib as source code while also making it easier to create and manage pre-built binaries (without forking). Am I missing something ?

drmohundro commented 4 years ago

FYI, see this post on Swift.org - https://swift.org/blog/library-evolution/

From that post, it says (emphasis mine):

Frameworks that are always built and distributed together, such as Swift Package Manager packages or binary frameworks that are internal to your app, should not be built with library evolution support.

and...

Library evolution support should only be used when a framework is going to be built and updated separately from its clients.

Even though many consume this library via CocoaPods or Carthage, I suspect the future direction for pure Swift libraries is via the Swift Package Manager meaning that their recommendations are to not enable this feature. In addition, I wouldn't expect any consumers of SWXMLHash to want to receive a new version of it without also updating both other dependencies and their app, too.

The reasons to not enable this are also mentioned on that post. See the paragraph beginning with:

Enabling library evolution support changes your framework’s performance characteristics...

I hope this helps! I appreciate your interest and contribution regardless. Thanks again!