├── .gitignore ├── CODEOWNERS ├── Example ├── NibView.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── NibView.xcscheme ├── NibView │ ├── Info.plist │ └── NibView.h └── NibViewExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── CardDetails │ ├── CardDetailsView.swift │ ├── CardDetailsView.xib │ └── CardDetailsViewController.swift │ ├── CardsList │ ├── CardView.swift │ ├── CardView.xib │ └── CardsListViewController.swift │ ├── Info.plist │ └── images.xcassets │ ├── AppIcon.appiconset │ └── Contents.json │ ├── Contents.json │ ├── Jane.imageset │ ├── Contents.json │ ├── Jane@2x.png │ └── Jane@3x.png │ ├── Jim.imageset │ ├── Contents.json │ ├── Jim@2x.png │ └── Jim@3x.png │ └── John.imageset │ ├── Contents.json │ ├── John@2x.png │ └── John@3x.png ├── Img ├── Preview.gif └── Setup.gif ├── LICENSE ├── NibView.swift ├── Package.swift ├── README.md └── Sources ├── NibLoadable.swift ├── NibLoader.swift └── NibViewController.swift /.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 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in 2 | # the repo. These owners will be requested for 3 | # review when someone opens a pull request. 4 | * @trafi/guild-ios 5 | -------------------------------------------------------------------------------- /Example/NibView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D3254B091E54C4820039D644 /* NibView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3FCA1EB1E4E54700003A30D /* NibView.swift */; }; 11 | D396D4BD1E4F45B100C5E25E /* CardDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D396D4BC1E4F45B100C5E25E /* CardDetailsViewController.swift */; }; 12 | D396D4BF1E4F46A800C5E25E /* CardDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D396D4BE1E4F46A800C5E25E /* CardDetailsView.swift */; }; 13 | D396D4C11E4F472C00C5E25E /* CardDetailsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D396D4C01E4F472C00C5E25E /* CardDetailsView.xib */; }; 14 | D39D11221E4F2F52008F7DF4 /* images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D39D11211E4F2F52008F7DF4 /* images.xcassets */; }; 15 | D3D711941E4E5A4500F33BE8 /* CardsListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D711931E4E5A4500F33BE8 /* CardsListViewController.swift */; }; 16 | D3F882C21E4F86CE005C19FF /* NibLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3F882C11E4F86CE005C19FF /* NibLoader.swift */; }; 17 | D3FCA1C81E4E53C60003A30D /* NibView.h in Headers */ = {isa = PBXBuildFile; fileRef = D3FCA1C61E4E53C60003A30D /* NibView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18 | D3FCA1D51E4E544C0003A30D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3FCA1D41E4E544C0003A30D /* AppDelegate.swift */; }; 19 | D3FCA1DA1E4E544C0003A30D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D3FCA1D81E4E544C0003A30D /* Main.storyboard */; }; 20 | D3FCA1DF1E4E544C0003A30D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D3FCA1DD1E4E544C0003A30D /* LaunchScreen.storyboard */; }; 21 | D3FCA1E41E4E545A0003A30D /* NibView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3FCA1C31E4E53C60003A30D /* NibView.framework */; }; 22 | D3FCA1E51E4E545A0003A30D /* NibView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D3FCA1C31E4E53C60003A30D /* NibView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23 | D3FCA1ED1E4E54700003A30D /* NibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3FCA1EA1E4E54700003A30D /* NibLoadable.swift */; }; 24 | D3FCA1EF1E4E54700003A30D /* NibViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3FCA1EC1E4E54700003A30D /* NibViewController.swift */; }; 25 | D3FCA1F31E4E568B0003A30D /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3FCA1F21E4E568B0003A30D /* CardView.swift */; }; 26 | D3FCA1F51E4E56B00003A30D /* CardView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D3FCA1F41E4E56B00003A30D /* CardView.xib */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | D3FCA1E61E4E545A0003A30D /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = D3FCA1BA1E4E53C60003A30D /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = D3FCA1C21E4E53C60003A30D; 35 | remoteInfo = NibView; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXCopyFilesBuildPhase section */ 40 | D3FCA1E81E4E545A0003A30D /* Embed Frameworks */ = { 41 | isa = PBXCopyFilesBuildPhase; 42 | buildActionMask = 2147483647; 43 | dstPath = ""; 44 | dstSubfolderSpec = 10; 45 | files = ( 46 | D3FCA1E51E4E545A0003A30D /* NibView.framework in Embed Frameworks */, 47 | ); 48 | name = "Embed Frameworks"; 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXCopyFilesBuildPhase section */ 52 | 53 | /* Begin PBXFileReference section */ 54 | D396D4BC1E4F45B100C5E25E /* CardDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardDetailsViewController.swift; sourceTree = ""; }; 55 | D396D4BE1E4F46A800C5E25E /* CardDetailsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardDetailsView.swift; sourceTree = ""; }; 56 | D396D4C01E4F472C00C5E25E /* CardDetailsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CardDetailsView.xib; sourceTree = ""; }; 57 | D39D11211E4F2F52008F7DF4 /* images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = images.xcassets; sourceTree = ""; }; 58 | D3D711931E4E5A4500F33BE8 /* CardsListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardsListViewController.swift; sourceTree = ""; }; 59 | D3F882C11E4F86CE005C19FF /* NibLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibLoader.swift; sourceTree = ""; }; 60 | D3FCA1C31E4E53C60003A30D /* NibView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NibView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | D3FCA1C61E4E53C60003A30D /* NibView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NibView.h; sourceTree = ""; }; 62 | D3FCA1C71E4E53C60003A30D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | D3FCA1D21E4E544C0003A30D /* NibViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NibViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | D3FCA1D41E4E544C0003A30D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 65 | D3FCA1D91E4E544C0003A30D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 66 | D3FCA1DE1E4E544C0003A30D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 67 | D3FCA1E01E4E544C0003A30D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | D3FCA1EA1E4E54700003A30D /* NibLoadable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibLoadable.swift; sourceTree = ""; }; 69 | D3FCA1EB1E4E54700003A30D /* NibView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NibView.swift; path = ../NibView.swift; sourceTree = ""; }; 70 | D3FCA1EC1E4E54700003A30D /* NibViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibViewController.swift; sourceTree = ""; }; 71 | D3FCA1F21E4E568B0003A30D /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = ""; }; 72 | D3FCA1F41E4E56B00003A30D /* CardView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CardView.xib; sourceTree = ""; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | D3FCA1BF1E4E53C60003A30D /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | D3FCA1CF1E4E544C0003A30D /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | D3FCA1E41E4E545A0003A30D /* NibView.framework in Frameworks */, 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | /* End PBXFrameworksBuildPhase section */ 92 | 93 | /* Begin PBXGroup section */ 94 | D3FCA1B91E4E53C60003A30D = { 95 | isa = PBXGroup; 96 | children = ( 97 | D3FCA1C51E4E53C60003A30D /* NibView */, 98 | D3FCA1D31E4E544C0003A30D /* NibViewExample */, 99 | D3FCA1C41E4E53C60003A30D /* Products */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | D3FCA1C41E4E53C60003A30D /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | D3FCA1C31E4E53C60003A30D /* NibView.framework */, 107 | D3FCA1D21E4E544C0003A30D /* NibViewExample.app */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | D3FCA1C51E4E53C60003A30D /* NibView */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | D3FCA1E91E4E54700003A30D /* Sources */, 116 | D3FCA1C61E4E53C60003A30D /* NibView.h */, 117 | D3FCA1C71E4E53C60003A30D /* Info.plist */, 118 | ); 119 | path = NibView; 120 | sourceTree = ""; 121 | }; 122 | D3FCA1D31E4E544C0003A30D /* NibViewExample */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | D3FCA1D41E4E544C0003A30D /* AppDelegate.swift */, 126 | D3FCA1F11E4E56620003A30D /* CardsList */, 127 | D3FCA1F01E4E56620003A30D /* CardDetails */, 128 | D3FCA1D81E4E544C0003A30D /* Main.storyboard */, 129 | D3FCA1DD1E4E544C0003A30D /* LaunchScreen.storyboard */, 130 | D39D11211E4F2F52008F7DF4 /* images.xcassets */, 131 | D3FCA1E01E4E544C0003A30D /* Info.plist */, 132 | ); 133 | path = NibViewExample; 134 | sourceTree = ""; 135 | }; 136 | D3FCA1E91E4E54700003A30D /* Sources */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | D3FCA1EA1E4E54700003A30D /* NibLoadable.swift */, 140 | D3F882C11E4F86CE005C19FF /* NibLoader.swift */, 141 | D3FCA1EB1E4E54700003A30D /* NibView.swift */, 142 | D3FCA1EC1E4E54700003A30D /* NibViewController.swift */, 143 | ); 144 | name = Sources; 145 | path = ../../Sources; 146 | sourceTree = ""; 147 | }; 148 | D3FCA1F01E4E56620003A30D /* CardDetails */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | D396D4BE1E4F46A800C5E25E /* CardDetailsView.swift */, 152 | D396D4C01E4F472C00C5E25E /* CardDetailsView.xib */, 153 | D396D4BC1E4F45B100C5E25E /* CardDetailsViewController.swift */, 154 | ); 155 | path = CardDetails; 156 | sourceTree = ""; 157 | }; 158 | D3FCA1F11E4E56620003A30D /* CardsList */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | D3FCA1F21E4E568B0003A30D /* CardView.swift */, 162 | D3FCA1F41E4E56B00003A30D /* CardView.xib */, 163 | D3D711931E4E5A4500F33BE8 /* CardsListViewController.swift */, 164 | ); 165 | path = CardsList; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXGroup section */ 169 | 170 | /* Begin PBXHeadersBuildPhase section */ 171 | D3FCA1C01E4E53C60003A30D /* Headers */ = { 172 | isa = PBXHeadersBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | D3FCA1C81E4E53C60003A30D /* NibView.h in Headers */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXHeadersBuildPhase section */ 180 | 181 | /* Begin PBXNativeTarget section */ 182 | D3FCA1C21E4E53C60003A30D /* NibView */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = D3FCA1CB1E4E53C60003A30D /* Build configuration list for PBXNativeTarget "NibView" */; 185 | buildPhases = ( 186 | D3FCA1BE1E4E53C60003A30D /* Sources */, 187 | D3FCA1BF1E4E53C60003A30D /* Frameworks */, 188 | D3FCA1C01E4E53C60003A30D /* Headers */, 189 | D3FCA1C11E4E53C60003A30D /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | ); 195 | name = NibView; 196 | productName = NibView; 197 | productReference = D3FCA1C31E4E53C60003A30D /* NibView.framework */; 198 | productType = "com.apple.product-type.framework"; 199 | }; 200 | D3FCA1D11E4E544C0003A30D /* NibViewExample */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = D3FCA1E31E4E544C0003A30D /* Build configuration list for PBXNativeTarget "NibViewExample" */; 203 | buildPhases = ( 204 | D3FCA1CE1E4E544C0003A30D /* Sources */, 205 | D3FCA1CF1E4E544C0003A30D /* Frameworks */, 206 | D3FCA1D01E4E544C0003A30D /* Resources */, 207 | D3FCA1E81E4E545A0003A30D /* Embed Frameworks */, 208 | ); 209 | buildRules = ( 210 | ); 211 | dependencies = ( 212 | D3FCA1E71E4E545A0003A30D /* PBXTargetDependency */, 213 | ); 214 | name = NibViewExample; 215 | productName = NibViewExample; 216 | productReference = D3FCA1D21E4E544C0003A30D /* NibViewExample.app */; 217 | productType = "com.apple.product-type.application"; 218 | }; 219 | /* End PBXNativeTarget section */ 220 | 221 | /* Begin PBXProject section */ 222 | D3FCA1BA1E4E53C60003A30D /* Project object */ = { 223 | isa = PBXProject; 224 | attributes = { 225 | LastSwiftUpdateCheck = 0820; 226 | LastUpgradeCheck = 1020; 227 | ORGANIZATIONNAME = Trafi; 228 | TargetAttributes = { 229 | D3FCA1C21E4E53C60003A30D = { 230 | CreatedOnToolsVersion = 8.2.1; 231 | DevelopmentTeam = MZZWC68X3W; 232 | ProvisioningStyle = Automatic; 233 | }; 234 | D3FCA1D11E4E544C0003A30D = { 235 | CreatedOnToolsVersion = 8.2.1; 236 | DevelopmentTeam = MZZWC68X3W; 237 | ProvisioningStyle = Automatic; 238 | }; 239 | }; 240 | }; 241 | buildConfigurationList = D3FCA1BD1E4E53C60003A30D /* Build configuration list for PBXProject "NibView" */; 242 | compatibilityVersion = "Xcode 3.2"; 243 | developmentRegion = en; 244 | hasScannedForEncodings = 0; 245 | knownRegions = ( 246 | en, 247 | Base, 248 | ); 249 | mainGroup = D3FCA1B91E4E53C60003A30D; 250 | productRefGroup = D3FCA1C41E4E53C60003A30D /* Products */; 251 | projectDirPath = ""; 252 | projectRoot = ""; 253 | targets = ( 254 | D3FCA1C21E4E53C60003A30D /* NibView */, 255 | D3FCA1D11E4E544C0003A30D /* NibViewExample */, 256 | ); 257 | }; 258 | /* End PBXProject section */ 259 | 260 | /* Begin PBXResourcesBuildPhase section */ 261 | D3FCA1C11E4E53C60003A30D /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | D3FCA1D01E4E544C0003A30D /* Resources */ = { 269 | isa = PBXResourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | D3FCA1DF1E4E544C0003A30D /* LaunchScreen.storyboard in Resources */, 273 | D39D11221E4F2F52008F7DF4 /* images.xcassets in Resources */, 274 | D3FCA1DA1E4E544C0003A30D /* Main.storyboard in Resources */, 275 | D396D4C11E4F472C00C5E25E /* CardDetailsView.xib in Resources */, 276 | D3FCA1F51E4E56B00003A30D /* CardView.xib in Resources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXResourcesBuildPhase section */ 281 | 282 | /* Begin PBXSourcesBuildPhase section */ 283 | D3FCA1BE1E4E53C60003A30D /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | D3FCA1EF1E4E54700003A30D /* NibViewController.swift in Sources */, 288 | D3F882C21E4F86CE005C19FF /* NibLoader.swift in Sources */, 289 | D3FCA1ED1E4E54700003A30D /* NibLoadable.swift in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | D3FCA1CE1E4E544C0003A30D /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | D3D711941E4E5A4500F33BE8 /* CardsListViewController.swift in Sources */, 298 | D396D4BD1E4F45B100C5E25E /* CardDetailsViewController.swift in Sources */, 299 | D3254B091E54C4820039D644 /* NibView.swift in Sources */, 300 | D396D4BF1E4F46A800C5E25E /* CardDetailsView.swift in Sources */, 301 | D3FCA1F31E4E568B0003A30D /* CardView.swift in Sources */, 302 | D3FCA1D51E4E544C0003A30D /* AppDelegate.swift in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXSourcesBuildPhase section */ 307 | 308 | /* Begin PBXTargetDependency section */ 309 | D3FCA1E71E4E545A0003A30D /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = D3FCA1C21E4E53C60003A30D /* NibView */; 312 | targetProxy = D3FCA1E61E4E545A0003A30D /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | D3FCA1D81E4E544C0003A30D /* Main.storyboard */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | D3FCA1D91E4E544C0003A30D /* Base */, 321 | ); 322 | name = Main.storyboard; 323 | sourceTree = ""; 324 | }; 325 | D3FCA1DD1E4E544C0003A30D /* LaunchScreen.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | D3FCA1DE1E4E544C0003A30D /* Base */, 329 | ); 330 | name = LaunchScreen.storyboard; 331 | sourceTree = ""; 332 | }; 333 | /* End PBXVariantGroup section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | D3FCA1C91E4E53C60003A30D /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_ANALYZER_NONNULL = YES; 341 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 342 | CLANG_CXX_LIBRARY = "libc++"; 343 | CLANG_ENABLE_MODULES = YES; 344 | CLANG_ENABLE_OBJC_ARC = YES; 345 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_COMMA = YES; 348 | CLANG_WARN_CONSTANT_CONVERSION = YES; 349 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INFINITE_RECURSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 357 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 358 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 361 | CLANG_WARN_STRICT_PROTOTYPES = YES; 362 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | CURRENT_PROJECT_VERSION = 1; 368 | DEBUG_INFORMATION_FORMAT = dwarf; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | ENABLE_TESTABILITY = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_DYNAMIC_NO_PIC = NO; 373 | GCC_NO_COMMON_BLOCKS = YES; 374 | GCC_OPTIMIZATION_LEVEL = 0; 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 386 | MTL_ENABLE_DEBUG_INFO = YES; 387 | ONLY_ACTIVE_ARCH = YES; 388 | SDKROOT = iphoneos; 389 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 390 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 391 | SWIFT_VERSION = 5.0; 392 | TARGETED_DEVICE_FAMILY = "1,2"; 393 | VERSIONING_SYSTEM = "apple-generic"; 394 | VERSION_INFO_PREFIX = ""; 395 | }; 396 | name = Debug; 397 | }; 398 | D3FCA1CA1E4E53C60003A30D /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_ANALYZER_NONNULL = YES; 403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 404 | CLANG_CXX_LIBRARY = "libc++"; 405 | CLANG_ENABLE_MODULES = YES; 406 | CLANG_ENABLE_OBJC_ARC = YES; 407 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_COMMA = YES; 410 | CLANG_WARN_CONSTANT_CONVERSION = YES; 411 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 412 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 413 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 414 | CLANG_WARN_EMPTY_BODY = YES; 415 | CLANG_WARN_ENUM_CONVERSION = YES; 416 | CLANG_WARN_INFINITE_RECURSION = YES; 417 | CLANG_WARN_INT_CONVERSION = YES; 418 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 419 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 420 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 422 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 423 | CLANG_WARN_STRICT_PROTOTYPES = YES; 424 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 425 | CLANG_WARN_UNREACHABLE_CODE = YES; 426 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 427 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 428 | COPY_PHASE_STRIP = NO; 429 | CURRENT_PROJECT_VERSION = 1; 430 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 431 | ENABLE_NS_ASSERTIONS = NO; 432 | ENABLE_STRICT_OBJC_MSGSEND = YES; 433 | GCC_C_LANGUAGE_STANDARD = gnu99; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 436 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 437 | GCC_WARN_UNDECLARED_SELECTOR = YES; 438 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 439 | GCC_WARN_UNUSED_FUNCTION = YES; 440 | GCC_WARN_UNUSED_VARIABLE = YES; 441 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 442 | MTL_ENABLE_DEBUG_INFO = NO; 443 | SDKROOT = iphoneos; 444 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 445 | SWIFT_VERSION = 5.0; 446 | TARGETED_DEVICE_FAMILY = "1,2"; 447 | VALIDATE_PRODUCT = YES; 448 | VERSIONING_SYSTEM = "apple-generic"; 449 | VERSION_INFO_PREFIX = ""; 450 | }; 451 | name = Release; 452 | }; 453 | D3FCA1CC1E4E53C60003A30D /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | CODE_SIGN_IDENTITY = ""; 457 | DEFINES_MODULE = YES; 458 | DEVELOPMENT_TEAM = MZZWC68X3W; 459 | DYLIB_COMPATIBILITY_VERSION = 1; 460 | DYLIB_CURRENT_VERSION = 1; 461 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 462 | INFOPLIST_FILE = NibView/Info.plist; 463 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = Trafi.NibView; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | SKIP_INSTALL = YES; 468 | }; 469 | name = Debug; 470 | }; 471 | D3FCA1CD1E4E53C60003A30D /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | CODE_SIGN_IDENTITY = ""; 475 | DEFINES_MODULE = YES; 476 | DEVELOPMENT_TEAM = MZZWC68X3W; 477 | DYLIB_COMPATIBILITY_VERSION = 1; 478 | DYLIB_CURRENT_VERSION = 1; 479 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 480 | INFOPLIST_FILE = NibView/Info.plist; 481 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 483 | PRODUCT_BUNDLE_IDENTIFIER = Trafi.NibView; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | SKIP_INSTALL = YES; 486 | }; 487 | name = Release; 488 | }; 489 | D3FCA1E11E4E544C0003A30D /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 493 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 494 | DEVELOPMENT_TEAM = MZZWC68X3W; 495 | INFOPLIST_FILE = NibViewExample/Info.plist; 496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 497 | PRODUCT_BUNDLE_IDENTIFIER = Trafi.NibViewExample; 498 | PRODUCT_NAME = "$(TARGET_NAME)"; 499 | }; 500 | name = Debug; 501 | }; 502 | D3FCA1E21E4E544C0003A30D /* Release */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 506 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 507 | DEVELOPMENT_TEAM = MZZWC68X3W; 508 | INFOPLIST_FILE = NibViewExample/Info.plist; 509 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 510 | PRODUCT_BUNDLE_IDENTIFIER = Trafi.NibViewExample; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | }; 513 | name = Release; 514 | }; 515 | /* End XCBuildConfiguration section */ 516 | 517 | /* Begin XCConfigurationList section */ 518 | D3FCA1BD1E4E53C60003A30D /* Build configuration list for PBXProject "NibView" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | D3FCA1C91E4E53C60003A30D /* Debug */, 522 | D3FCA1CA1E4E53C60003A30D /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | defaultConfigurationName = Release; 526 | }; 527 | D3FCA1CB1E4E53C60003A30D /* Build configuration list for PBXNativeTarget "NibView" */ = { 528 | isa = XCConfigurationList; 529 | buildConfigurations = ( 530 | D3FCA1CC1E4E53C60003A30D /* Debug */, 531 | D3FCA1CD1E4E53C60003A30D /* Release */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | D3FCA1E31E4E544C0003A30D /* Build configuration list for PBXNativeTarget "NibViewExample" */ = { 537 | isa = XCConfigurationList; 538 | buildConfigurations = ( 539 | D3FCA1E11E4E544C0003A30D /* Debug */, 540 | D3FCA1E21E4E544C0003A30D /* Release */, 541 | ); 542 | defaultConfigurationIsVisible = 0; 543 | defaultConfigurationName = Release; 544 | }; 545 | /* End XCConfigurationList section */ 546 | }; 547 | rootObject = D3FCA1BA1E4E53C60003A30D /* Project object */; 548 | } 549 | -------------------------------------------------------------------------------- /Example/NibView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/NibView.xcodeproj/xcshareddata/xcschemes/NibView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Example/NibView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | -------------------------------------------------------------------------------- /Example/NibView/NibView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NibView.h 3 | // NibView 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for NibView. 12 | FOUNDATION_EXPORT double NibViewVersionNumber; 13 | 14 | //! Project version string for NibView. 15 | FOUNDATION_EXPORT const unsigned char NibViewVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Example/NibViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NibViewExample 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | } 15 | -------------------------------------------------------------------------------- /Example/NibViewExample/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 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Example/NibViewExample/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 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardDetails/CardDetailsView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardView.swift 3 | // NibView 4 | // 5 | // Created by Domas on 11/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | import NibView 10 | 11 | @IBDesignable 12 | final class CardDetailsView: NibView { 13 | @IBOutlet var nameLabel: UILabel! 14 | @IBOutlet var professionLabel: UILabel! 15 | @IBOutlet var imageView: UIImageView! 16 | } 17 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardDetails/CardDetailsView.xib: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 40 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardDetails/CardDetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardDetailsViewController.swift 3 | // NibView 4 | // 5 | // Created by Domas on 11/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | import NibView 10 | 11 | class CardDetailsViewController: UIViewController, NibViewController { 12 | typealias ViewType = CardDetailsView 13 | 14 | func setup(with cardView: CardView) { 15 | ui.nameLabel.text = cardView.name 16 | ui.professionLabel.text = cardView.profession 17 | ui.imageView.image = cardView.image 18 | } 19 | 20 | @IBAction private func dismissAnimated() { 21 | dismiss(animated: true, completion: nil) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardsList/CardView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardView.swift 3 | // NibView 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | import NibView 10 | 11 | @IBDesignable 12 | final class CardView: NibView { 13 | @IBOutlet private var nameLabel: UILabel! 14 | @IBOutlet private var professionLabel: UILabel! 15 | @IBOutlet private var imageView: UIImageView! 16 | 17 | @IBInspectable var name: String? { 18 | get { return nameLabel.text } 19 | set { nameLabel.text = newValue } 20 | } 21 | @IBInspectable var profession: String? { 22 | get { return professionLabel.text } 23 | set { professionLabel.text = newValue } 24 | } 25 | @IBInspectable var image: UIImage? { 26 | get { return imageView.image } 27 | set { imageView.image = newValue } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardsList/CardView.xib: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Example/NibViewExample/CardsList/CardsListViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardsListViewController.swift 3 | // NibView 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2017 Trafi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class CardsListViewController: UIViewController { 12 | 13 | @IBAction private func cardTapped(_ gesture: UITapGestureRecognizer) { 14 | performSegue(withIdentifier: "ShowDetails", sender: gesture.view) 15 | } 16 | 17 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 18 | super.prepare(for: segue, sender: sender) 19 | 20 | guard let details = segue.destination as? CardDetailsViewController, let cardView = sender as? CardView else { return } 21 | details.setup(with: cardView) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Example/NibViewExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Example/NibViewExample/images.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" : "1x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "29x29", 26 | "scale" : "3x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "40x40", 36 | "scale" : "3x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "57x57", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "iphone", 45 | "size" : "57x57", 46 | "scale" : "2x" 47 | }, 48 | { 49 | "idiom" : "iphone", 50 | "size" : "60x60", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "iphone", 55 | "size" : "60x60", 56 | "scale" : "3x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "20x20", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "20x20", 66 | "scale" : "2x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "29x29", 71 | "scale" : "1x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "29x29", 76 | "scale" : "2x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "40x40", 81 | "scale" : "1x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "40x40", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ipad", 90 | "size" : "50x50", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "idiom" : "ipad", 95 | "size" : "50x50", 96 | "scale" : "2x" 97 | }, 98 | { 99 | "idiom" : "ipad", 100 | "size" : "72x72", 101 | "scale" : "1x" 102 | }, 103 | { 104 | "idiom" : "ipad", 105 | "size" : "72x72", 106 | "scale" : "2x" 107 | }, 108 | { 109 | "idiom" : "ipad", 110 | "size" : "76x76", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "idiom" : "ipad", 115 | "size" : "76x76", 116 | "scale" : "2x" 117 | }, 118 | { 119 | "idiom" : "ipad", 120 | "size" : "83.5x83.5", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jane.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Jane@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "Jane@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jane.imageset/Jane@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/Jane.imageset/Jane@2x.png -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jane.imageset/Jane@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/Jane.imageset/Jane@3x.png -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jim.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Jim@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "Jim@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jim.imageset/Jim@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/Jim.imageset/Jim@2x.png -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/Jim.imageset/Jim@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/Jim.imageset/Jim@3x.png -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/John.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "John@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "John@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/John.imageset/John@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/John.imageset/John@2x.png -------------------------------------------------------------------------------- /Example/NibViewExample/images.xcassets/John.imageset/John@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Example/NibViewExample/images.xcassets/John.imageset/John@3x.png -------------------------------------------------------------------------------- /Img/Preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Img/Preview.gif -------------------------------------------------------------------------------- /Img/Setup.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trafi/NibView/90f1b2fab30ed1984d590d54a94624bd459a58ea/Img/Setup.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 TRAFI 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 | -------------------------------------------------------------------------------- /NibView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibView.swift 3 | // NibView 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2016 Trafi. All rights reserved. 7 | // 8 | 9 | #if canImport(NibView) 10 | import NibView 11 | #endif 12 | import UIKit 13 | 14 | open class NibView: UIView, NibLoadable { 15 | 16 | open class var nibName: String { 17 | return String(describing: self) 18 | } 19 | 20 | open class var bundle: Bundle { 21 | return Bundle(for: self) 22 | } 23 | 24 | open override func awakeAfter(using aDecoder: NSCoder) -> Any? { 25 | return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder)) 26 | } 27 | 28 | // MARK: - Interface builder 29 | 30 | #if TARGET_INTERFACE_BUILDER 31 | 32 | public override init(frame: CGRect) { 33 | super.init(frame: frame) 34 | nibLoader.initWithFrame() 35 | } 36 | 37 | public required init?(coder aDecoder: NSCoder) { 38 | super.init(coder: aDecoder) 39 | } 40 | 41 | open override func prepareForInterfaceBuilder() { 42 | super.prepareForInterfaceBuilder() 43 | nibLoader.prepareForInterfaceBuilder() 44 | } 45 | 46 | open override func setValue(_ value: Any?, forKeyPath keyPath: String) { 47 | super.setValue(value, forKeyPath: keyPath) 48 | nibLoader.setValue(value, forKeyPath: keyPath) 49 | } 50 | 51 | #endif 52 | } 53 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let sourceFiles = [ 7 | "Sources/NibLoadable.swift", 8 | "Sources/NibLoader.swift", 9 | "Sources/NibViewController.swift", 10 | "NibView.swift" 11 | ] 12 | 13 | let excludedFiles = [ 14 | "Example", 15 | "Img", 16 | "README.md", 17 | "CODEOWNERS", 18 | "LICENSE" 19 | ] 20 | 21 | let package = Package( 22 | name: "NibView", 23 | defaultLocalization: "en", 24 | products: [ 25 | .library(name: "NibView", targets: ["NibView"]) 26 | ], 27 | targets: [ 28 | .target(name: "NibView", path: "", exclude: excludedFiles, sources: sourceFiles) 29 | ], 30 | swiftLanguageVersions: [.v5] 31 | ) 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 2 | 3 | # NibView 4 | ```swift 5 | @IBDesignable class MyView: NibView {} // That's it! ✨ 6 | ``` 7 | ![Preview](Img/Preview.gif) 8 | 9 | Tiny Swift framework to reference nibs from anywhere - code, other nibs or storyboards :sparkles: 10 | 11 | | | **Capabilities** | 12 | | --- | --------------- | 13 | | ✨ | **True** rendering inside interface builder with `@IBDesignable` and `@IBInspectable` | 14 | | 📏 | Calculates correct intrinsic content size | 15 | | ♻️ | Referencing from other nibs and storyboards - keeping them small | 16 | | ⌨️ | Loading from code with a simple `.fromNib()` | 17 | | ⚙️ | Integrates as little or as much | 18 | 19 | 20 | Play around with [`Example` project](Example) 🕹️👈 21 | 22 | # Usage 23 | 24 | ## Subclass `NibView` 25 | Just subclass `NibView` and optionally add `@IBDesignable` attribute. That's it! ✨ 26 | ```swift 27 | @IBDesignable class MyView: NibView {} 28 | ``` 29 | ![Setup](Img/Setup.gif) 30 | 31 |
32 | ⚠️ Usage If subclassing is not an option. 33 | 34 | ## Implement `NibLoadable` 35 | Implementing `NibLoadable` protocol and overriding a couple of functions will unleash the full power of referencing 💪:neckbeard: 36 | 37 | ### ⌨️ - Code 38 | To reference nibs only from code implement `NibLoadable` protocol: 39 | ```swift 40 | class MyView: SomeBaseView, NibLoadable { 41 | // 'nibName' defaults to class name. "MyView" in this case. 42 | class var nibName: String { return "MyCustomView" } 43 | } 44 | let myView = MyView.fromNib() 45 | ``` 46 | ### 💻 - IB 47 | To reference nibs from interface builder (other nibs or storyboards) in addition to implementing `NibLoadable` override `awakeAfter(using:)` with a call to `nibLoader` - a helper struct from 'NibLoadable' protocol: 48 | ```swift 49 | class MyView: SomeBaseView, NibLoadable { 50 | override func awakeAfter(using aDecoder: NSCoder) -> Any? { 51 | return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder)) 52 | } 53 | } 54 | ``` 55 | ### ⚡️📱✨ - `@IBDesignable` 56 | To get real rendering and intrinsic content size from the nib - `@IBDesignable` attribute and some overrides are needed: 57 | ```swift 58 | @IBDesignable 59 | class MyView: SomeBaseView, NibLoadable { 60 | 61 | open override func awakeAfter(using aDecoder: NSCoder) -> Any? { 62 | return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder)) 63 | } 64 | 65 | #if TARGET_INTERFACE_BUILDER 66 | 67 | override init(frame: CGRect) { 68 | super.init(frame: frame) 69 | nibLoader.initWithFrame() 70 | } 71 | 72 | required init?(coder aDecoder: NSCoder) { 73 | super.init(coder: aDecoder) 74 | } 75 | 76 | override func prepareForInterfaceBuilder() { 77 | super.prepareForInterfaceBuilder() 78 | nibLoader.prepareForInterfaceBuilder() 79 | } 80 | 81 | override func setValue(_ value: Any?, forKeyPath keyPath: String) { 82 | super.setValue(value, forKeyPath: keyPath) 83 | nibLoader.setValue(value, forKeyPath: keyPath) 84 | } 85 | 86 | #endif 87 | } 88 | ``` 89 |
90 | 91 | # Installation 92 | ## [Carthage](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) 93 | Drag [`NibView.swift`](NibView.swift) file into your Xcode project and add the following line to your Cartfile: 94 | ``` 95 | github "Trafi/NibView" 96 | ``` 97 | 98 | ## [Swift Package Manager](https://swift.org/package-manager/) 99 | ``` 100 | dependencies: [ 101 | .package(url: "https://github.com/trafi/NibView.git", .upToNextMajor(from: "2.0.0")) 102 | ] 103 | ``` 104 | 105 | ## Manual 106 | Drag the [`Sources`](Sources) folder and [`NibView.swift`](NibView.swift) file into your Xcode project. 107 | -------------------------------------------------------------------------------- /Sources/NibLoadable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibLoadable.swift 3 | // NibLoadable 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2016 Trafi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /** 12 | `NibLoadable` helps you reuse views created in .xib files. 13 | 14 | # Reference only from code 15 | Setup class by conforming to `NibLoadable`: 16 | 17 | class MyView: UIView, NibLoadable {} 18 | 19 | Get the view loaded from nib with a one-liner: 20 | 21 | let myView = MyView.fromNib() 22 | 23 | Setup like this will look for a file named "MyView.xib" in your project and load the view that is of type `MyView`. 24 | 25 | *Optionally* provide custom nib name (defaults to type name): 26 | 27 | class var nibName: String { return "MyCustomView" } 28 | 29 | *Optionally* provide custom bundle (defaults to class location): 30 | 31 | class var bundle: Bundle { return Bundle(for: self) } 32 | 33 | # Refencing from IB 34 | 35 | To reference view from another .xib or .storyboard file simply subclass `NibView`: 36 | 37 | class MyView: NibView {} 38 | 39 | If subclassing is **not an option** override `awakeAfter(using:)` with a call to `nibLoader`: 40 | 41 | class MyView: SomeBaseView, NibLoadable { 42 | open override func awakeAfter(using aDecoder: NSCoder) -> Any? { 43 | return nibLoader.awakeAfter(using: aDecoder, 44 | super.awakeAfter(using: aDecoder)) 45 | } 46 | } 47 | 48 | # @IBDesignable referencing from IB 49 | 50 | To see live updates and get intrinsic content size of view reference simply subclass `NibView` with `@IBDesignable` attribute: 51 | 52 | @IBDesignable 53 | class MyView: NibView {} 54 | 55 | If subclassing is **not an option** override functions of the view with calls to `nibLoader`: 56 | 57 | @IBDesignable 58 | class MyView: SomeBaseView, NibLoadable { 59 | 60 | open override func awakeAfter(using aDecoder: NSCoder) -> Any? { 61 | return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder)) 62 | } 63 | 64 | #if TARGET_INTERFACE_BUILDER 65 | 66 | public override init(frame: CGRect) { 67 | super.init(frame: frame) 68 | nibLoader.initWithFrame() 69 | } 70 | 71 | public required init?(coder aDecoder: NSCoder) { 72 | super.init(coder: aDecoder) 73 | } 74 | 75 | open override func prepareForInterfaceBuilder() { 76 | super.prepareForInterfaceBuilder() 77 | nibLoader.prepareForInterfaceBuilder() 78 | } 79 | 80 | open override func setValue(_ value: Any?, forKeyPath keyPath: String) { 81 | super.setValue(value, forKeyPath: keyPath) 82 | nibLoader.setValue(value, forKeyPath: keyPath) 83 | } 84 | 85 | #endif 86 | } 87 | 88 | */ 89 | public protocol NibLoadable: class { 90 | static var nibName: String { get } 91 | static var bundle: Bundle { get } 92 | } 93 | 94 | // MARK: - From Nib 95 | 96 | public extension NibLoadable where Self: UIView { 97 | 98 | static var nibName: String { 99 | return String(describing: self) 100 | } 101 | 102 | static var bundle: Bundle { 103 | return Bundle(for: self) 104 | } 105 | 106 | static func fromNib() -> Self { 107 | guard let nib = self.bundle.loadNibNamed(nibName, owner: nil, options: nil) else { 108 | fatalError("Failed loading the nib named \(nibName) for 'NibLoadable' view of type '\(self)'.") 109 | } 110 | guard let view = (nib.first { $0 is Self }) as? Self else { 111 | fatalError("Did not find 'NibLoadable' view of type '\(self)' inside '\(nibName).xib'.") 112 | } 113 | return view 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Sources/NibLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibLoader.swift 3 | // NibLoader 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2016 Trafi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | // MARK: - Public 12 | 13 | public extension NibLoadable where Self: UIView { 14 | var nibLoader: IBNibLoader { return IBNibLoader(self) } 15 | } 16 | 17 | public struct IBNibLoader where NibLoadableView: UIView { 18 | 19 | public func awakeAfter(using aDecoder: NSCoder, _ superMethod: @autoclosure () -> Any?) -> Any? { 20 | guard nonPrivateSubviews.isEmpty else { return superMethod() } 21 | 22 | let nibView = type(of: view).fromNib() 23 | copyProperties(to: nibView) 24 | copyConstraints(to: nibView) 25 | 26 | return nibView 27 | } 28 | 29 | public func initWithFrame() { 30 | let nibView = type(of: view).fromNib() 31 | copyProperties(to: nibView) 32 | SubviewsCopier.copySubviewReferences(from: nibView, to: view) 33 | 34 | nibView.frame = view.bounds 35 | nibView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 36 | view.addSubview(nibView) 37 | } 38 | 39 | public func prepareForInterfaceBuilder() { 40 | if nonPrivateSubviews.count == 1 { 41 | // Used as a reference container 42 | view.backgroundColor = .clear 43 | } else { 44 | // Is original .xib file 45 | nonPrivateSubviews.first?.removeFromSuperview() 46 | } 47 | } 48 | 49 | public func setValue(_ value: Any?, forKeyPath keyPath: String) { 50 | guard let subview = value as? UIView else { return } 51 | SubviewsCopier.store(subview: subview, forKeyPath: keyPath, of: view) 52 | } 53 | 54 | 55 | // MARK: - Private 56 | 57 | private let view: NibLoadableView 58 | fileprivate init(_ view: NibLoadableView) { 59 | self.view = view 60 | } 61 | 62 | private var nonPrivateSubviews: [UIView] { 63 | return view.subviews.filter { !String(describing: type(of: $0)).hasPrefix("_") } 64 | } 65 | 66 | private func copyProperties(to nibView: UIView) { 67 | nibView.frame = view.frame 68 | nibView.autoresizingMask = view.autoresizingMask 69 | nibView.translatesAutoresizingMaskIntoConstraints = view.translatesAutoresizingMaskIntoConstraints 70 | nibView.clipsToBounds = view.clipsToBounds 71 | nibView.alpha = view.alpha 72 | nibView.isHidden = view.isHidden 73 | } 74 | 75 | private func copyConstraints(to nibView: UIView) { 76 | nibView.addConstraints( 77 | view.constraints.map { 78 | NSLayoutConstraint( 79 | item: $0.firstItem === view ? nibView : $0.firstItem as Any, 80 | attribute: $0.firstAttribute, 81 | relatedBy: $0.relation, 82 | toItem: $0.secondItem === view ? nibView : $0.secondItem, 83 | attribute: $0.secondAttribute, 84 | multiplier: $0.multiplier, 85 | constant: $0.constant) 86 | } 87 | ) 88 | } 89 | } 90 | 91 | 92 | fileprivate struct SubviewsCopier { 93 | 94 | static var viewKeyPathsForSubviews = [UIView: [String: UIView]]() 95 | 96 | static func store(subview: UIView, forKeyPath keyPath: String, of view: UIView) { 97 | if viewKeyPathsForSubviews[view] == nil { 98 | viewKeyPathsForSubviews[view] = [keyPath: subview] 99 | } else { 100 | viewKeyPathsForSubviews[view]?[keyPath] = subview 101 | } 102 | } 103 | 104 | static func copySubviewReferences(from view: UIView, to otherView: UIView) { 105 | viewKeyPathsForSubviews[view]?.forEach { otherView.setValue($0.value, forKeyPath: $0.key) } 106 | viewKeyPathsForSubviews[view] = nil 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Sources/NibViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibViewController.swift 3 | // NibViewController 4 | // 5 | // Created by Domas on 10/02/2017. 6 | // Copyright © 2016 Trafi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol NibViewController { 12 | associatedtype ViewType: NibLoadable 13 | } 14 | 15 | public extension NibViewController where Self: UIViewController { 16 | var ui: ViewType { 17 | guard let ui = view as? ViewType else { 18 | fatalError("'\(type(of: self))' 'view' type did not match the 'ViewType' declared in conformance to 'NibViewController' protocol.Found \(type(of: view)) instead of expected '\(ViewType.self)'") 19 | } 20 | return ui 21 | } 22 | } 23 | --------------------------------------------------------------------------------