Existential Any migration Script

This is a good question, quite a lot of code is going to need to be updated for this aspect of Swift 6 and it's not as simple as just adding any as you would be missing out on the subtle advantages of using some, opaque types.

There is, just enough information available using SourceKit to to identify where protocols are being referenced in source so I've written a small Swift "script" to attempt to help automate this conversion.

It follows the following:

There are a few extra edge cases handled using regular expressions and system protocol references are always elided to any to avoid breaking conformances. The script follows up by using the compiler with option -enable-upcoming-feature ExistentialAny to pick up any remaining missing anys and patches them in.

There will always be a few remaining errors to fix manually but it's working reasonably well. The results so far compiling the most popular Swift packages showing the deduplicated number of compilation errors compiling for option ExistentialAny before and after running the script are below.

repos/<rank>_<stars>_<name> ... #errors
repos/0001_37713_Alamofire/AFTER.txt      10
repos/0001_37713_Alamofire/BEFORE.txt     363
repos/0002_35061_fastlane/AFTER.txt       7
repos/0002_35061_fastlane/BEFORE.txt       7
repos/0003_25532_Charts/AFTER.txt      52
repos/0003_25532_Charts/BEFORE.txt     199
repos/0004_24159_SDWebImage/AFTER.txt       0
repos/0004_24159_SDWebImage/BEFORE.txt       0
repos/0005_22763_lottie-ios/BEFORE.txt       0
repos/0006_22232_RxSwift/AFTER.txt      26
repos/0006_22232_RxSwift/BEFORE.txt     761
repos/0007_21791_vapor/AFTER.txt       2
repos/0007_21791_vapor/BEFORE.txt       2
repos/0008_21366_SwiftyJSON/AFTER.txt       3
repos/0008_21366_SwiftyJSON/BEFORE.txt       8
repos/0009_20837_Hero/AFTER.txt       0
repos/0009_20837_Hero/BEFORE.txt       0
repos/0010_20172_Kingfisher/AFTER.txt      18
repos/0010_20172_Kingfisher/BEFORE.txt     109
repos/0011_18528_SnapKit/AFTER.txt       0
repos/0011_18528_SnapKit/BEFORE.txt      39
repos/0012_16168_SwiftLint/BEFORE.txt       0
repos/0013_15620_IQKeyboardManager/AFTER.txt       3
repos/0013_15620_IQKeyboardManager/BEFORE.txt       3
repos/0014_15353_realm-swift/AFTER.txt      17
repos/0014_15353_realm-swift/BEFORE.txt     235
repos/0015_14594_carthage/AFTER.txt       2
repos/0015_14594_carthage/BEFORE.txt       2
repos/0016_13989_Moya/AFTER.txt      62
repos/0016_13989_Moya/BEFORE.txt      62
repos/0017_13873_perfect/AFTER.txt       0
repos/0017_13873_perfect/BEFORE.txt       9
repos/0018_13854_PromiseKit/AFTER.txt       0
repos/0018_13854_PromiseKit/BEFORE.txt      24
repos/0019_13694_fmdb/AFTER.txt       0
repos/0019_13694_fmdb/BEFORE.txt       0
repos/0020_12703_CocoaLumberjack/AFTER.txt       2
repos/0020_12703_CocoaLumberjack/BEFORE.txt       2
repos/0021_12409_IGListKit/AFTER.txt       4
repos/0021_12409_IGListKit/BEFORE.txt       3
repos/0022_12209_CocoaAsyncSocket/AFTER.txt       0
repos/0022_12209_CocoaAsyncSocket/BEFORE.txt       0
repos/0023_11443_Eureka/AFTER.txt       3
repos/0023_11443_Eureka/BEFORE.txt       3
repos/0024_11225_SkeletonView/AFTER.txt       3
repos/0024_11225_SkeletonView/BEFORE.txt       3
repos/0025_11197_SwifterSwift/AFTER.txt       3
repos/0025_11197_SwifterSwift/BEFORE.txt      10
repos/0026_10141_NVActivityIndicatorView/AFTER.txt       0
repos/0026_10141_NVActivityIndicatorView/BEFORE.txt       0
repos/0027_9447_Quick/AFTER.txt       0
repos/0027_9447_Quick/BEFORE.txt       5
repos/0028_9173_AudioKit/AFTER.txt       0
repos/0028_9173_AudioKit/BEFORE.txt     150
repos/0029_9100_CryptoSwift/AFTER.txt      16
repos/0029_9100_CryptoSwift/BEFORE.txt      65
repos/0030_8962_ObjectMapper/AFTER.txt       0
repos/0030_8962_ObjectMapper/BEFORE.txt      20
repos/0031_8800_swift-package-manager/AFTER.txt       1
repos/0031_8800_swift-package-manager/BEFORE.txt       1
repos/0032_8687_R.swift/AFTER.txt       2
repos/0032_8687_R.swift/BEFORE.txt       2
repos/0033_8620_IBAnimatable/AFTER.txt       3
repos/0033_8620_IBAnimatable/BEFORE.txt       3
repos/0034_8286_SQLite.swift/AFTER.txt      40
repos/0034_8286_SQLite.swift/BEFORE.txt     265
repos/0035_7972_swiftgen/AFTER.txt      10
repos/0035_7972_swiftgen/BEFORE.txt      10
repos/0036_7611_Reachability.swift/AFTER.txt       0
repos/0036_7611_Reachability.swift/BEFORE.txt       0
repos/0037_7572_PureLayout/AFTER.txt       0
repos/0037_7572_PureLayout/BEFORE.txt       0
repos/0038_7529_Kitura/AFTER.txt       2
repos/0038_7529_Kitura/BEFORE.txt       2
repos/0039_7332_Starscream/AFTER.txt       0
repos/0039_7332_Starscream/BEFORE.txt      69
repos/0040_7295_Cartography/AFTER.txt      19
repos/0040_7295_Cartography/BEFORE.txt     104
repos/0041_7206_ReSwift/AFTER.txt       7
repos/0041_7206_ReSwift/BEFORE.txt      14
repos/0042_7187_JTAppleCalendar/AFTER.txt       3
repos/0042_7187_JTAppleCalendar/BEFORE.txt       3
repos/0043_7150_JVFloatLabeledTextField/AFTER.txt       2
repos/0043_7150_JVFloatLabeledTextField/BEFORE.txt       2
repos/0044_7087_facebook-ios-sdk/BEFORE.txt       0
repos/0045_7001_swift-nio/AFTER.txt       2
repos/0045_7001_swift-nio/BEFORE.txt       2
repos/0046_6939_RIBs/AFTER.txt      14
repos/0046_6939_RIBs/BEFORE.txt      14
repos/0047_6932_SwiftDate/AFTER.txt      31
repos/0047_6932_SwiftDate/BEFORE.txt      96
repos/0048_6922_KeychainAccess/AFTER.txt       0
repos/0048_6922_KeychainAccess/BEFORE.txt       5
repos/0049_6745_ViewAnimator/AFTER.txt       3
repos/0049_6745_ViewAnimator/BEFORE.txt       3
repos/0050_6703_Nuke/AFTER.txt      40
repos/0050_6703_Nuke/BEFORE.txt     113
repos/0051_6624_sourcery/AFTER.txt       2
repos/0051_6624_sourcery/BEFORE.txt       2
repos/0052_6545_SwiftMessages/AFTER.txt       3
repos/0052_6545_SwiftMessages/BEFORE.txt       3
repos/0053_6505_FSPagerView/AFTER.txt       3
repos/0053_6505_FSPagerView/BEFORE.txt       3
repos/0054_6300_swift-composable-architecture/AFTER.txt       2
repos/0054_6300_swift-composable-architecture/BEFORE.txt       2
repos/0055_6209_DTCoreText/AFTER.txt       1
repos/0055_6209_DTCoreText/BEFORE.txt       1
repos/0056_6117_KIF/AFTER.txt       4
repos/0056_6117_KIF/BEFORE.txt       4
repos/0057_6075_AMScrollingNavbar/AFTER.txt       3
repos/0057_6075_AMScrollingNavbar/BEFORE.txt       3
repos/0058_5992_SwiftyStoreKit/AFTER.txt       6
repos/0058_5992_SwiftyStoreKit/BEFORE.txt      56
repos/0059_5915_Sparkle/BEFORE.txt       0
repos/0060_5877_SwiftEntryKit/AFTER.txt       3
repos/0060_5877_SwiftEntryKit/BEFORE.txt       3
repos/0061_5851_swipecellkit/AFTER.txt       3
repos/0061_5851_swipecellkit/BEFORE.txt       3
repos/0062_5839_macaw/AFTER.txt       2
repos/0062_5839_macaw/BEFORE.txt       2
repos/0063_5763_SwiftFormat/AFTER.txt       0
repos/0063_5763_SwiftFormat/BEFORE.txt      19
repos/0064_5506_SwiftyBeaver/AFTER.txt       0
repos/0064_5506_SwiftyBeaver/BEFORE.txt      30
repos/0065_5481_XcodeGen/AFTER.txt      10
repos/0065_5481_XcodeGen/BEFORE.txt      10
repos/0066_5354_SideMenu/AFTER.txt       3
repos/0066_5354_SideMenu/BEFORE.txt       3
repos/0067_5298_Swinject/AFTER.txt       5
repos/0067_5298_Swinject/BEFORE.txt      76
repos/0068_5191_MessageKit/BEFORE.txt       0
repos/0069_5150_GRDB.swift/AFTER.txt      15
repos/0069_5150_GRDB.swift/BEFORE.txt     112
repos/0070_4997_Surge/AFTER.txt       0
repos/0070_4997_Surge/BEFORE.txt       0
repos/0071_4949_FloatingPanel/AFTER.txt       3
repos/0071_4949_FloatingPanel/BEFORE.txt       3
repos/0072_4941_PermissionsKit/AFTER.txt       3
repos/0072_4941_PermissionsKit/BEFORE.txt       3
repos/0073_4891_OHHTTPStubs/AFTER.txt       0
repos/0073_4891_OHHTTPStubs/BEFORE.txt       3
repos/0074_4862_Instructions/AFTER.txt       3
repos/0074_4862_Instructions/BEFORE.txt       3
repos/0075_4802_socket.io-client-swift/AFTER.txt       3
repos/0075_4802_socket.io-client-swift/BEFORE.txt       3
repos/0076_4744_gpuimage2/AFTER.txt       0
repos/0076_4744_gpuimage2/BEFORE.txt      29
repos/0077_4742_ESTabBarController/AFTER.txt       3
repos/0077_4742_ESTabBarController/BEFORE.txt       3
repos/0078_4726_SwiftUIX/AFTER.txt     101
repos/0078_4726_SwiftUIX/BEFORE.txt     101
repos/0079_4648_SwiftyUserDefaults/AFTER.txt       0
repos/0079_4648_SwiftyUserDefaults/BEFORE.txt       7
repos/0080_4617_async/AFTER.txt       0
repos/0080_4617_async/BEFORE.txt       0
repos/0081_4542_PhoneNumberKit/AFTER.txt       0
repos/0081_4542_PhoneNumberKit/BEFORE.txt       7
repos/0082_4462_Advance/AFTER.txt       0
repos/0082_4462_Advance/BEFORE.txt       0
repos/0083_4451_Nimble/AFTER.txt      21
repos/0083_4451_Nimble/BEFORE.txt      84
repos/0084_4405_AnimatedCollectionViewLayout/AFTER.txt       3
repos/0084_4405_AnimatedCollectionViewLayout/BEFORE.txt       3
repos/0085_4382_chartview/AFTER.txt       3
repos/0085_4382_chartview/BEFORE.txt       3
repos/0086_4381_swift-algorithms/AFTER.txt       0
repos/0086_4381_swift-algorithms/BEFORE.txt       0
repos/0087_4215_EFQRCode/AFTER.txt       0
repos/0087_4215_EFQRCode/BEFORE.txt       7
repos/0088_4212_bond/AFTER.txt       2
repos/0088_4212_bond/BEFORE.txt       2
repos/0089_4188_SVGKit/AFTER.txt       8
repos/0089_4188_SVGKit/BEFORE.txt       8
repos/0090_4101_Bagel/AFTER.txt       1
repos/0090_4101_Bagel/BEFORE.txt       1
repos/0091_4089_ActiveLabel.swift/AFTER.txt       3
repos/0091_4089_ActiveLabel.swift/BEFORE.txt       3
repos/0092_4019_Publish/AFTER.txt       2
repos/0092_4019_Publish/BEFORE.txt       2
repos/0093_3984_Siren/AFTER.txt       3
repos/0093_3984_Siren/BEFORE.txt       3
repos/0094_3959_SkyFloatingLabelTextField/AFTER.txt       3
repos/0094_3959_SkyFloatingLabelTextField/BEFORE.txt       3
repos/0095_3880_swift-protobuf/AFTER.txt      11
repos/0095_3880_swift-protobuf/BEFORE.txt     167
repos/0096_3840_Then/AFTER.txt       0
repos/0096_3840_Then/BEFORE.txt       0
repos/0097_3827_KSCrash/AFTER.txt       3
repos/0097_3827_KSCrash/BEFORE.txt       3
repos/0098_3827_MarqueeLabel/AFTER.txt       3
repos/0098_3827_MarqueeLabel/BEFORE.txt       3
repos/0099_3818_AlamofireImage/AFTER.txt      48
repos/0099_3818_AlamofireImage/BEFORE.txt      48
5 Likes