├── .gitignore ├── LICENSE.md ├── README.md ├── Sample App ├── WeakifyObject.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── WeakifyObject.xcscheme ├── WeakifyObject.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── WeakifyObject │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Business Logic │ │ └── FetchWeatherUseCase.swift │ ├── Info.plist │ ├── Presentation │ │ └── WeatherDataPresenter.swift │ ├── UI │ │ ├── Base.lproj │ │ │ └── Main.storyboard │ │ └── WeatherViewController.swift │ └── WeakRef+WeatherDataPresenterOutput.swift └── WeakifyObjectTests │ ├── AppDelegateTests.swift │ ├── Business Logic │ └── FetchWeatherUseCaseTests.swift │ ├── Info.plist │ ├── Presentation │ └── WeatherDataPresenterTests.swift │ └── UI │ └── WeatherViewControllerTests.swift └── WeakRef ├── WeakRef.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── WeakRef_iOS.xcscheme │ └── WeakRef_macOS.xcscheme ├── WeakRef ├── Info.plist └── WeakRef.swift └── WeakRefTests ├── Info.plist └── WeakRefTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/swift,xcode 2 | 3 | ### Swift ### 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | DerivedData/ 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | # Packages/ 42 | # Package.pins 43 | # Package.resolved 44 | .build/ 45 | 46 | # CocoaPods 47 | # 48 | # We recommend against adding the Pods directory to your .gitignore. However 49 | # you should judge for yourself, the pros and cons are mentioned at: 50 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 51 | # 52 | # Pods/ 53 | # 54 | # Add this line if you want to avoid checking in source code from the Xcode workspace 55 | # *.xcworkspace 56 | 57 | # Carthage 58 | # 59 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 60 | # Carthage/Checkouts 61 | 62 | Carthage/Build 63 | 64 | # fastlane 65 | # 66 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 67 | # screenshots whenever they are needed. 68 | # For more information about the recommended setup visit: 69 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 70 | 71 | fastlane/report.xml 72 | fastlane/Preview.html 73 | fastlane/screenshots/**/*.png 74 | fastlane/test_output 75 | 76 | ### Xcode ### 77 | # Xcode 78 | # 79 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 80 | 81 | ## User settings 82 | 83 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 84 | 85 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 86 | 87 | ### Xcode Patch ### 88 | *.xcodeproj/* 89 | !*.xcodeproj/project.pbxproj 90 | !*.xcodeproj/xcshareddata/ 91 | !*.xcworkspace/contents.xcworkspacedata 92 | /*.gcno 93 | 94 | # End of https://www.gitignore.io/api/swift,xcode -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Essential Developer 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 | # `WeakRef`: A Swift type-safe alternative to `weak` properties 2 | 3 | `WeakRef` is a type-safe alternative to `weak` properties that maintains a clean cross-boundary separation of concerns. 4 | 5 | ``` 6 | final class WeakRef { 7 | weak var object: T? 8 | 9 | init(_ object: T) { 10 | self.object = object 11 | } 12 | } 13 | ``` 14 | 15 | Usage example: 16 | 17 | ``` 18 | let vc = WeatherViewController() 19 | let presenter = WeatherPresenter(view: WeakRef(vc)) 20 | vc.presenter = presenter 21 | ``` 22 | 23 | Learn more at: https://www.essentialdeveloper.com/articles/clean-ios-architecture-pt-4-clean-memory-management-in-swift-with-weakref -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 082B82C22121BDEF00F12E38 /* WeatherDataPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082B82C12121BDEF00F12E38 /* WeatherDataPresenter.swift */; }; 11 | 082B82C52121BE3D00F12E38 /* WeatherDataPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082B82C42121BE3D00F12E38 /* WeatherDataPresenterTests.swift */; }; 12 | 086F6DF12121C65500442CCB /* AppDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086F6DF02121C65500442CCB /* AppDelegateTests.swift */; }; 13 | 086F6DF52121E74C00442CCB /* WeakRef+WeatherDataPresenterOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086F6DF42121E74C00442CCB /* WeakRef+WeatherDataPresenterOutput.swift */; }; 14 | 0877D5CE21218EE2008448EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877D5CD21218EE2008448EF /* AppDelegate.swift */; }; 15 | 0877D5D021218EE2008448EF /* WeatherViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877D5CF21218EE2008448EF /* WeatherViewController.swift */; }; 16 | 0877D5D321218EE2008448EF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0877D5D121218EE2008448EF /* Main.storyboard */; }; 17 | 0877D5D521218EE3008448EF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0877D5D421218EE3008448EF /* Assets.xcassets */; }; 18 | 0877D5D821218EE3008448EF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0877D5D621218EE3008448EF /* LaunchScreen.storyboard */; }; 19 | 0877D5F221219B1D008448EF /* WeatherViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877D5F121219B1D008448EF /* WeatherViewControllerTests.swift */; }; 20 | 0877D5FA2121BA33008448EF /* FetchWeatherUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877D5F92121BA33008448EF /* FetchWeatherUseCase.swift */; }; 21 | 0877D6002121BA97008448EF /* FetchWeatherUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877D5FF2121BA97008448EF /* FetchWeatherUseCaseTests.swift */; }; 22 | 08CD0F60212362B100D81726 /* WeakRef.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD0F5F212362B100D81726 /* WeakRef.framework */; }; 23 | 08CD0F61212362B100D81726 /* WeakRef.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD0F5F212362B100D81726 /* WeakRef.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | 0877D5DF21218EE3008448EF /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 0877D5C221218EE2008448EF /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 0877D5C921218EE2008448EF; 32 | remoteInfo = WeakifyObject; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXCopyFilesBuildPhase section */ 37 | 089AD8312123621000875B8F /* Embed Frameworks */ = { 38 | isa = PBXCopyFilesBuildPhase; 39 | buildActionMask = 2147483647; 40 | dstPath = ""; 41 | dstSubfolderSpec = 10; 42 | files = ( 43 | 08CD0F61212362B100D81726 /* WeakRef.framework in Embed Frameworks */, 44 | ); 45 | name = "Embed Frameworks"; 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXCopyFilesBuildPhase section */ 49 | 50 | /* Begin PBXFileReference section */ 51 | 082B82C12121BDEF00F12E38 /* WeatherDataPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherDataPresenter.swift; sourceTree = ""; }; 52 | 082B82C42121BE3D00F12E38 /* WeatherDataPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherDataPresenterTests.swift; sourceTree = ""; }; 53 | 086F6DF02121C65500442CCB /* AppDelegateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegateTests.swift; sourceTree = ""; }; 54 | 086F6DF42121E74C00442CCB /* WeakRef+WeatherDataPresenterOutput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WeakRef+WeatherDataPresenterOutput.swift"; sourceTree = ""; }; 55 | 0877D5CA21218EE2008448EF /* WeakifyObject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WeakifyObject.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 0877D5CD21218EE2008448EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 57 | 0877D5CF21218EE2008448EF /* WeatherViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherViewController.swift; sourceTree = ""; }; 58 | 0877D5D221218EE2008448EF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 59 | 0877D5D421218EE3008448EF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 60 | 0877D5D721218EE3008448EF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 61 | 0877D5D921218EE3008448EF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | 0877D5DE21218EE3008448EF /* WeakifyObjectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WeakifyObjectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 0877D5E421218EE3008448EF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 0877D5F121219B1D008448EF /* WeatherViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherViewControllerTests.swift; sourceTree = ""; }; 65 | 0877D5F92121BA33008448EF /* FetchWeatherUseCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchWeatherUseCase.swift; sourceTree = ""; }; 66 | 0877D5FF2121BA97008448EF /* FetchWeatherUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchWeatherUseCaseTests.swift; sourceTree = ""; }; 67 | 08CD0F5F212362B100D81726 /* WeakRef.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WeakRef.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | 0877D5C721218EE2008448EF /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | 08CD0F60212362B100D81726 /* WeakRef.framework in Frameworks */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 0877D5DB21218EE3008448EF /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | /* End PBXFrameworksBuildPhase section */ 87 | 88 | /* Begin PBXGroup section */ 89 | 082B82C02121BDD600F12E38 /* Presentation */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 082B82C12121BDEF00F12E38 /* WeatherDataPresenter.swift */, 93 | ); 94 | path = Presentation; 95 | sourceTree = ""; 96 | }; 97 | 082B82C32121BE2200F12E38 /* Presentation */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 082B82C42121BE3D00F12E38 /* WeatherDataPresenterTests.swift */, 101 | ); 102 | path = Presentation; 103 | sourceTree = ""; 104 | }; 105 | 082B82C62121C3EA00F12E38 /* UI */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 0877D5CF21218EE2008448EF /* WeatherViewController.swift */, 109 | 0877D5D121218EE2008448EF /* Main.storyboard */, 110 | ); 111 | path = UI; 112 | sourceTree = ""; 113 | }; 114 | 082B82C72121C41200F12E38 /* UI */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 0877D5F121219B1D008448EF /* WeatherViewControllerTests.swift */, 118 | ); 119 | path = UI; 120 | sourceTree = ""; 121 | }; 122 | 082B82C82121C46E00F12E38 /* Main */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 0877D5CD21218EE2008448EF /* AppDelegate.swift */, 126 | 086F6DF42121E74C00442CCB /* WeakRef+WeatherDataPresenterOutput.swift */, 127 | 083FB28E2121C4AA006348B8 /* Supporting Files */, 128 | ); 129 | name = Main; 130 | sourceTree = ""; 131 | }; 132 | 083FB28E2121C4AA006348B8 /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 0877D5D421218EE3008448EF /* Assets.xcassets */, 136 | 0877D5D621218EE3008448EF /* LaunchScreen.storyboard */, 137 | 0877D5D921218EE3008448EF /* Info.plist */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | 083FB28F2121C4BF006348B8 /* Main */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 086F6DF02121C65500442CCB /* AppDelegateTests.swift */, 146 | 0877D5E421218EE3008448EF /* Info.plist */, 147 | ); 148 | name = Main; 149 | sourceTree = ""; 150 | }; 151 | 0877D5C121218EE2008448EF = { 152 | isa = PBXGroup; 153 | children = ( 154 | 0877D5CC21218EE2008448EF /* WeakifyObject */, 155 | 0877D5E121218EE3008448EF /* WeakifyObjectTests */, 156 | 0877D5CB21218EE2008448EF /* Products */, 157 | 08CD0F5F212362B100D81726 /* WeakRef.framework */, 158 | ); 159 | sourceTree = ""; 160 | }; 161 | 0877D5CB21218EE2008448EF /* Products */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 0877D5CA21218EE2008448EF /* WeakifyObject.app */, 165 | 0877D5DE21218EE3008448EF /* WeakifyObjectTests.xctest */, 166 | ); 167 | name = Products; 168 | sourceTree = ""; 169 | }; 170 | 0877D5CC21218EE2008448EF /* WeakifyObject */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 0877D5F82121BA05008448EF /* Business Logic */, 174 | 082B82C02121BDD600F12E38 /* Presentation */, 175 | 082B82C62121C3EA00F12E38 /* UI */, 176 | 082B82C82121C46E00F12E38 /* Main */, 177 | ); 178 | path = WeakifyObject; 179 | sourceTree = ""; 180 | }; 181 | 0877D5E121218EE3008448EF /* WeakifyObjectTests */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | 0877D5FE2121BA89008448EF /* Business Logic */, 185 | 082B82C32121BE2200F12E38 /* Presentation */, 186 | 082B82C72121C41200F12E38 /* UI */, 187 | 083FB28F2121C4BF006348B8 /* Main */, 188 | ); 189 | path = WeakifyObjectTests; 190 | sourceTree = ""; 191 | }; 192 | 0877D5F82121BA05008448EF /* Business Logic */ = { 193 | isa = PBXGroup; 194 | children = ( 195 | 0877D5F92121BA33008448EF /* FetchWeatherUseCase.swift */, 196 | ); 197 | path = "Business Logic"; 198 | sourceTree = ""; 199 | }; 200 | 0877D5FE2121BA89008448EF /* Business Logic */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | 0877D5FF2121BA97008448EF /* FetchWeatherUseCaseTests.swift */, 204 | ); 205 | path = "Business Logic"; 206 | sourceTree = ""; 207 | }; 208 | /* End PBXGroup section */ 209 | 210 | /* Begin PBXNativeTarget section */ 211 | 0877D5C921218EE2008448EF /* WeakifyObject */ = { 212 | isa = PBXNativeTarget; 213 | buildConfigurationList = 0877D5E721218EE3008448EF /* Build configuration list for PBXNativeTarget "WeakifyObject" */; 214 | buildPhases = ( 215 | 0877D5C621218EE2008448EF /* Sources */, 216 | 0877D5C721218EE2008448EF /* Frameworks */, 217 | 0877D5C821218EE2008448EF /* Resources */, 218 | 089AD8312123621000875B8F /* Embed Frameworks */, 219 | ); 220 | buildRules = ( 221 | ); 222 | dependencies = ( 223 | ); 224 | name = WeakifyObject; 225 | productName = WeakifyObject; 226 | productReference = 0877D5CA21218EE2008448EF /* WeakifyObject.app */; 227 | productType = "com.apple.product-type.application"; 228 | }; 229 | 0877D5DD21218EE3008448EF /* WeakifyObjectTests */ = { 230 | isa = PBXNativeTarget; 231 | buildConfigurationList = 0877D5EA21218EE3008448EF /* Build configuration list for PBXNativeTarget "WeakifyObjectTests" */; 232 | buildPhases = ( 233 | 0877D5DA21218EE3008448EF /* Sources */, 234 | 0877D5DB21218EE3008448EF /* Frameworks */, 235 | 0877D5DC21218EE3008448EF /* Resources */, 236 | ); 237 | buildRules = ( 238 | ); 239 | dependencies = ( 240 | 0877D5E021218EE3008448EF /* PBXTargetDependency */, 241 | ); 242 | name = WeakifyObjectTests; 243 | productName = WeakifyObjectTests; 244 | productReference = 0877D5DE21218EE3008448EF /* WeakifyObjectTests.xctest */; 245 | productType = "com.apple.product-type.bundle.unit-test"; 246 | }; 247 | /* End PBXNativeTarget section */ 248 | 249 | /* Begin PBXProject section */ 250 | 0877D5C221218EE2008448EF /* Project object */ = { 251 | isa = PBXProject; 252 | attributes = { 253 | LastSwiftUpdateCheck = 0940; 254 | LastUpgradeCheck = 0940; 255 | ORGANIZATIONNAME = "Essential Developer"; 256 | TargetAttributes = { 257 | 0877D5C921218EE2008448EF = { 258 | CreatedOnToolsVersion = 9.4.1; 259 | }; 260 | 0877D5DD21218EE3008448EF = { 261 | CreatedOnToolsVersion = 9.4.1; 262 | LastSwiftMigration = 0940; 263 | TestTargetID = 0877D5C921218EE2008448EF; 264 | }; 265 | }; 266 | }; 267 | buildConfigurationList = 0877D5C521218EE2008448EF /* Build configuration list for PBXProject "WeakifyObject" */; 268 | compatibilityVersion = "Xcode 9.3"; 269 | developmentRegion = en; 270 | hasScannedForEncodings = 0; 271 | knownRegions = ( 272 | en, 273 | Base, 274 | ); 275 | mainGroup = 0877D5C121218EE2008448EF; 276 | productRefGroup = 0877D5CB21218EE2008448EF /* Products */; 277 | projectDirPath = ""; 278 | projectRoot = ""; 279 | targets = ( 280 | 0877D5C921218EE2008448EF /* WeakifyObject */, 281 | 0877D5DD21218EE3008448EF /* WeakifyObjectTests */, 282 | ); 283 | }; 284 | /* End PBXProject section */ 285 | 286 | /* Begin PBXResourcesBuildPhase section */ 287 | 0877D5C821218EE2008448EF /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 0877D5D821218EE3008448EF /* LaunchScreen.storyboard in Resources */, 292 | 0877D5D521218EE3008448EF /* Assets.xcassets in Resources */, 293 | 0877D5D321218EE2008448EF /* Main.storyboard in Resources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | 0877D5DC21218EE3008448EF /* Resources */ = { 298 | isa = PBXResourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | ); 302 | runOnlyForDeploymentPostprocessing = 0; 303 | }; 304 | /* End PBXResourcesBuildPhase section */ 305 | 306 | /* Begin PBXSourcesBuildPhase section */ 307 | 0877D5C621218EE2008448EF /* Sources */ = { 308 | isa = PBXSourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | 0877D5FA2121BA33008448EF /* FetchWeatherUseCase.swift in Sources */, 312 | 0877D5D021218EE2008448EF /* WeatherViewController.swift in Sources */, 313 | 0877D5CE21218EE2008448EF /* AppDelegate.swift in Sources */, 314 | 086F6DF52121E74C00442CCB /* WeakRef+WeatherDataPresenterOutput.swift in Sources */, 315 | 082B82C22121BDEF00F12E38 /* WeatherDataPresenter.swift in Sources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | 0877D5DA21218EE3008448EF /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | 086F6DF12121C65500442CCB /* AppDelegateTests.swift in Sources */, 324 | 0877D5F221219B1D008448EF /* WeatherViewControllerTests.swift in Sources */, 325 | 082B82C52121BE3D00F12E38 /* WeatherDataPresenterTests.swift in Sources */, 326 | 0877D6002121BA97008448EF /* FetchWeatherUseCaseTests.swift in Sources */, 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | }; 330 | /* End PBXSourcesBuildPhase section */ 331 | 332 | /* Begin PBXTargetDependency section */ 333 | 0877D5E021218EE3008448EF /* PBXTargetDependency */ = { 334 | isa = PBXTargetDependency; 335 | target = 0877D5C921218EE2008448EF /* WeakifyObject */; 336 | targetProxy = 0877D5DF21218EE3008448EF /* PBXContainerItemProxy */; 337 | }; 338 | /* End PBXTargetDependency section */ 339 | 340 | /* Begin PBXVariantGroup section */ 341 | 0877D5D121218EE2008448EF /* Main.storyboard */ = { 342 | isa = PBXVariantGroup; 343 | children = ( 344 | 0877D5D221218EE2008448EF /* Base */, 345 | ); 346 | name = Main.storyboard; 347 | sourceTree = ""; 348 | }; 349 | 0877D5D621218EE3008448EF /* LaunchScreen.storyboard */ = { 350 | isa = PBXVariantGroup; 351 | children = ( 352 | 0877D5D721218EE3008448EF /* Base */, 353 | ); 354 | name = LaunchScreen.storyboard; 355 | sourceTree = ""; 356 | }; 357 | /* End PBXVariantGroup section */ 358 | 359 | /* Begin XCBuildConfiguration section */ 360 | 0877D5E521218EE3008448EF /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ALWAYS_SEARCH_USER_PATHS = NO; 364 | CLANG_ANALYZER_NONNULL = YES; 365 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 366 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 367 | CLANG_CXX_LIBRARY = "libc++"; 368 | CLANG_ENABLE_MODULES = YES; 369 | CLANG_ENABLE_OBJC_ARC = YES; 370 | CLANG_ENABLE_OBJC_WEAK = YES; 371 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 372 | CLANG_WARN_BOOL_CONVERSION = YES; 373 | CLANG_WARN_COMMA = YES; 374 | CLANG_WARN_CONSTANT_CONVERSION = YES; 375 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 376 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 377 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 378 | CLANG_WARN_EMPTY_BODY = YES; 379 | CLANG_WARN_ENUM_CONVERSION = YES; 380 | CLANG_WARN_INFINITE_RECURSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 383 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 384 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 385 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 386 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 387 | CLANG_WARN_STRICT_PROTOTYPES = YES; 388 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 389 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | CODE_SIGN_IDENTITY = "iPhone Developer"; 393 | COPY_PHASE_STRIP = NO; 394 | DEBUG_INFORMATION_FORMAT = dwarf; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | ENABLE_TESTABILITY = YES; 397 | GCC_C_LANGUAGE_STANDARD = gnu11; 398 | GCC_DYNAMIC_NO_PIC = NO; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_OPTIMIZATION_LEVEL = 0; 401 | GCC_PREPROCESSOR_DEFINITIONS = ( 402 | "DEBUG=1", 403 | "$(inherited)", 404 | ); 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNDECLARED_SELECTOR = YES; 408 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 409 | GCC_WARN_UNUSED_FUNCTION = YES; 410 | GCC_WARN_UNUSED_VARIABLE = YES; 411 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 412 | MTL_ENABLE_DEBUG_INFO = YES; 413 | ONLY_ACTIVE_ARCH = YES; 414 | SDKROOT = iphoneos; 415 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 416 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 417 | }; 418 | name = Debug; 419 | }; 420 | 0877D5E621218EE3008448EF /* Release */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ALWAYS_SEARCH_USER_PATHS = NO; 424 | CLANG_ANALYZER_NONNULL = YES; 425 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 426 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 427 | CLANG_CXX_LIBRARY = "libc++"; 428 | CLANG_ENABLE_MODULES = YES; 429 | CLANG_ENABLE_OBJC_ARC = YES; 430 | CLANG_ENABLE_OBJC_WEAK = YES; 431 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 432 | CLANG_WARN_BOOL_CONVERSION = YES; 433 | CLANG_WARN_COMMA = YES; 434 | CLANG_WARN_CONSTANT_CONVERSION = YES; 435 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 436 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 437 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 438 | CLANG_WARN_EMPTY_BODY = YES; 439 | CLANG_WARN_ENUM_CONVERSION = YES; 440 | CLANG_WARN_INFINITE_RECURSION = YES; 441 | CLANG_WARN_INT_CONVERSION = YES; 442 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 443 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 444 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 445 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 446 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 447 | CLANG_WARN_STRICT_PROTOTYPES = YES; 448 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 449 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 450 | CLANG_WARN_UNREACHABLE_CODE = YES; 451 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 452 | CODE_SIGN_IDENTITY = "iPhone Developer"; 453 | COPY_PHASE_STRIP = NO; 454 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 455 | ENABLE_NS_ASSERTIONS = NO; 456 | ENABLE_STRICT_OBJC_MSGSEND = YES; 457 | GCC_C_LANGUAGE_STANDARD = gnu11; 458 | GCC_NO_COMMON_BLOCKS = YES; 459 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 460 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 461 | GCC_WARN_UNDECLARED_SELECTOR = YES; 462 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 463 | GCC_WARN_UNUSED_FUNCTION = YES; 464 | GCC_WARN_UNUSED_VARIABLE = YES; 465 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 466 | MTL_ENABLE_DEBUG_INFO = NO; 467 | SDKROOT = iphoneos; 468 | SWIFT_COMPILATION_MODE = wholemodule; 469 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 470 | VALIDATE_PRODUCT = YES; 471 | }; 472 | name = Release; 473 | }; 474 | 0877D5E821218EE3008448EF /* Debug */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 478 | CODE_SIGN_STYLE = Automatic; 479 | DEVELOPMENT_TEAM = VRJ2W4578X; 480 | INFOPLIST_FILE = WeakifyObject/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = ( 482 | "$(inherited)", 483 | "@executable_path/Frameworks", 484 | ); 485 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakifyObject; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | SWIFT_VERSION = 4.0; 488 | TARGETED_DEVICE_FAMILY = "1,2"; 489 | }; 490 | name = Debug; 491 | }; 492 | 0877D5E921218EE3008448EF /* Release */ = { 493 | isa = XCBuildConfiguration; 494 | buildSettings = { 495 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 496 | CODE_SIGN_STYLE = Automatic; 497 | DEVELOPMENT_TEAM = VRJ2W4578X; 498 | INFOPLIST_FILE = WeakifyObject/Info.plist; 499 | LD_RUNPATH_SEARCH_PATHS = ( 500 | "$(inherited)", 501 | "@executable_path/Frameworks", 502 | ); 503 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakifyObject; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | SWIFT_VERSION = 4.0; 506 | TARGETED_DEVICE_FAMILY = "1,2"; 507 | }; 508 | name = Release; 509 | }; 510 | 0877D5EB21218EE3008448EF /* Debug */ = { 511 | isa = XCBuildConfiguration; 512 | buildSettings = { 513 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 514 | BUNDLE_LOADER = "$(TEST_HOST)"; 515 | CLANG_ENABLE_MODULES = YES; 516 | CODE_SIGN_STYLE = Automatic; 517 | DEVELOPMENT_TEAM = VRJ2W4578X; 518 | INFOPLIST_FILE = WeakifyObjectTests/Info.plist; 519 | LD_RUNPATH_SEARCH_PATHS = ( 520 | "$(inherited)", 521 | "@executable_path/Frameworks", 522 | "@loader_path/Frameworks", 523 | ); 524 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakifyObjectTests; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 527 | SWIFT_VERSION = 4.0; 528 | TARGETED_DEVICE_FAMILY = "1,2"; 529 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WeakifyObject.app/WeakifyObject"; 530 | }; 531 | name = Debug; 532 | }; 533 | 0877D5EC21218EE3008448EF /* Release */ = { 534 | isa = XCBuildConfiguration; 535 | buildSettings = { 536 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 537 | BUNDLE_LOADER = "$(TEST_HOST)"; 538 | CLANG_ENABLE_MODULES = YES; 539 | CODE_SIGN_STYLE = Automatic; 540 | DEVELOPMENT_TEAM = VRJ2W4578X; 541 | INFOPLIST_FILE = WeakifyObjectTests/Info.plist; 542 | LD_RUNPATH_SEARCH_PATHS = ( 543 | "$(inherited)", 544 | "@executable_path/Frameworks", 545 | "@loader_path/Frameworks", 546 | ); 547 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakifyObjectTests; 548 | PRODUCT_NAME = "$(TARGET_NAME)"; 549 | SWIFT_VERSION = 4.0; 550 | TARGETED_DEVICE_FAMILY = "1,2"; 551 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WeakifyObject.app/WeakifyObject"; 552 | }; 553 | name = Release; 554 | }; 555 | /* End XCBuildConfiguration section */ 556 | 557 | /* Begin XCConfigurationList section */ 558 | 0877D5C521218EE2008448EF /* Build configuration list for PBXProject "WeakifyObject" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 0877D5E521218EE3008448EF /* Debug */, 562 | 0877D5E621218EE3008448EF /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | 0877D5E721218EE3008448EF /* Build configuration list for PBXNativeTarget "WeakifyObject" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | 0877D5E821218EE3008448EF /* Debug */, 571 | 0877D5E921218EE3008448EF /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | 0877D5EA21218EE3008448EF /* Build configuration list for PBXNativeTarget "WeakifyObjectTests" */ = { 577 | isa = XCConfigurationList; 578 | buildConfigurations = ( 579 | 0877D5EB21218EE3008448EF /* Debug */, 580 | 0877D5EC21218EE3008448EF /* Release */, 581 | ); 582 | defaultConfigurationIsVisible = 0; 583 | defaultConfigurationName = Release; 584 | }; 585 | /* End XCConfigurationList section */ 586 | }; 587 | rootObject = 0877D5C221218EE2008448EF /* Project object */; 588 | } 589 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcodeproj/xcshareddata/xcschemes/WeakifyObject.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 67 | 73 | 74 | 75 | 76 | 77 | 78 | 84 | 86 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import UIKit 6 | import WeakRef 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | var window: UIWindow? 11 | 12 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 13 | 14 | if let vc = window?.rootViewController as? WeatherViewController { 15 | let presenter = WeatherDataPresenter(output: WeakRef(vc)) 16 | let weatherFetcher = FetchWeatherUseCase(output: presenter) 17 | vc.reloadData = weatherFetcher.fetch 18 | } 19 | 20 | return true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Sample App/WeakifyObject/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Sample App/WeakifyObject/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/Business Logic/FetchWeatherUseCase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import Foundation 6 | 7 | struct WeatherData: Hashable { 8 | let temperature: Measurement 9 | } 10 | 11 | protocol FetchWeatherUseCaseOutput { 12 | func didFetch(_ weather: WeatherData) 13 | } 14 | 15 | final class FetchWeatherUseCase { 16 | let output: FetchWeatherUseCaseOutput 17 | 18 | init(output: FetchWeatherUseCaseOutput) { 19 | self.output = output 20 | } 21 | 22 | func fetch() { 23 | let temperature = Double(arc4random_uniform(21) + 15) // random between 15 - 35 24 | output.didFetch(WeatherData(temperature: Measurement(value: temperature, unit: .celsius))) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/Presentation/WeatherDataPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import Foundation 6 | 7 | struct WeatherViewModel: Equatable { 8 | let temperature: String 9 | } 10 | 11 | protocol WeatherDataPresenterOutput { 12 | func present(_ weather: WeatherViewModel) 13 | } 14 | 15 | final class WeatherDataPresenter: FetchWeatherUseCaseOutput { 16 | let output: WeatherDataPresenterOutput 17 | private let converter: MeasurementFormatter 18 | 19 | init(output: WeatherDataPresenterOutput, locale: Locale = .current) { 20 | self.output = output 21 | self.converter = MeasurementFormatter() 22 | self.converter.locale = locale 23 | } 24 | 25 | func didFetch(_ weather: WeatherData) { 26 | output.present(WeatherViewModel( 27 | temperature: converter.string( 28 | from: weather.temperature))) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/UI/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/UI/WeatherViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import UIKit 6 | 7 | class WeatherViewController: UIViewController { 8 | @IBOutlet var label: UILabel! 9 | @IBOutlet var reloadButton: UIButton! 10 | var reloadData: (() -> Void)? 11 | 12 | override func viewWillAppear(_ animated: Bool) { 13 | super.viewWillAppear(animated) 14 | 15 | reload() 16 | } 17 | 18 | @IBAction private func reload() { 19 | reloadData?() 20 | } 21 | } 22 | 23 | extension WeatherViewController: WeatherDataPresenterOutput { 24 | func present(_ weather: WeatherViewModel) { 25 | label.text = weather.temperature 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sample App/WeakifyObject/WeakRef+WeatherDataPresenterOutput.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import Foundation 6 | import WeakRef 7 | 8 | extension WeakRef: WeatherDataPresenterOutput where T: WeatherDataPresenterOutput { 9 | func present(_ weather: WeatherViewModel) { 10 | object?.present(weather) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Sample App/WeakifyObjectTests/AppDelegateTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import XCTest 6 | @testable import WeakifyObject 7 | 8 | class AppDelegateTests: XCTestCase { 9 | private weak var weakSUT: AppDelegate? 10 | private weak var weakVC: WeatherViewController? 11 | 12 | override func tearDown() { 13 | super.tearDown() 14 | 15 | assertNoMemoryLeaks() 16 | } 17 | 18 | private func assertNoMemoryLeaks() { 19 | XCTAssertNil(weakVC) 20 | XCTAssertNil(weakSUT) 21 | } 22 | 23 | func testDidFinishLaunchingConfiguresWeatherViewController() { 24 | let vc = makeWeatherViewController() 25 | let sut = makeSUT(withRoot: vc) 26 | 27 | XCTAssertNil(vc.reloadData) 28 | 29 | _ = sut.application(.shared, didFinishLaunchingWithOptions: [:]) 30 | 31 | XCTAssertNotNil(vc.reloadData) 32 | } 33 | 34 | func testWeatherViewControllerReloadDataShouldUpdateLabel() { 35 | let vc = makeWeatherViewController() 36 | let sut = makeSUT(withRoot: vc) 37 | 38 | _ = sut.application(.shared, didFinishLaunchingWithOptions: [:]) 39 | 40 | let initialLabelValue = vc.label.text 41 | 42 | vc.reloadData?() 43 | 44 | XCTAssertNotEqual(vc.label.text, initialLabelValue) 45 | } 46 | 47 | // MARK: - Helpers 48 | 49 | private func makeSUT(withRoot vc: UIViewController) -> AppDelegate { 50 | let sut = AppDelegate() 51 | sut.window = UIWindow() 52 | sut.window?.rootViewController = vc 53 | self.weakSUT = sut 54 | return sut 55 | } 56 | 57 | private func makeWeatherViewController() -> WeatherViewController { 58 | let sb = UIStoryboard(name: "Main", bundle: nil) 59 | let vc = sb.instantiateInitialViewController() as! WeatherViewController 60 | vc.loadViewIfNeeded() 61 | self.weakVC = vc 62 | return vc 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Sample App/WeakifyObjectTests/Business Logic/FetchWeatherUseCaseTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import XCTest 6 | @testable import WeakifyObject 7 | 8 | class FetchWeatherUseCaseTests: XCTestCase { 9 | 10 | func testFetchSendsRandomWeatherDataOutput() { 11 | let output = OutputSpy() 12 | let sut = FetchWeatherUseCase(output: output) 13 | 14 | XCTAssertEqual(output.messages.count, 0) 15 | 16 | for i in 1...10 { 17 | sut.fetch() 18 | XCTAssertEqual(output.messages.count, i) 19 | } 20 | 21 | XCTAssertGreaterThan(output.uniqueMessages.count, 3, "Should have generated at least 3 unique random weather data from 10 tries") 22 | } 23 | 24 | // MARK: - Helpers 25 | 26 | private class OutputSpy: FetchWeatherUseCaseOutput { 27 | typealias Message = (WeatherData) 28 | 29 | var messages = [Message]() 30 | func didFetch(_ weather: Message) { 31 | messages.append(weather) 32 | } 33 | 34 | var uniqueMessages: Set { 35 | return Set(messages) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Sample App/WeakifyObjectTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sample App/WeakifyObjectTests/Presentation/WeatherDataPresenterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import XCTest 6 | @testable import WeakifyObject 7 | 8 | class WeatherDataPresenterTests: XCTestCase { 9 | 10 | func testDidFetchPassesMessageToOutput() { 11 | let output = OutputSpy() 12 | let sut = WeatherDataPresenter(output: output) 13 | 14 | XCTAssertEqual(output.messages.count, 0) 15 | 16 | sut.didFetch(WeatherData(temperature: Measurement(value: 10, unit: .celsius))) 17 | XCTAssertEqual(output.messages.count, 1) 18 | 19 | sut.didFetch(WeatherData(temperature: Measurement(value: 20, unit: .kelvin))) 20 | XCTAssertEqual(output.messages.count, 2) 21 | } 22 | 23 | func testTranslatesDataToViewModelInFahrenheitForUSLocale() { 24 | let output = OutputSpy() 25 | let sut = WeatherDataPresenter(output: output, locale: Locale(identifier: "en_US")) 26 | 27 | sut.didFetch(WeatherData(temperature: Measurement(value: 10, unit: .celsius))) 28 | 29 | XCTAssertEqual(output.messages, [WeatherViewModel(temperature: "50°F")]) 30 | } 31 | 32 | func testTranslatesDataToViewModelInCelsiusForUKLocale() { 33 | let output = OutputSpy() 34 | let sut = WeatherDataPresenter(output: output, locale: Locale(identifier: "en_GB")) 35 | 36 | sut.didFetch(WeatherData(temperature: Measurement(value: 50, unit: .fahrenheit))) 37 | 38 | XCTAssertEqual(output.messages, [WeatherViewModel(temperature: "10°C")]) 39 | } 40 | 41 | // MARK: - Helpers 42 | 43 | private class OutputSpy: WeatherDataPresenterOutput { 44 | typealias Message = (WeatherViewModel) 45 | 46 | var messages = [Message]() 47 | func present(_ weather: WeatherViewModel) { 48 | messages.append(weather) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Sample App/WeakifyObjectTests/UI/WeatherViewControllerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import XCTest 6 | @testable import WeakifyObject 7 | 8 | class WeatherViewControllerTests: XCTestCase { 9 | private let sb = UIStoryboard(name: "Main", bundle: nil) 10 | 11 | func testCanCreateFromStoryboard() { 12 | let sut = sb.instantiateInitialViewController() 13 | 14 | XCTAssertTrue(sut is WeatherViewController) 15 | } 16 | 17 | func testLabelOutletIsConnected() { 18 | XCTAssertNotNil(makeSUT().label) 19 | } 20 | 21 | func testReloadButtonOutletIsConnected() { 22 | XCTAssertNotNil(makeSUT().reloadButton) 23 | } 24 | 25 | func testReloadButtonTapTriggersReloadDataClosure() { 26 | let sut = makeSUT() 27 | 28 | var callCount = 0 29 | sut.reloadData = { callCount += 1 } 30 | 31 | XCTAssertEqual(callCount, 0) 32 | 33 | sut.reloadButton.sendActions(for: .touchUpInside) 34 | XCTAssertEqual(callCount, 1) 35 | 36 | sut.reloadButton.sendActions(for: .touchUpInside) 37 | XCTAssertEqual(callCount, 2) 38 | } 39 | 40 | func testViewWillAppearTriggersReloadDataClosure() { 41 | let sut = makeSUT() 42 | 43 | var callCount = 0 44 | sut.reloadData = { callCount += 1 } 45 | 46 | XCTAssertEqual(callCount, 0) 47 | 48 | sut.viewWillAppear(false) 49 | XCTAssertEqual(callCount, 1) 50 | 51 | sut.viewWillAppear(false) 52 | XCTAssertEqual(callCount, 2) 53 | } 54 | 55 | // MARK: - WeatherPresenterOutput Tests 56 | 57 | func testPresentWeatherViewModelUpdatesLabel() { 58 | let sut = makeSUT() 59 | 60 | sut.present(WeatherViewModel(temperature: "a temperature")) 61 | 62 | XCTAssertEqual(sut.label.text, "a temperature") 63 | } 64 | 65 | // MARK: - Helpers 66 | 67 | private func makeSUT() -> WeatherViewController { 68 | let sut = sb.instantiateInitialViewController() as! WeatherViewController 69 | sut.loadViewIfNeeded() 70 | return sut 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /WeakRef/WeakRef.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 089AD81C21235A4400875B8F /* WeakRef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 089AD81B21235A4400875B8F /* WeakRef.swift */; }; 11 | 089AD81D21235A4400875B8F /* WeakRef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 089AD81B21235A4400875B8F /* WeakRef.swift */; }; 12 | 089AD827212360C400875B8F /* WeakRef.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08F312FB212357510093D631 /* WeakRef.framework */; }; 13 | 089AD82D2123617B00875B8F /* WeakRefTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F312EA212356B60093D631 /* WeakRefTests.swift */; }; 14 | 08F312E6212356B60093D631 /* WeakRef.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08F312DC212356B60093D631 /* WeakRef.framework */; }; 15 | 08F312EB212356B60093D631 /* WeakRefTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F312EA212356B60093D631 /* WeakRefTests.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | 089AD828212360C400875B8F /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = 08F312D3212356B60093D631 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = 08F312FA212357510093D631; 24 | remoteInfo = WeakRef_macOS; 25 | }; 26 | 08F312E7212356B60093D631 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 08F312D3212356B60093D631 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 08F312DB212356B60093D631; 31 | remoteInfo = WeakRef; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | 089AD81B21235A4400875B8F /* WeakRef.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeakRef.swift; sourceTree = ""; }; 37 | 089AD822212360C400875B8F /* WeakRefTests_macOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WeakRefTests_macOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 08F312DC212356B60093D631 /* WeakRef.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WeakRef.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 08F312E0212356B60093D631 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | 08F312E5212356B60093D631 /* WeakRefTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WeakRefTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 08F312EA212356B60093D631 /* WeakRefTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeakRefTests.swift; sourceTree = ""; }; 42 | 08F312EC212356B60093D631 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 08F312FB212357510093D631 /* WeakRef.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WeakRef.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 089AD81F212360C400875B8F /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | 089AD827212360C400875B8F /* WeakRef.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | 08F312D8212356B60093D631 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 08F312E2212356B60093D631 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 08F312E6212356B60093D631 /* WeakRef.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 08F312F7212357510093D631 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXFrameworksBuildPhase section */ 78 | 79 | /* Begin PBXGroup section */ 80 | 08F312D2212356B60093D631 = { 81 | isa = PBXGroup; 82 | children = ( 83 | 08F312DE212356B60093D631 /* WeakRef */, 84 | 08F312E9212356B60093D631 /* WeakRefTests */, 85 | 08F312DD212356B60093D631 /* Products */, 86 | ); 87 | sourceTree = ""; 88 | }; 89 | 08F312DD212356B60093D631 /* Products */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 08F312DC212356B60093D631 /* WeakRef.framework */, 93 | 08F312E5212356B60093D631 /* WeakRefTests_iOS.xctest */, 94 | 08F312FB212357510093D631 /* WeakRef.framework */, 95 | 089AD822212360C400875B8F /* WeakRefTests_macOS.xctest */, 96 | ); 97 | name = Products; 98 | sourceTree = ""; 99 | }; 100 | 08F312DE212356B60093D631 /* WeakRef */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 089AD81B21235A4400875B8F /* WeakRef.swift */, 104 | 08F312E0212356B60093D631 /* Info.plist */, 105 | ); 106 | path = WeakRef; 107 | sourceTree = ""; 108 | }; 109 | 08F312E9212356B60093D631 /* WeakRefTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 08F312EA212356B60093D631 /* WeakRefTests.swift */, 113 | 08F312EC212356B60093D631 /* Info.plist */, 114 | ); 115 | path = WeakRefTests; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXHeadersBuildPhase section */ 121 | 08F312D9212356B60093D631 /* Headers */ = { 122 | isa = PBXHeadersBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | ); 126 | runOnlyForDeploymentPostprocessing = 0; 127 | }; 128 | 08F312F8212357510093D631 /* Headers */ = { 129 | isa = PBXHeadersBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXHeadersBuildPhase section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 089AD821212360C400875B8F /* WeakRefTests_macOS */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 089AD82A212360C400875B8F /* Build configuration list for PBXNativeTarget "WeakRefTests_macOS" */; 141 | buildPhases = ( 142 | 089AD81E212360C400875B8F /* Sources */, 143 | 089AD81F212360C400875B8F /* Frameworks */, 144 | 089AD820212360C400875B8F /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | 089AD829212360C400875B8F /* PBXTargetDependency */, 150 | ); 151 | name = WeakRefTests_macOS; 152 | productName = WeakRefTests_macOS; 153 | productReference = 089AD822212360C400875B8F /* WeakRefTests_macOS.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | 08F312DB212356B60093D631 /* WeakRef_iOS */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 08F312F0212356B60093D631 /* Build configuration list for PBXNativeTarget "WeakRef_iOS" */; 159 | buildPhases = ( 160 | 08F312D7212356B60093D631 /* Sources */, 161 | 08F312D8212356B60093D631 /* Frameworks */, 162 | 08F312D9212356B60093D631 /* Headers */, 163 | 08F312DA212356B60093D631 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = WeakRef_iOS; 170 | productName = WeakRef; 171 | productReference = 08F312DC212356B60093D631 /* WeakRef.framework */; 172 | productType = "com.apple.product-type.framework"; 173 | }; 174 | 08F312E4212356B60093D631 /* WeakRefTests_iOS */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = 08F312F3212356B60093D631 /* Build configuration list for PBXNativeTarget "WeakRefTests_iOS" */; 177 | buildPhases = ( 178 | 08F312E1212356B60093D631 /* Sources */, 179 | 08F312E2212356B60093D631 /* Frameworks */, 180 | 08F312E3212356B60093D631 /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | 08F312E8212356B60093D631 /* PBXTargetDependency */, 186 | ); 187 | name = WeakRefTests_iOS; 188 | productName = WeakRefTests; 189 | productReference = 08F312E5212356B60093D631 /* WeakRefTests_iOS.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | 08F312FA212357510093D631 /* WeakRef_macOS */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = 08F31300212357510093D631 /* Build configuration list for PBXNativeTarget "WeakRef_macOS" */; 195 | buildPhases = ( 196 | 08F312F6212357510093D631 /* Sources */, 197 | 08F312F7212357510093D631 /* Frameworks */, 198 | 08F312F8212357510093D631 /* Headers */, 199 | 08F312F9212357510093D631 /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | ); 205 | name = WeakRef_macOS; 206 | productName = WeakRef_macOS; 207 | productReference = 08F312FB212357510093D631 /* WeakRef.framework */; 208 | productType = "com.apple.product-type.framework"; 209 | }; 210 | /* End PBXNativeTarget section */ 211 | 212 | /* Begin PBXProject section */ 213 | 08F312D3212356B60093D631 /* Project object */ = { 214 | isa = PBXProject; 215 | attributes = { 216 | LastSwiftUpdateCheck = 0940; 217 | LastUpgradeCheck = 0940; 218 | ORGANIZATIONNAME = "Essential Developer"; 219 | TargetAttributes = { 220 | 089AD821212360C400875B8F = { 221 | CreatedOnToolsVersion = 9.4.1; 222 | }; 223 | 08F312DB212356B60093D631 = { 224 | CreatedOnToolsVersion = 9.4.1; 225 | LastSwiftMigration = 0940; 226 | }; 227 | 08F312E4212356B60093D631 = { 228 | CreatedOnToolsVersion = 9.4.1; 229 | }; 230 | 08F312FA212357510093D631 = { 231 | CreatedOnToolsVersion = 9.4.1; 232 | LastSwiftMigration = 0940; 233 | }; 234 | }; 235 | }; 236 | buildConfigurationList = 08F312D6212356B60093D631 /* Build configuration list for PBXProject "WeakRef" */; 237 | compatibilityVersion = "Xcode 9.3"; 238 | developmentRegion = en; 239 | hasScannedForEncodings = 0; 240 | knownRegions = ( 241 | en, 242 | ); 243 | mainGroup = 08F312D2212356B60093D631; 244 | productRefGroup = 08F312DD212356B60093D631 /* Products */; 245 | projectDirPath = ""; 246 | projectRoot = ""; 247 | targets = ( 248 | 08F312FA212357510093D631 /* WeakRef_macOS */, 249 | 089AD821212360C400875B8F /* WeakRefTests_macOS */, 250 | 08F312DB212356B60093D631 /* WeakRef_iOS */, 251 | 08F312E4212356B60093D631 /* WeakRefTests_iOS */, 252 | ); 253 | }; 254 | /* End PBXProject section */ 255 | 256 | /* Begin PBXResourcesBuildPhase section */ 257 | 089AD820212360C400875B8F /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | 08F312DA212356B60093D631 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | 08F312E3212356B60093D631 /* Resources */ = { 272 | isa = PBXResourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 08F312F9212357510093D631 /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | /* End PBXResourcesBuildPhase section */ 286 | 287 | /* Begin PBXSourcesBuildPhase section */ 288 | 089AD81E212360C400875B8F /* Sources */ = { 289 | isa = PBXSourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | 089AD82D2123617B00875B8F /* WeakRefTests.swift in Sources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | 08F312D7212356B60093D631 /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | 089AD81D21235A4400875B8F /* WeakRef.swift in Sources */, 301 | ); 302 | runOnlyForDeploymentPostprocessing = 0; 303 | }; 304 | 08F312E1212356B60093D631 /* Sources */ = { 305 | isa = PBXSourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | 08F312EB212356B60093D631 /* WeakRefTests.swift in Sources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | 08F312F6212357510093D631 /* Sources */ = { 313 | isa = PBXSourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | 089AD81C21235A4400875B8F /* WeakRef.swift in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | /* End PBXSourcesBuildPhase section */ 321 | 322 | /* Begin PBXTargetDependency section */ 323 | 089AD829212360C400875B8F /* PBXTargetDependency */ = { 324 | isa = PBXTargetDependency; 325 | target = 08F312FA212357510093D631 /* WeakRef_macOS */; 326 | targetProxy = 089AD828212360C400875B8F /* PBXContainerItemProxy */; 327 | }; 328 | 08F312E8212356B60093D631 /* PBXTargetDependency */ = { 329 | isa = PBXTargetDependency; 330 | target = 08F312DB212356B60093D631 /* WeakRef_iOS */; 331 | targetProxy = 08F312E7212356B60093D631 /* PBXContainerItemProxy */; 332 | }; 333 | /* End PBXTargetDependency section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | 089AD82B212360C400875B8F /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | CODE_SIGN_IDENTITY = "Mac Developer"; 340 | CODE_SIGN_STYLE = Automatic; 341 | COMBINE_HIDPI_IMAGES = YES; 342 | DEVELOPMENT_TEAM = VRJ2W4578X; 343 | INFOPLIST_FILE = WeakRefTests/Info.plist; 344 | LD_RUNPATH_SEARCH_PATHS = ( 345 | "$(inherited)", 346 | "@executable_path/../Frameworks", 347 | "@loader_path/../Frameworks", 348 | ); 349 | MACOSX_DEPLOYMENT_TARGET = 10.13; 350 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRefTests-macOS"; 351 | PRODUCT_NAME = "$(TARGET_NAME)"; 352 | SDKROOT = macosx; 353 | SWIFT_VERSION = 4.0; 354 | }; 355 | name = Debug; 356 | }; 357 | 089AD82C212360C400875B8F /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | CODE_SIGN_IDENTITY = "Mac Developer"; 361 | CODE_SIGN_STYLE = Automatic; 362 | COMBINE_HIDPI_IMAGES = YES; 363 | DEVELOPMENT_TEAM = VRJ2W4578X; 364 | INFOPLIST_FILE = WeakRefTests/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = ( 366 | "$(inherited)", 367 | "@executable_path/../Frameworks", 368 | "@loader_path/../Frameworks", 369 | ); 370 | MACOSX_DEPLOYMENT_TARGET = 10.13; 371 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRefTests-macOS"; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SDKROOT = macosx; 374 | SWIFT_VERSION = 4.0; 375 | }; 376 | name = Release; 377 | }; 378 | 08F312EE212356B60093D631 /* Debug */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ALWAYS_SEARCH_USER_PATHS = NO; 382 | CLANG_ANALYZER_NONNULL = YES; 383 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 384 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 385 | CLANG_CXX_LIBRARY = "libc++"; 386 | CLANG_ENABLE_MODULES = YES; 387 | CLANG_ENABLE_OBJC_ARC = YES; 388 | CLANG_ENABLE_OBJC_WEAK = YES; 389 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 390 | CLANG_WARN_BOOL_CONVERSION = YES; 391 | CLANG_WARN_COMMA = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 394 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 395 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 396 | CLANG_WARN_EMPTY_BODY = YES; 397 | CLANG_WARN_ENUM_CONVERSION = YES; 398 | CLANG_WARN_INFINITE_RECURSION = YES; 399 | CLANG_WARN_INT_CONVERSION = YES; 400 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 401 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 402 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 403 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 404 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 405 | CLANG_WARN_STRICT_PROTOTYPES = YES; 406 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 407 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 408 | CLANG_WARN_UNREACHABLE_CODE = YES; 409 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 410 | CODE_SIGN_IDENTITY = "iPhone Developer"; 411 | COPY_PHASE_STRIP = NO; 412 | CURRENT_PROJECT_VERSION = 1; 413 | DEBUG_INFORMATION_FORMAT = dwarf; 414 | ENABLE_STRICT_OBJC_MSGSEND = YES; 415 | ENABLE_TESTABILITY = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu11; 417 | GCC_DYNAMIC_NO_PIC = NO; 418 | GCC_NO_COMMON_BLOCKS = YES; 419 | GCC_OPTIMIZATION_LEVEL = 0; 420 | GCC_PREPROCESSOR_DEFINITIONS = ( 421 | "DEBUG=1", 422 | "$(inherited)", 423 | ); 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 431 | MTL_ENABLE_DEBUG_INFO = YES; 432 | ONLY_ACTIVE_ARCH = YES; 433 | SDKROOT = iphoneos; 434 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 435 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 436 | VERSIONING_SYSTEM = "apple-generic"; 437 | VERSION_INFO_PREFIX = ""; 438 | }; 439 | name = Debug; 440 | }; 441 | 08F312EF212356B60093D631 /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ALWAYS_SEARCH_USER_PATHS = NO; 445 | CLANG_ANALYZER_NONNULL = YES; 446 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 447 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 448 | CLANG_CXX_LIBRARY = "libc++"; 449 | CLANG_ENABLE_MODULES = YES; 450 | CLANG_ENABLE_OBJC_ARC = YES; 451 | CLANG_ENABLE_OBJC_WEAK = YES; 452 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 453 | CLANG_WARN_BOOL_CONVERSION = YES; 454 | CLANG_WARN_COMMA = YES; 455 | CLANG_WARN_CONSTANT_CONVERSION = YES; 456 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 457 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 458 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 459 | CLANG_WARN_EMPTY_BODY = YES; 460 | CLANG_WARN_ENUM_CONVERSION = YES; 461 | CLANG_WARN_INFINITE_RECURSION = YES; 462 | CLANG_WARN_INT_CONVERSION = YES; 463 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 464 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 465 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 466 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 467 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 468 | CLANG_WARN_STRICT_PROTOTYPES = YES; 469 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 470 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 471 | CLANG_WARN_UNREACHABLE_CODE = YES; 472 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 473 | CODE_SIGN_IDENTITY = "iPhone Developer"; 474 | COPY_PHASE_STRIP = NO; 475 | CURRENT_PROJECT_VERSION = 1; 476 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 477 | ENABLE_NS_ASSERTIONS = NO; 478 | ENABLE_STRICT_OBJC_MSGSEND = YES; 479 | GCC_C_LANGUAGE_STANDARD = gnu11; 480 | GCC_NO_COMMON_BLOCKS = YES; 481 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 482 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 483 | GCC_WARN_UNDECLARED_SELECTOR = YES; 484 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 485 | GCC_WARN_UNUSED_FUNCTION = YES; 486 | GCC_WARN_UNUSED_VARIABLE = YES; 487 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 488 | MTL_ENABLE_DEBUG_INFO = NO; 489 | SDKROOT = iphoneos; 490 | SWIFT_COMPILATION_MODE = wholemodule; 491 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 492 | VALIDATE_PRODUCT = YES; 493 | VERSIONING_SYSTEM = "apple-generic"; 494 | VERSION_INFO_PREFIX = ""; 495 | }; 496 | name = Release; 497 | }; 498 | 08F312F1212356B60093D631 /* Debug */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | CLANG_ENABLE_MODULES = YES; 502 | CODE_SIGN_IDENTITY = ""; 503 | CODE_SIGN_STYLE = Automatic; 504 | DEFINES_MODULE = YES; 505 | DEVELOPMENT_TEAM = VRJ2W4578X; 506 | DYLIB_COMPATIBILITY_VERSION = 1; 507 | DYLIB_CURRENT_VERSION = 1; 508 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 509 | INFOPLIST_FILE = WeakRef/Info.plist; 510 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 511 | LD_RUNPATH_SEARCH_PATHS = ( 512 | "$(inherited)", 513 | "@executable_path/Frameworks", 514 | "@loader_path/Frameworks", 515 | ); 516 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRef-iOS"; 517 | PRODUCT_MODULE_NAME = WeakRef; 518 | PRODUCT_NAME = WeakRef; 519 | SKIP_INSTALL = YES; 520 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 521 | SWIFT_VERSION = 4.0; 522 | TARGETED_DEVICE_FAMILY = "1,2"; 523 | }; 524 | name = Debug; 525 | }; 526 | 08F312F2212356B60093D631 /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | buildSettings = { 529 | CLANG_ENABLE_MODULES = YES; 530 | CODE_SIGN_IDENTITY = ""; 531 | CODE_SIGN_STYLE = Automatic; 532 | DEFINES_MODULE = YES; 533 | DEVELOPMENT_TEAM = VRJ2W4578X; 534 | DYLIB_COMPATIBILITY_VERSION = 1; 535 | DYLIB_CURRENT_VERSION = 1; 536 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 537 | INFOPLIST_FILE = WeakRef/Info.plist; 538 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 539 | LD_RUNPATH_SEARCH_PATHS = ( 540 | "$(inherited)", 541 | "@executable_path/Frameworks", 542 | "@loader_path/Frameworks", 543 | ); 544 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRef-iOS"; 545 | PRODUCT_MODULE_NAME = WeakRef; 546 | PRODUCT_NAME = WeakRef; 547 | SKIP_INSTALL = YES; 548 | SWIFT_VERSION = 4.0; 549 | TARGETED_DEVICE_FAMILY = "1,2"; 550 | }; 551 | name = Release; 552 | }; 553 | 08F312F4212356B60093D631 /* Debug */ = { 554 | isa = XCBuildConfiguration; 555 | buildSettings = { 556 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 557 | CODE_SIGN_STYLE = Automatic; 558 | DEVELOPMENT_TEAM = VRJ2W4578X; 559 | INFOPLIST_FILE = WeakRefTests/Info.plist; 560 | LD_RUNPATH_SEARCH_PATHS = ( 561 | "$(inherited)", 562 | "@executable_path/Frameworks", 563 | "@loader_path/Frameworks", 564 | ); 565 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakRefTests; 566 | PRODUCT_NAME = "$(TARGET_NAME)"; 567 | SWIFT_VERSION = 4.0; 568 | TARGETED_DEVICE_FAMILY = "1,2"; 569 | }; 570 | name = Debug; 571 | }; 572 | 08F312F5212356B60093D631 /* Release */ = { 573 | isa = XCBuildConfiguration; 574 | buildSettings = { 575 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 576 | CODE_SIGN_STYLE = Automatic; 577 | DEVELOPMENT_TEAM = VRJ2W4578X; 578 | INFOPLIST_FILE = WeakRefTests/Info.plist; 579 | LD_RUNPATH_SEARCH_PATHS = ( 580 | "$(inherited)", 581 | "@executable_path/Frameworks", 582 | "@loader_path/Frameworks", 583 | ); 584 | PRODUCT_BUNDLE_IDENTIFIER = com.essentialdeveloper.WeakRefTests; 585 | PRODUCT_NAME = "$(TARGET_NAME)"; 586 | SWIFT_VERSION = 4.0; 587 | TARGETED_DEVICE_FAMILY = "1,2"; 588 | }; 589 | name = Release; 590 | }; 591 | 08F31301212357510093D631 /* Debug */ = { 592 | isa = XCBuildConfiguration; 593 | buildSettings = { 594 | CLANG_ENABLE_MODULES = YES; 595 | CODE_SIGN_IDENTITY = "Mac Developer"; 596 | CODE_SIGN_STYLE = Automatic; 597 | COMBINE_HIDPI_IMAGES = YES; 598 | DEFINES_MODULE = YES; 599 | DEVELOPMENT_TEAM = VRJ2W4578X; 600 | DYLIB_COMPATIBILITY_VERSION = 1; 601 | DYLIB_CURRENT_VERSION = 1; 602 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 603 | FRAMEWORK_VERSION = A; 604 | INFOPLIST_FILE = WeakRef/Info.plist; 605 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 606 | LD_RUNPATH_SEARCH_PATHS = ( 607 | "$(inherited)", 608 | "@executable_path/../Frameworks", 609 | "@loader_path/Frameworks", 610 | ); 611 | MACOSX_DEPLOYMENT_TARGET = 10.13; 612 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRef-macOS"; 613 | PRODUCT_MODULE_NAME = WeakRef; 614 | PRODUCT_NAME = WeakRef; 615 | SDKROOT = macosx; 616 | SKIP_INSTALL = YES; 617 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 618 | SWIFT_VERSION = 4.0; 619 | }; 620 | name = Debug; 621 | }; 622 | 08F31302212357510093D631 /* Release */ = { 623 | isa = XCBuildConfiguration; 624 | buildSettings = { 625 | CLANG_ENABLE_MODULES = YES; 626 | CODE_SIGN_IDENTITY = "Mac Developer"; 627 | CODE_SIGN_STYLE = Automatic; 628 | COMBINE_HIDPI_IMAGES = YES; 629 | DEFINES_MODULE = YES; 630 | DEVELOPMENT_TEAM = VRJ2W4578X; 631 | DYLIB_COMPATIBILITY_VERSION = 1; 632 | DYLIB_CURRENT_VERSION = 1; 633 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 634 | FRAMEWORK_VERSION = A; 635 | INFOPLIST_FILE = WeakRef/Info.plist; 636 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 637 | LD_RUNPATH_SEARCH_PATHS = ( 638 | "$(inherited)", 639 | "@executable_path/../Frameworks", 640 | "@loader_path/Frameworks", 641 | ); 642 | MACOSX_DEPLOYMENT_TARGET = 10.13; 643 | PRODUCT_BUNDLE_IDENTIFIER = "com.essentialdeveloper.WeakRef-macOS"; 644 | PRODUCT_MODULE_NAME = WeakRef; 645 | PRODUCT_NAME = WeakRef; 646 | SDKROOT = macosx; 647 | SKIP_INSTALL = YES; 648 | SWIFT_VERSION = 4.0; 649 | }; 650 | name = Release; 651 | }; 652 | /* End XCBuildConfiguration section */ 653 | 654 | /* Begin XCConfigurationList section */ 655 | 089AD82A212360C400875B8F /* Build configuration list for PBXNativeTarget "WeakRefTests_macOS" */ = { 656 | isa = XCConfigurationList; 657 | buildConfigurations = ( 658 | 089AD82B212360C400875B8F /* Debug */, 659 | 089AD82C212360C400875B8F /* Release */, 660 | ); 661 | defaultConfigurationIsVisible = 0; 662 | defaultConfigurationName = Release; 663 | }; 664 | 08F312D6212356B60093D631 /* Build configuration list for PBXProject "WeakRef" */ = { 665 | isa = XCConfigurationList; 666 | buildConfigurations = ( 667 | 08F312EE212356B60093D631 /* Debug */, 668 | 08F312EF212356B60093D631 /* Release */, 669 | ); 670 | defaultConfigurationIsVisible = 0; 671 | defaultConfigurationName = Release; 672 | }; 673 | 08F312F0212356B60093D631 /* Build configuration list for PBXNativeTarget "WeakRef_iOS" */ = { 674 | isa = XCConfigurationList; 675 | buildConfigurations = ( 676 | 08F312F1212356B60093D631 /* Debug */, 677 | 08F312F2212356B60093D631 /* Release */, 678 | ); 679 | defaultConfigurationIsVisible = 0; 680 | defaultConfigurationName = Release; 681 | }; 682 | 08F312F3212356B60093D631 /* Build configuration list for PBXNativeTarget "WeakRefTests_iOS" */ = { 683 | isa = XCConfigurationList; 684 | buildConfigurations = ( 685 | 08F312F4212356B60093D631 /* Debug */, 686 | 08F312F5212356B60093D631 /* Release */, 687 | ); 688 | defaultConfigurationIsVisible = 0; 689 | defaultConfigurationName = Release; 690 | }; 691 | 08F31300212357510093D631 /* Build configuration list for PBXNativeTarget "WeakRef_macOS" */ = { 692 | isa = XCConfigurationList; 693 | buildConfigurations = ( 694 | 08F31301212357510093D631 /* Debug */, 695 | 08F31302212357510093D631 /* Release */, 696 | ); 697 | defaultConfigurationIsVisible = 0; 698 | defaultConfigurationName = Release; 699 | }; 700 | /* End XCConfigurationList section */ 701 | }; 702 | rootObject = 08F312D3212356B60093D631 /* Project object */; 703 | } 704 | -------------------------------------------------------------------------------- /WeakRef/WeakRef.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WeakRef/WeakRef.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /WeakRef/WeakRef.xcodeproj/xcshareddata/xcschemes/WeakRef_iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /WeakRef/WeakRef.xcodeproj/xcshareddata/xcschemes/WeakRef_macOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /WeakRef/WeakRef/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WeakRef/WeakRef/WeakRef.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import Foundation 6 | 7 | public final class WeakRef { 8 | public weak var object: T? 9 | 10 | public init(_ object: T) { 11 | self.object = object 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WeakRef/WeakRefTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WeakRef/WeakRefTests/WeakRefTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright © 2018 Essential Developer. All rights reserved. 3 | // 4 | 5 | import XCTest 6 | import WeakRef 7 | 8 | class WeakRefTests: XCTestCase { 9 | 10 | func testWeakRefHoldsAReferenceToTheGivenObject() { 11 | let anObject = MockObject() 12 | 13 | let sut = WeakRef(anObject) 14 | 15 | XCTAssertEqual(ObjectIdentifier(sut.object!), ObjectIdentifier(anObject)) 16 | } 17 | 18 | func testWeakRefHoldsAWeakReferenceToTheGivenObject() { 19 | var anObject: MockObject? = MockObject() // anObject retain count = 1 20 | 21 | let sut = WeakRef(anObject!) 22 | 23 | anObject = nil // anObject retain count = 0 (memory should be freed now) 24 | 25 | XCTAssertNil(sut.object, "Object reference should be nil after the object has been freed") 26 | } 27 | 28 | private class MockObject {} 29 | } 30 | --------------------------------------------------------------------------------