evgenyneu / keychain-swift

Helper functions for saving text in Keychain securely for iOS, OS X, tvOS and watchOS.
MIT License
2.84k stars 345 forks source link

Allow static library usage from Cocoapods #74

Open bridger opened 6 years ago

bridger commented 6 years ago

Version 1.4.0 of Cocoapods allows a pod to be used as a static library, even in a Swift app. It requires the library's podspec to contain s.static_framework = true.

I believe this will help apps launch faster. Here's a blog post that explains why too many dynamic frameworks slows down launch: https://blog.automatic.com/how-we-cut-our-ios-apps-launch-time-in-half-with-this-one-cool-trick-7aca2011e2ea

evgenyneu commented 6 years ago

Hi @bridger, thanks for the update. If we add s.static_framework = true to the podspec file, what will happen to people who want to continue using our library the old way? Will it break things?

bridger commented 6 years ago

Honestly, I'm not sure... I guess the dynamic framework is nice if you don't want to repeat the binary size in each extension, like an Apple Watch binary that also uses Keychain?

For keychain-swift I'd imagine that binary size concern would be tiny. If people still needed to, they could make their own dynamic framework target which depends on keychain-swift then make their app and watch extension depend on that framework.

evgenyneu commented 6 years ago

That's good to know, thanks. I will do some Googling to see if there are any side effects that can affect our current users. In addition, I wonder if there is a way do switch to static framework on the client side, in Podfile instead of doing it for everyone in the podspec of the library?

evgenyneu commented 6 years ago

For the referece, I've asked about the side effects of static_framework=true on stackoverflow.

I can see two potential problems:

  1. One possible issue for us would be other dynamic frameworks that depend on keychain-swift. We may break those frameworks if we add static_framework = true, since dynamic frameworks can not depend on static ones (they say).

  2. If we add static_framework = true to the podspec, we will impose this for all users. But some users may not want that. I wonder if there is a way for the user to decide if they want the library to be static or dynamic?

bridger commented 6 years ago

Thanks for digging into this! Sorry it is more complicated than I thought it would be.

It would be awesome if CocoaPods allowed the app to choose whether it is imported statically or dynamically, but that option doesn't exist. I think Carthage allows the user of the library to choose. Let's see if the CocoaPods peeps will comment on what to do.