├── .gitignore ├── CombineExtensions ├── CombineExtensions.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── CombineExtensions │ ├── CombineExtensions.h │ ├── Info.plist │ ├── Protocols │ │ └── CombineCompatible.swift │ └── Publishers │ │ └── UIControlPublisher.swift └── CombineExtensionsTests │ ├── CombineExtensionsTests.swift │ └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 507A7CF222CCB74600223CDA /* CombineExtensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 507A7CE822CCB74600223CDA /* CombineExtensions.framework */; }; 11 | 507A7CF722CCB74600223CDA /* CombineExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507A7CF622CCB74600223CDA /* CombineExtensionsTests.swift */; }; 12 | 507A7CF922CCB74600223CDA /* CombineExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 507A7CEB22CCB74600223CDA /* CombineExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | 507A7D0422CCB78800223CDA /* UIControlPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507A7D0322CCB78800223CDA /* UIControlPublisher.swift */; }; 14 | 507A7D0722CCB80200223CDA /* CombineCompatible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507A7D0622CCB80200223CDA /* CombineCompatible.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | 507A7CF322CCB74600223CDA /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = 507A7CDF22CCB74600223CDA /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = 507A7CE722CCB74600223CDA; 23 | remoteInfo = CombineExtensions; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 507A7CE822CCB74600223CDA /* CombineExtensions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CombineExtensions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 507A7CEB22CCB74600223CDA /* CombineExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CombineExtensions.h; sourceTree = ""; }; 30 | 507A7CEC22CCB74600223CDA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 507A7CF122CCB74600223CDA /* CombineExtensionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CombineExtensionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 507A7CF622CCB74600223CDA /* CombineExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineExtensionsTests.swift; sourceTree = ""; }; 33 | 507A7CF822CCB74600223CDA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 507A7D0322CCB78800223CDA /* UIControlPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIControlPublisher.swift; sourceTree = ""; }; 35 | 507A7D0622CCB80200223CDA /* CombineCompatible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineCompatible.swift; sourceTree = ""; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | 507A7CE522CCB74600223CDA /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | 507A7CEE22CCB74600223CDA /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 507A7CF222CCB74600223CDA /* CombineExtensions.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 507A7CDE22CCB74600223CDA = { 58 | isa = PBXGroup; 59 | children = ( 60 | 507A7CEA22CCB74600223CDA /* CombineExtensions */, 61 | 507A7CF522CCB74600223CDA /* CombineExtensionsTests */, 62 | 507A7CE922CCB74600223CDA /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 507A7CE922CCB74600223CDA /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 507A7CE822CCB74600223CDA /* CombineExtensions.framework */, 70 | 507A7CF122CCB74600223CDA /* CombineExtensionsTests.xctest */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 507A7CEA22CCB74600223CDA /* CombineExtensions */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 507A7D0522CCB7E800223CDA /* Protocols */, 79 | 507A7D0222CCB77B00223CDA /* Publishers */, 80 | 507A7CEB22CCB74600223CDA /* CombineExtensions.h */, 81 | 507A7CEC22CCB74600223CDA /* Info.plist */, 82 | ); 83 | path = CombineExtensions; 84 | sourceTree = ""; 85 | }; 86 | 507A7CF522CCB74600223CDA /* CombineExtensionsTests */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 507A7CF622CCB74600223CDA /* CombineExtensionsTests.swift */, 90 | 507A7CF822CCB74600223CDA /* Info.plist */, 91 | ); 92 | path = CombineExtensionsTests; 93 | sourceTree = ""; 94 | }; 95 | 507A7D0222CCB77B00223CDA /* Publishers */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 507A7D0322CCB78800223CDA /* UIControlPublisher.swift */, 99 | ); 100 | path = Publishers; 101 | sourceTree = ""; 102 | }; 103 | 507A7D0522CCB7E800223CDA /* Protocols */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 507A7D0622CCB80200223CDA /* CombineCompatible.swift */, 107 | ); 108 | path = Protocols; 109 | sourceTree = ""; 110 | }; 111 | /* End PBXGroup section */ 112 | 113 | /* Begin PBXHeadersBuildPhase section */ 114 | 507A7CE322CCB74600223CDA /* Headers */ = { 115 | isa = PBXHeadersBuildPhase; 116 | buildActionMask = 2147483647; 117 | files = ( 118 | 507A7CF922CCB74600223CDA /* CombineExtensions.h in Headers */, 119 | ); 120 | runOnlyForDeploymentPostprocessing = 0; 121 | }; 122 | /* End PBXHeadersBuildPhase section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 507A7CE722CCB74600223CDA /* CombineExtensions */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 507A7CFC22CCB74600223CDA /* Build configuration list for PBXNativeTarget "CombineExtensions" */; 128 | buildPhases = ( 129 | 507A7CE322CCB74600223CDA /* Headers */, 130 | 507A7CE422CCB74600223CDA /* Sources */, 131 | 507A7CE522CCB74600223CDA /* Frameworks */, 132 | 507A7CE622CCB74600223CDA /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | ); 138 | name = CombineExtensions; 139 | productName = CombineExtensions; 140 | productReference = 507A7CE822CCB74600223CDA /* CombineExtensions.framework */; 141 | productType = "com.apple.product-type.framework"; 142 | }; 143 | 507A7CF022CCB74600223CDA /* CombineExtensionsTests */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 507A7CFF22CCB74600223CDA /* Build configuration list for PBXNativeTarget "CombineExtensionsTests" */; 146 | buildPhases = ( 147 | 507A7CED22CCB74600223CDA /* Sources */, 148 | 507A7CEE22CCB74600223CDA /* Frameworks */, 149 | 507A7CEF22CCB74600223CDA /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | 507A7CF422CCB74600223CDA /* PBXTargetDependency */, 155 | ); 156 | name = CombineExtensionsTests; 157 | productName = CombineExtensionsTests; 158 | productReference = 507A7CF122CCB74600223CDA /* CombineExtensionsTests.xctest */; 159 | productType = "com.apple.product-type.bundle.unit-test"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | 507A7CDF22CCB74600223CDA /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | LastSwiftUpdateCheck = 1100; 168 | LastUpgradeCheck = 1100; 169 | ORGANIZATIONNAME = SwiftLee; 170 | TargetAttributes = { 171 | 507A7CE722CCB74600223CDA = { 172 | CreatedOnToolsVersion = 11.0; 173 | LastSwiftMigration = 1100; 174 | }; 175 | 507A7CF022CCB74600223CDA = { 176 | CreatedOnToolsVersion = 11.0; 177 | }; 178 | }; 179 | }; 180 | buildConfigurationList = 507A7CE222CCB74600223CDA /* Build configuration list for PBXProject "CombineExtensions" */; 181 | compatibilityVersion = "Xcode 9.3"; 182 | developmentRegion = en; 183 | hasScannedForEncodings = 0; 184 | knownRegions = ( 185 | en, 186 | Base, 187 | ); 188 | mainGroup = 507A7CDE22CCB74600223CDA; 189 | productRefGroup = 507A7CE922CCB74600223CDA /* Products */; 190 | projectDirPath = ""; 191 | projectRoot = ""; 192 | targets = ( 193 | 507A7CE722CCB74600223CDA /* CombineExtensions */, 194 | 507A7CF022CCB74600223CDA /* CombineExtensionsTests */, 195 | ); 196 | }; 197 | /* End PBXProject section */ 198 | 199 | /* Begin PBXResourcesBuildPhase section */ 200 | 507A7CE622CCB74600223CDA /* Resources */ = { 201 | isa = PBXResourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | 507A7CEF22CCB74600223CDA /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | /* End PBXResourcesBuildPhase section */ 215 | 216 | /* Begin PBXSourcesBuildPhase section */ 217 | 507A7CE422CCB74600223CDA /* Sources */ = { 218 | isa = PBXSourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | 507A7D0422CCB78800223CDA /* UIControlPublisher.swift in Sources */, 222 | 507A7D0722CCB80200223CDA /* CombineCompatible.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | 507A7CED22CCB74600223CDA /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | 507A7CF722CCB74600223CDA /* CombineExtensionsTests.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXSourcesBuildPhase section */ 235 | 236 | /* Begin PBXTargetDependency section */ 237 | 507A7CF422CCB74600223CDA /* PBXTargetDependency */ = { 238 | isa = PBXTargetDependency; 239 | target = 507A7CE722CCB74600223CDA /* CombineExtensions */; 240 | targetProxy = 507A7CF322CCB74600223CDA /* PBXContainerItemProxy */; 241 | }; 242 | /* End PBXTargetDependency section */ 243 | 244 | /* Begin XCBuildConfiguration section */ 245 | 507A7CFA22CCB74600223CDA /* Debug */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_ANALYZER_NONNULL = YES; 250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | COPY_PHASE_STRIP = NO; 278 | CURRENT_PROJECT_VERSION = 1; 279 | DEBUG_INFORMATION_FORMAT = dwarf; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | ENABLE_TESTABILITY = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu11; 283 | GCC_DYNAMIC_NO_PIC = NO; 284 | GCC_NO_COMMON_BLOCKS = YES; 285 | GCC_OPTIMIZATION_LEVEL = 0; 286 | GCC_PREPROCESSOR_DEFINITIONS = ( 287 | "DEBUG=1", 288 | "$(inherited)", 289 | ); 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 297 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 298 | MTL_FAST_MATH = YES; 299 | ONLY_ACTIVE_ARCH = YES; 300 | SDKROOT = iphoneos; 301 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 302 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 303 | VERSIONING_SYSTEM = "apple-generic"; 304 | VERSION_INFO_PREFIX = ""; 305 | }; 306 | name = Debug; 307 | }; 308 | 507A7CFB22CCB74600223CDA /* Release */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | ALWAYS_SEARCH_USER_PATHS = NO; 312 | CLANG_ANALYZER_NONNULL = YES; 313 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 314 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 315 | CLANG_CXX_LIBRARY = "libc++"; 316 | CLANG_ENABLE_MODULES = YES; 317 | CLANG_ENABLE_OBJC_ARC = YES; 318 | CLANG_ENABLE_OBJC_WEAK = YES; 319 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 320 | CLANG_WARN_BOOL_CONVERSION = YES; 321 | CLANG_WARN_COMMA = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 325 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 326 | CLANG_WARN_EMPTY_BODY = YES; 327 | CLANG_WARN_ENUM_CONVERSION = YES; 328 | CLANG_WARN_INFINITE_RECURSION = YES; 329 | CLANG_WARN_INT_CONVERSION = YES; 330 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 331 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 332 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 333 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 334 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 335 | CLANG_WARN_STRICT_PROTOTYPES = YES; 336 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 337 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 338 | CLANG_WARN_UNREACHABLE_CODE = YES; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | COPY_PHASE_STRIP = NO; 341 | CURRENT_PROJECT_VERSION = 1; 342 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 343 | ENABLE_NS_ASSERTIONS = NO; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | GCC_C_LANGUAGE_STANDARD = gnu11; 346 | GCC_NO_COMMON_BLOCKS = YES; 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 354 | MTL_ENABLE_DEBUG_INFO = NO; 355 | MTL_FAST_MATH = YES; 356 | SDKROOT = iphoneos; 357 | SWIFT_COMPILATION_MODE = wholemodule; 358 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 359 | VALIDATE_PRODUCT = YES; 360 | VERSIONING_SYSTEM = "apple-generic"; 361 | VERSION_INFO_PREFIX = ""; 362 | }; 363 | name = Release; 364 | }; 365 | 507A7CFD22CCB74600223CDA /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | CLANG_ENABLE_MODULES = YES; 369 | CODE_SIGN_STYLE = Automatic; 370 | DEFINES_MODULE = YES; 371 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 372 | DYLIB_COMPATIBILITY_VERSION = 1; 373 | DYLIB_CURRENT_VERSION = 1; 374 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 375 | INFOPLIST_FILE = CombineExtensions/Info.plist; 376 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 377 | LD_RUNPATH_SEARCH_PATHS = ( 378 | "$(inherited)", 379 | "@executable_path/Frameworks", 380 | "@loader_path/Frameworks", 381 | ); 382 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftLee.CombineExtensions; 383 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 384 | SKIP_INSTALL = YES; 385 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 386 | SWIFT_VERSION = 5.0; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Debug; 390 | }; 391 | 507A7CFE22CCB74600223CDA /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | CLANG_ENABLE_MODULES = YES; 395 | CODE_SIGN_STYLE = Automatic; 396 | DEFINES_MODULE = YES; 397 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 398 | DYLIB_COMPATIBILITY_VERSION = 1; 399 | DYLIB_CURRENT_VERSION = 1; 400 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 401 | INFOPLIST_FILE = CombineExtensions/Info.plist; 402 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 403 | LD_RUNPATH_SEARCH_PATHS = ( 404 | "$(inherited)", 405 | "@executable_path/Frameworks", 406 | "@loader_path/Frameworks", 407 | ); 408 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftLee.CombineExtensions; 409 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 410 | SKIP_INSTALL = YES; 411 | SWIFT_VERSION = 5.0; 412 | TARGETED_DEVICE_FAMILY = "1,2"; 413 | }; 414 | name = Release; 415 | }; 416 | 507A7D0022CCB74600223CDA /* Debug */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 420 | CODE_SIGN_STYLE = Automatic; 421 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 422 | INFOPLIST_FILE = CombineExtensionsTests/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = ( 424 | "$(inherited)", 425 | "@executable_path/Frameworks", 426 | "@loader_path/Frameworks", 427 | ); 428 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftLee.CombineExtensionsTests; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | SWIFT_VERSION = 5.0; 431 | TARGETED_DEVICE_FAMILY = "1,2"; 432 | }; 433 | name = Debug; 434 | }; 435 | 507A7D0122CCB74600223CDA /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | buildSettings = { 438 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 439 | CODE_SIGN_STYLE = Automatic; 440 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 441 | INFOPLIST_FILE = CombineExtensionsTests/Info.plist; 442 | LD_RUNPATH_SEARCH_PATHS = ( 443 | "$(inherited)", 444 | "@executable_path/Frameworks", 445 | "@loader_path/Frameworks", 446 | ); 447 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftLee.CombineExtensionsTests; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | SWIFT_VERSION = 5.0; 450 | TARGETED_DEVICE_FAMILY = "1,2"; 451 | }; 452 | name = Release; 453 | }; 454 | /* End XCBuildConfiguration section */ 455 | 456 | /* Begin XCConfigurationList section */ 457 | 507A7CE222CCB74600223CDA /* Build configuration list for PBXProject "CombineExtensions" */ = { 458 | isa = XCConfigurationList; 459 | buildConfigurations = ( 460 | 507A7CFA22CCB74600223CDA /* Debug */, 461 | 507A7CFB22CCB74600223CDA /* Release */, 462 | ); 463 | defaultConfigurationIsVisible = 0; 464 | defaultConfigurationName = Release; 465 | }; 466 | 507A7CFC22CCB74600223CDA /* Build configuration list for PBXNativeTarget "CombineExtensions" */ = { 467 | isa = XCConfigurationList; 468 | buildConfigurations = ( 469 | 507A7CFD22CCB74600223CDA /* Debug */, 470 | 507A7CFE22CCB74600223CDA /* Release */, 471 | ); 472 | defaultConfigurationIsVisible = 0; 473 | defaultConfigurationName = Release; 474 | }; 475 | 507A7CFF22CCB74600223CDA /* Build configuration list for PBXNativeTarget "CombineExtensionsTests" */ = { 476 | isa = XCConfigurationList; 477 | buildConfigurations = ( 478 | 507A7D0022CCB74600223CDA /* Debug */, 479 | 507A7D0122CCB74600223CDA /* Release */, 480 | ); 481 | defaultConfigurationIsVisible = 0; 482 | defaultConfigurationName = Release; 483 | }; 484 | /* End XCConfigurationList section */ 485 | }; 486 | rootObject = 507A7CDF22CCB74600223CDA /* Project object */; 487 | } 488 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions/CombineExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CombineExtensions.h 3 | // CombineExtensions 4 | // 5 | // Created by Antoine van der Lee on 03/07/2019. 6 | // Copyright © 2019 SwiftLee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CombineExtensions. 12 | FOUNDATION_EXPORT double CombineExtensionsVersionNumber; 13 | 14 | //! Project version string for CombineExtensions. 15 | FOUNDATION_EXPORT const unsigned char CombineExtensionsVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions/Protocols/CombineCompatible.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CombineCompatible.swift 3 | // CombineExtensions 4 | // 5 | // Created by Antoine van der Lee on 03/07/2019. 6 | // Copyright © 2019 SwiftLee. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | import Combine 12 | 13 | public protocol CombineCompatible { } 14 | extension UIControl: CombineCompatible { } 15 | 16 | extension CombineCompatible { 17 | public func assign(_ publisher: P, to keyPath: ReferenceWritableKeyPath) -> AnyCancellable where P.Failure == Never { 18 | return publisher.assign(to: keyPath, on: self) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensions/Publishers/UIControlPublisher.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIControlPublisher.swift 3 | // CombineExtensions 4 | // 5 | // Created by Antoine van der Lee on 03/07/2019. 6 | // Copyright © 2019 SwiftLee. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | import Combine 12 | 13 | /// A custom subscription to capture UIControl target events. 14 | final class UIControlSubscription: Subscription where SubscriberType.Input == Control { 15 | private var subscriber: SubscriberType? 16 | private let control: Control 17 | 18 | init(subscriber: SubscriberType, control: Control, event: UIControl.Event) { 19 | self.subscriber = subscriber 20 | self.control = control 21 | control.addTarget(self, action: #selector(eventHandler), for: event) 22 | } 23 | 24 | func request(_ demand: Subscribers.Demand) { 25 | // We do nothing here as we only want to send events when they occur. 26 | // See, for more info: https://developer.apple.com/documentation/combine/subscribers/demand 27 | } 28 | 29 | func cancel() { 30 | subscriber = nil 31 | } 32 | 33 | @objc private func eventHandler() { 34 | _ = subscriber?.receive(control) 35 | } 36 | 37 | deinit { 38 | print("UIControlTarget deinit") 39 | } 40 | } 41 | 42 | /// A custom `Publisher` to work with our custom `UIControlSubscription`. 43 | public struct UIControlPublisher: Publisher { 44 | 45 | public typealias Output = Control 46 | public typealias Failure = Never 47 | 48 | let control: Control 49 | let controlEvents: UIControl.Event 50 | 51 | public init(control: Control, events: UIControl.Event) { 52 | self.control = control 53 | self.controlEvents = events 54 | } 55 | 56 | /// This function is called to attach the specified `Subscriber` to this `Publisher` by `subscribe(_:)` 57 | /// 58 | /// - SeeAlso: `subscribe(_:)` 59 | /// - Parameters: 60 | /// - subscriber: The subscriber to attach to this `Publisher`. 61 | /// once attached it can begin to receive values. 62 | public func receive(subscriber: S) where S : Subscriber, S.Failure == UIControlPublisher.Failure, S.Input == UIControlPublisher.Output { 63 | subscriber.receive(subscription: UIControlSubscription(subscriber: subscriber, control: control, event: controlEvents)) 64 | } 65 | } 66 | 67 | /// Extending the `UIControl` types to be able to produce a `UIControl.Event` publisher. 68 | extension CombineCompatible where Self: UIControl { 69 | public func publisher(for events: UIControl.Event) -> UIControlPublisher { 70 | return UIControlPublisher(control: self, events: events) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensionsTests/CombineExtensionsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CombineExtensionsTests.swift 3 | // CombineExtensionsTests 4 | // 5 | // Created by Antoine van der Lee on 03/07/2019. 6 | // Copyright © 2019 SwiftLee. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import CombineExtensions 11 | 12 | class CombineExtensionsTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /CombineExtensions/CombineExtensionsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Antoine van der Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Combine Extensions 2 | A collection of Combine Extensions to make it easier to work with Combine. 3 | 4 | ## Available extensions 5 | 6 | - `UIControl.publisher(for events: UIControl.Event)` to listen to UIControl events. 7 | - `NSObject.assign(_ publisher:, to keyPath:)` to have autocompletion for the key paths. 8 | 9 | # Useful resources 10 | 11 | - [Combine - Apple Developer Documentation](https://developer.apple.com/documentation/combine) 12 | - [Getting started with Combine](https://www.avanderlee.com/swift/combine/) 13 | - [Combine Swift Playground](https://github.com/AvdLee/CombineSwiftPlayground) 14 | --------------------------------------------------------------------------------