TZStackView icon indicating copy to clipboard operation
TZStackView copied to clipboard

Add a polyfill for Objective-C to select TZStackView only when UIStackView is Unavailable

Open fbartho opened this issue 9 years ago • 7 comments
trafficstars

This messes with xcode's preprocessor and the Objective-C runtime so that you as a developer can just write UIStackView, and not worry about the fact that TZStackView is used under the hood when you're on older-iOS Versions.

Then when you're ready to drop iOS 8.x, you can just delete TZStackView and none of the rest of your code will need to change.

fbartho avatar Nov 25 '15 21:11 fbartho

:+1:

thunky-monk avatar Nov 30 '15 19:11 thunky-monk

Have you looked at my PR #47? It uses an (arguably) better method that allows things like NSClassFromString("UIStackView") to work as well. It's a well defined trick pioneered by the PSTCollectionView folks.

It also aligns the enums with their UIKit counterparts as well.

kdubb avatar Dec 01 '15 02:12 kdubb

It seems @CosynPa, @fbartho, @andi357 & myself all have a vested interested in 100% iOS 8 compatibility and, some of us, want automatic support for interface builder; not to mention some level of iOS 7 compatibility.

Should figure out how to work together because we all seem to be reinventing some portion of the same wheel.

kdubb avatar Dec 01 '15 03:12 kdubb

I saw your PR @kdubb, and also PSTCollectionView's solutions to the Polyfill problem, but pulling in Assembly code was simply a non-starter with our existing shipping app and Engineering culture. (as an aside: does your assembly work with bitcode?). With the Preprocessor & alloc-override based solution from this PR we were able to convince the necessary parties to even start using StackViews at all.

iOS 7: When we started considering TZStackView, iOS 7 support was a requirement from on-high, but we successfully convinced them to drop it for new versions as the userbase numbers didn't justify it. This was overcome before the experimental branch with TZStackView was ready to undergo testing, so, now I'm neutral / don't require iOS 7 support.

Storyboards: Finally, we don't use Storyboards, the lack of Storyboard integration was an indifferent/neutral point for my team, but of course I support no-compromise solutions to that integration.

fbartho avatar Dec 01 '15 05:12 fbartho

After researching it a bit more I think there is a simpler solution using the mach-o library, thereby removing the assembly requirement. This would make it compatible with bitcode as well (not sure if assembly kills bitcode but it sure seems like it could).

kdubb avatar Dec 01 '15 06:12 kdubb

It it never guaranteed that a TZStackView has exactly the same behavior as a UIStackView. I think using UIStackView in iOS 9 and replacing it with TZStackView prior to iOS 8 is dangerous. And your approach would become very confusing if both Objective-C and Swift were used.

CosynPa avatar Dec 01 '15 12:12 CosynPa

@fbartho iOS 7 support is broken by a careless pull request #37 , and is already fixed by me #59 . I think TZStackView, as a library, should support iOS 7.

CosynPa avatar Dec 01 '15 12:12 CosynPa