├── PencilKitExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── yoellev.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── PencilKitExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Controller │ └── PencilKitViewController.swift ├── Info.plist ├── PencilKit View │ ├── PKCanvas.swift │ └── PencilKitInterface.swift └── SceneDelegate.swift ├── PencilKitExampleTests ├── Info.plist └── PencilKitExampleTests.swift ├── PencilKitExampleUITests ├── Info.plist └── PencilKitExampleUITests.swift ├── README.md └── pencilKitOverview.gif /PencilKitExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B15FC4A523349F82008D7031 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4A423349F82008D7031 /* AppDelegate.swift */; }; 11 | B15FC4A723349F82008D7031 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4A623349F82008D7031 /* SceneDelegate.swift */; }; 12 | B15FC4A923349F82008D7031 /* PencilKitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4A823349F82008D7031 /* PencilKitViewController.swift */; }; 13 | B15FC4AC23349F82008D7031 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B15FC4AA23349F82008D7031 /* Main.storyboard */; }; 14 | B15FC4AE23349F83008D7031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B15FC4AD23349F83008D7031 /* Assets.xcassets */; }; 15 | B15FC4B123349F83008D7031 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B15FC4AF23349F83008D7031 /* LaunchScreen.storyboard */; }; 16 | B15FC4BC23349F83008D7031 /* PencilKitExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4BB23349F83008D7031 /* PencilKitExampleTests.swift */; }; 17 | B15FC4C723349F84008D7031 /* PencilKitExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4C623349F84008D7031 /* PencilKitExampleUITests.swift */; }; 18 | B15FC4D52334A159008D7031 /* PencilKitInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4D42334A159008D7031 /* PencilKitInterface.swift */; }; 19 | B15FC4D72334A17F008D7031 /* PKCanvas.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15FC4D62334A17F008D7031 /* PKCanvas.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | B15FC4B823349F83008D7031 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = B15FC49923349F82008D7031 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = B15FC4A023349F82008D7031; 28 | remoteInfo = PencilKitExample; 29 | }; 30 | B15FC4C323349F84008D7031 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = B15FC49923349F82008D7031 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = B15FC4A023349F82008D7031; 35 | remoteInfo = PencilKitExample; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | B15FC4A123349F82008D7031 /* PencilKitExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PencilKitExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | B15FC4A423349F82008D7031 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 42 | B15FC4A623349F82008D7031 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 43 | B15FC4A823349F82008D7031 /* PencilKitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PencilKitViewController.swift; sourceTree = ""; }; 44 | B15FC4AB23349F82008D7031 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | B15FC4AD23349F83008D7031 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | B15FC4B023349F83008D7031 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | B15FC4B223349F83008D7031 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | B15FC4B723349F83008D7031 /* PencilKitExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PencilKitExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | B15FC4BB23349F83008D7031 /* PencilKitExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PencilKitExampleTests.swift; sourceTree = ""; }; 50 | B15FC4BD23349F83008D7031 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | B15FC4C223349F84008D7031 /* PencilKitExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PencilKitExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | B15FC4C623349F84008D7031 /* PencilKitExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PencilKitExampleUITests.swift; sourceTree = ""; }; 53 | B15FC4C823349F84008D7031 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | B15FC4D42334A159008D7031 /* PencilKitInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PencilKitInterface.swift; sourceTree = ""; }; 55 | B15FC4D62334A17F008D7031 /* PKCanvas.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PKCanvas.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | B15FC49E23349F82008D7031 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | B15FC4B423349F83008D7031 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | B15FC4BF23349F84008D7031 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | B15FC49823349F82008D7031 = { 84 | isa = PBXGroup; 85 | children = ( 86 | B15FC4A323349F82008D7031 /* PencilKitExample */, 87 | B15FC4BA23349F83008D7031 /* PencilKitExampleTests */, 88 | B15FC4C523349F84008D7031 /* PencilKitExampleUITests */, 89 | B15FC4A223349F82008D7031 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | B15FC4A223349F82008D7031 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | B15FC4A123349F82008D7031 /* PencilKitExample.app */, 97 | B15FC4B723349F83008D7031 /* PencilKitExampleTests.xctest */, 98 | B15FC4C223349F84008D7031 /* PencilKitExampleUITests.xctest */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | B15FC4A323349F82008D7031 /* PencilKitExample */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | B15FC4A423349F82008D7031 /* AppDelegate.swift */, 107 | B15FC4A623349F82008D7031 /* SceneDelegate.swift */, 108 | B15FC4D82334FEF6008D7031 /* PencilKit View */, 109 | B15FC4D92334FF07008D7031 /* Controller */, 110 | B15FC4AA23349F82008D7031 /* Main.storyboard */, 111 | B15FC4AD23349F83008D7031 /* Assets.xcassets */, 112 | B15FC4AF23349F83008D7031 /* LaunchScreen.storyboard */, 113 | B15FC4B223349F83008D7031 /* Info.plist */, 114 | ); 115 | path = PencilKitExample; 116 | sourceTree = ""; 117 | }; 118 | B15FC4BA23349F83008D7031 /* PencilKitExampleTests */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | B15FC4BB23349F83008D7031 /* PencilKitExampleTests.swift */, 122 | B15FC4BD23349F83008D7031 /* Info.plist */, 123 | ); 124 | path = PencilKitExampleTests; 125 | sourceTree = ""; 126 | }; 127 | B15FC4C523349F84008D7031 /* PencilKitExampleUITests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | B15FC4C623349F84008D7031 /* PencilKitExampleUITests.swift */, 131 | B15FC4C823349F84008D7031 /* Info.plist */, 132 | ); 133 | path = PencilKitExampleUITests; 134 | sourceTree = ""; 135 | }; 136 | B15FC4D82334FEF6008D7031 /* PencilKit View */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | B15FC4D42334A159008D7031 /* PencilKitInterface.swift */, 140 | B15FC4D62334A17F008D7031 /* PKCanvas.swift */, 141 | ); 142 | path = "PencilKit View"; 143 | sourceTree = ""; 144 | }; 145 | B15FC4D92334FF07008D7031 /* Controller */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | B15FC4A823349F82008D7031 /* PencilKitViewController.swift */, 149 | ); 150 | path = Controller; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXGroup section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | B15FC4A023349F82008D7031 /* PencilKitExample */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = B15FC4CB23349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExample" */; 159 | buildPhases = ( 160 | B15FC49D23349F82008D7031 /* Sources */, 161 | B15FC49E23349F82008D7031 /* Frameworks */, 162 | B15FC49F23349F82008D7031 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = PencilKitExample; 169 | productName = PencilKitExample; 170 | productReference = B15FC4A123349F82008D7031 /* PencilKitExample.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | B15FC4B623349F83008D7031 /* PencilKitExampleTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = B15FC4CE23349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExampleTests" */; 176 | buildPhases = ( 177 | B15FC4B323349F83008D7031 /* Sources */, 178 | B15FC4B423349F83008D7031 /* Frameworks */, 179 | B15FC4B523349F83008D7031 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | B15FC4B923349F83008D7031 /* PBXTargetDependency */, 185 | ); 186 | name = PencilKitExampleTests; 187 | productName = PencilKitExampleTests; 188 | productReference = B15FC4B723349F83008D7031 /* PencilKitExampleTests.xctest */; 189 | productType = "com.apple.product-type.bundle.unit-test"; 190 | }; 191 | B15FC4C123349F84008D7031 /* PencilKitExampleUITests */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = B15FC4D123349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExampleUITests" */; 194 | buildPhases = ( 195 | B15FC4BE23349F84008D7031 /* Sources */, 196 | B15FC4BF23349F84008D7031 /* Frameworks */, 197 | B15FC4C023349F84008D7031 /* Resources */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | B15FC4C423349F84008D7031 /* PBXTargetDependency */, 203 | ); 204 | name = PencilKitExampleUITests; 205 | productName = PencilKitExampleUITests; 206 | productReference = B15FC4C223349F84008D7031 /* PencilKitExampleUITests.xctest */; 207 | productType = "com.apple.product-type.bundle.ui-testing"; 208 | }; 209 | /* End PBXNativeTarget section */ 210 | 211 | /* Begin PBXProject section */ 212 | B15FC49923349F82008D7031 /* Project object */ = { 213 | isa = PBXProject; 214 | attributes = { 215 | LastSwiftUpdateCheck = 1100; 216 | LastUpgradeCheck = 1100; 217 | ORGANIZATIONNAME = "Yoel Lev"; 218 | TargetAttributes = { 219 | B15FC4A023349F82008D7031 = { 220 | CreatedOnToolsVersion = 11.0; 221 | }; 222 | B15FC4B623349F83008D7031 = { 223 | CreatedOnToolsVersion = 11.0; 224 | TestTargetID = B15FC4A023349F82008D7031; 225 | }; 226 | B15FC4C123349F84008D7031 = { 227 | CreatedOnToolsVersion = 11.0; 228 | TestTargetID = B15FC4A023349F82008D7031; 229 | }; 230 | }; 231 | }; 232 | buildConfigurationList = B15FC49C23349F82008D7031 /* Build configuration list for PBXProject "PencilKitExample" */; 233 | compatibilityVersion = "Xcode 9.3"; 234 | developmentRegion = en; 235 | hasScannedForEncodings = 0; 236 | knownRegions = ( 237 | en, 238 | Base, 239 | ); 240 | mainGroup = B15FC49823349F82008D7031; 241 | productRefGroup = B15FC4A223349F82008D7031 /* Products */; 242 | projectDirPath = ""; 243 | projectRoot = ""; 244 | targets = ( 245 | B15FC4A023349F82008D7031 /* PencilKitExample */, 246 | B15FC4B623349F83008D7031 /* PencilKitExampleTests */, 247 | B15FC4C123349F84008D7031 /* PencilKitExampleUITests */, 248 | ); 249 | }; 250 | /* End PBXProject section */ 251 | 252 | /* Begin PBXResourcesBuildPhase section */ 253 | B15FC49F23349F82008D7031 /* Resources */ = { 254 | isa = PBXResourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | B15FC4B123349F83008D7031 /* LaunchScreen.storyboard in Resources */, 258 | B15FC4AE23349F83008D7031 /* Assets.xcassets in Resources */, 259 | B15FC4AC23349F82008D7031 /* Main.storyboard in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | B15FC4B523349F83008D7031 /* Resources */ = { 264 | isa = PBXResourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | B15FC4C023349F84008D7031 /* Resources */ = { 271 | isa = PBXResourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXResourcesBuildPhase section */ 278 | 279 | /* Begin PBXSourcesBuildPhase section */ 280 | B15FC49D23349F82008D7031 /* Sources */ = { 281 | isa = PBXSourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | B15FC4A923349F82008D7031 /* PencilKitViewController.swift in Sources */, 285 | B15FC4A523349F82008D7031 /* AppDelegate.swift in Sources */, 286 | B15FC4A723349F82008D7031 /* SceneDelegate.swift in Sources */, 287 | B15FC4D72334A17F008D7031 /* PKCanvas.swift in Sources */, 288 | B15FC4D52334A159008D7031 /* PencilKitInterface.swift in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | B15FC4B323349F83008D7031 /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | B15FC4BC23349F83008D7031 /* PencilKitExampleTests.swift in Sources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | B15FC4BE23349F84008D7031 /* Sources */ = { 301 | isa = PBXSourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | B15FC4C723349F84008D7031 /* PencilKitExampleUITests.swift in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | /* End PBXSourcesBuildPhase section */ 309 | 310 | /* Begin PBXTargetDependency section */ 311 | B15FC4B923349F83008D7031 /* PBXTargetDependency */ = { 312 | isa = PBXTargetDependency; 313 | target = B15FC4A023349F82008D7031 /* PencilKitExample */; 314 | targetProxy = B15FC4B823349F83008D7031 /* PBXContainerItemProxy */; 315 | }; 316 | B15FC4C423349F84008D7031 /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = B15FC4A023349F82008D7031 /* PencilKitExample */; 319 | targetProxy = B15FC4C323349F84008D7031 /* PBXContainerItemProxy */; 320 | }; 321 | /* End PBXTargetDependency section */ 322 | 323 | /* Begin PBXVariantGroup section */ 324 | B15FC4AA23349F82008D7031 /* Main.storyboard */ = { 325 | isa = PBXVariantGroup; 326 | children = ( 327 | B15FC4AB23349F82008D7031 /* Base */, 328 | ); 329 | name = Main.storyboard; 330 | sourceTree = ""; 331 | }; 332 | B15FC4AF23349F83008D7031 /* LaunchScreen.storyboard */ = { 333 | isa = PBXVariantGroup; 334 | children = ( 335 | B15FC4B023349F83008D7031 /* Base */, 336 | ); 337 | name = LaunchScreen.storyboard; 338 | sourceTree = ""; 339 | }; 340 | /* End PBXVariantGroup section */ 341 | 342 | /* Begin XCBuildConfiguration section */ 343 | B15FC4C923349F84008D7031 /* Debug */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | ALWAYS_SEARCH_USER_PATHS = NO; 347 | CLANG_ANALYZER_NONNULL = YES; 348 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 349 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 350 | CLANG_CXX_LIBRARY = "libc++"; 351 | CLANG_ENABLE_MODULES = YES; 352 | CLANG_ENABLE_OBJC_ARC = YES; 353 | CLANG_ENABLE_OBJC_WEAK = YES; 354 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 355 | CLANG_WARN_BOOL_CONVERSION = YES; 356 | CLANG_WARN_COMMA = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 361 | CLANG_WARN_EMPTY_BODY = YES; 362 | CLANG_WARN_ENUM_CONVERSION = YES; 363 | CLANG_WARN_INFINITE_RECURSION = YES; 364 | CLANG_WARN_INT_CONVERSION = YES; 365 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 366 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 367 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 370 | CLANG_WARN_STRICT_PROTOTYPES = YES; 371 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 372 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 373 | CLANG_WARN_UNREACHABLE_CODE = YES; 374 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 375 | COPY_PHASE_STRIP = NO; 376 | DEBUG_INFORMATION_FORMAT = dwarf; 377 | ENABLE_STRICT_OBJC_MSGSEND = YES; 378 | ENABLE_TESTABILITY = YES; 379 | GCC_C_LANGUAGE_STANDARD = gnu11; 380 | GCC_DYNAMIC_NO_PIC = NO; 381 | GCC_NO_COMMON_BLOCKS = YES; 382 | GCC_OPTIMIZATION_LEVEL = 0; 383 | GCC_PREPROCESSOR_DEFINITIONS = ( 384 | "DEBUG=1", 385 | "$(inherited)", 386 | ); 387 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 388 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 389 | GCC_WARN_UNDECLARED_SELECTOR = YES; 390 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 391 | GCC_WARN_UNUSED_FUNCTION = YES; 392 | GCC_WARN_UNUSED_VARIABLE = YES; 393 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 394 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 395 | MTL_FAST_MATH = YES; 396 | ONLY_ACTIVE_ARCH = YES; 397 | SDKROOT = iphoneos; 398 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 399 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 400 | }; 401 | name = Debug; 402 | }; 403 | B15FC4CA23349F84008D7031 /* Release */ = { 404 | isa = XCBuildConfiguration; 405 | buildSettings = { 406 | ALWAYS_SEARCH_USER_PATHS = NO; 407 | CLANG_ANALYZER_NONNULL = YES; 408 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 409 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 410 | CLANG_CXX_LIBRARY = "libc++"; 411 | CLANG_ENABLE_MODULES = YES; 412 | CLANG_ENABLE_OBJC_ARC = YES; 413 | CLANG_ENABLE_OBJC_WEAK = YES; 414 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_COMMA = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 419 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 420 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 421 | CLANG_WARN_EMPTY_BODY = YES; 422 | CLANG_WARN_ENUM_CONVERSION = YES; 423 | CLANG_WARN_INFINITE_RECURSION = YES; 424 | CLANG_WARN_INT_CONVERSION = YES; 425 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 426 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 427 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 428 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 429 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 430 | CLANG_WARN_STRICT_PROTOTYPES = YES; 431 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 432 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 433 | CLANG_WARN_UNREACHABLE_CODE = YES; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | COPY_PHASE_STRIP = NO; 436 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 437 | ENABLE_NS_ASSERTIONS = NO; 438 | ENABLE_STRICT_OBJC_MSGSEND = YES; 439 | GCC_C_LANGUAGE_STANDARD = gnu11; 440 | GCC_NO_COMMON_BLOCKS = YES; 441 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 442 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 443 | GCC_WARN_UNDECLARED_SELECTOR = YES; 444 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 445 | GCC_WARN_UNUSED_FUNCTION = YES; 446 | GCC_WARN_UNUSED_VARIABLE = YES; 447 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 448 | MTL_ENABLE_DEBUG_INFO = NO; 449 | MTL_FAST_MATH = YES; 450 | SDKROOT = iphoneos; 451 | SWIFT_COMPILATION_MODE = wholemodule; 452 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 453 | VALIDATE_PRODUCT = YES; 454 | }; 455 | name = Release; 456 | }; 457 | B15FC4CC23349F84008D7031 /* Debug */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 461 | CODE_SIGN_STYLE = Automatic; 462 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 463 | INFOPLIST_FILE = PencilKitExample/Info.plist; 464 | LD_RUNPATH_SEARCH_PATHS = ( 465 | "$(inherited)", 466 | "@executable_path/Frameworks", 467 | ); 468 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExample; 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | SWIFT_VERSION = 5.0; 471 | TARGETED_DEVICE_FAMILY = "1,2"; 472 | }; 473 | name = Debug; 474 | }; 475 | B15FC4CD23349F84008D7031 /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 479 | CODE_SIGN_STYLE = Automatic; 480 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 481 | INFOPLIST_FILE = PencilKitExample/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = ( 483 | "$(inherited)", 484 | "@executable_path/Frameworks", 485 | ); 486 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExample; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_VERSION = 5.0; 489 | TARGETED_DEVICE_FAMILY = "1,2"; 490 | }; 491 | name = Release; 492 | }; 493 | B15FC4CF23349F84008D7031 /* Debug */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 497 | BUNDLE_LOADER = "$(TEST_HOST)"; 498 | CODE_SIGN_STYLE = Automatic; 499 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 500 | INFOPLIST_FILE = PencilKitExampleTests/Info.plist; 501 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 502 | LD_RUNPATH_SEARCH_PATHS = ( 503 | "$(inherited)", 504 | "@executable_path/Frameworks", 505 | "@loader_path/Frameworks", 506 | ); 507 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExampleTests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | SWIFT_VERSION = 5.0; 510 | TARGETED_DEVICE_FAMILY = "1,2"; 511 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PencilKitExample.app/PencilKitExample"; 512 | }; 513 | name = Debug; 514 | }; 515 | B15FC4D023349F84008D7031 /* Release */ = { 516 | isa = XCBuildConfiguration; 517 | buildSettings = { 518 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 519 | BUNDLE_LOADER = "$(TEST_HOST)"; 520 | CODE_SIGN_STYLE = Automatic; 521 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 522 | INFOPLIST_FILE = PencilKitExampleTests/Info.plist; 523 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 524 | LD_RUNPATH_SEARCH_PATHS = ( 525 | "$(inherited)", 526 | "@executable_path/Frameworks", 527 | "@loader_path/Frameworks", 528 | ); 529 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExampleTests; 530 | PRODUCT_NAME = "$(TARGET_NAME)"; 531 | SWIFT_VERSION = 5.0; 532 | TARGETED_DEVICE_FAMILY = "1,2"; 533 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PencilKitExample.app/PencilKitExample"; 534 | }; 535 | name = Release; 536 | }; 537 | B15FC4D223349F84008D7031 /* Debug */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 541 | CODE_SIGN_STYLE = Automatic; 542 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 543 | INFOPLIST_FILE = PencilKitExampleUITests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = ( 545 | "$(inherited)", 546 | "@executable_path/Frameworks", 547 | "@loader_path/Frameworks", 548 | ); 549 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExampleUITests; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | SWIFT_VERSION = 5.0; 552 | TARGETED_DEVICE_FAMILY = "1,2"; 553 | TEST_TARGET_NAME = PencilKitExample; 554 | }; 555 | name = Debug; 556 | }; 557 | B15FC4D323349F84008D7031 /* Release */ = { 558 | isa = XCBuildConfiguration; 559 | buildSettings = { 560 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 561 | CODE_SIGN_STYLE = Automatic; 562 | DEVELOPMENT_TEAM = 7MC85J6Z5Y; 563 | INFOPLIST_FILE = PencilKitExampleUITests/Info.plist; 564 | LD_RUNPATH_SEARCH_PATHS = ( 565 | "$(inherited)", 566 | "@executable_path/Frameworks", 567 | "@loader_path/Frameworks", 568 | ); 569 | PRODUCT_BUNDLE_IDENTIFIER = com.yoelev.PencilKitExampleUITests; 570 | PRODUCT_NAME = "$(TARGET_NAME)"; 571 | SWIFT_VERSION = 5.0; 572 | TARGETED_DEVICE_FAMILY = "1,2"; 573 | TEST_TARGET_NAME = PencilKitExample; 574 | }; 575 | name = Release; 576 | }; 577 | /* End XCBuildConfiguration section */ 578 | 579 | /* Begin XCConfigurationList section */ 580 | B15FC49C23349F82008D7031 /* Build configuration list for PBXProject "PencilKitExample" */ = { 581 | isa = XCConfigurationList; 582 | buildConfigurations = ( 583 | B15FC4C923349F84008D7031 /* Debug */, 584 | B15FC4CA23349F84008D7031 /* Release */, 585 | ); 586 | defaultConfigurationIsVisible = 0; 587 | defaultConfigurationName = Release; 588 | }; 589 | B15FC4CB23349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExample" */ = { 590 | isa = XCConfigurationList; 591 | buildConfigurations = ( 592 | B15FC4CC23349F84008D7031 /* Debug */, 593 | B15FC4CD23349F84008D7031 /* Release */, 594 | ); 595 | defaultConfigurationIsVisible = 0; 596 | defaultConfigurationName = Release; 597 | }; 598 | B15FC4CE23349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExampleTests" */ = { 599 | isa = XCConfigurationList; 600 | buildConfigurations = ( 601 | B15FC4CF23349F84008D7031 /* Debug */, 602 | B15FC4D023349F84008D7031 /* Release */, 603 | ); 604 | defaultConfigurationIsVisible = 0; 605 | defaultConfigurationName = Release; 606 | }; 607 | B15FC4D123349F84008D7031 /* Build configuration list for PBXNativeTarget "PencilKitExampleUITests" */ = { 608 | isa = XCConfigurationList; 609 | buildConfigurations = ( 610 | B15FC4D223349F84008D7031 /* Debug */, 611 | B15FC4D323349F84008D7031 /* Release */, 612 | ); 613 | defaultConfigurationIsVisible = 0; 614 | defaultConfigurationName = Release; 615 | }; 616 | /* End XCConfigurationList section */ 617 | }; 618 | rootObject = B15FC49923349F82008D7031 /* Project object */; 619 | } 620 | -------------------------------------------------------------------------------- /PencilKitExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PencilKitExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PencilKitExample.xcodeproj/xcuserdata/yoellev.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PencilKitExample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PencilKitExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PencilKitExample 4 | // 5 | // Created by Yoel Lev on 20/09/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /PencilKitExample/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 | } -------------------------------------------------------------------------------- /PencilKitExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PencilKitExample/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 | -------------------------------------------------------------------------------- /PencilKitExample/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 | -------------------------------------------------------------------------------- /PencilKitExample/Controller/PencilKitViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PencilKitViewController.swift 3 | // PencilKitExample 4 | // 5 | // Created by Yoel Lev on 20/09/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PencilKitViewController: UIViewController { 12 | 13 | var pencilKitCanvas = PKCanvas() 14 | 15 | //MARK: - iOS Life Cycle 16 | override func viewDidAppear(_ animated: Bool) { 17 | super.viewDidAppear(animated) 18 | addPencilKit() 19 | } 20 | 21 | override func viewDidLayoutSubviews() { 22 | super.viewDidLayoutSubviews() 23 | updateCanvasOrientation(with: view.bounds) 24 | } 25 | 26 | //MARK: - iOS override properties 27 | override var prefersHomeIndicatorAutoHidden: Bool { 28 | return true 29 | } 30 | 31 | override var prefersStatusBarHidden: Bool { 32 | return true; 33 | } 34 | 35 | //MARK: - Setup Functions 36 | 37 | private func addPencilKit() { 38 | view.backgroundColor = .clear 39 | 40 | pencilKitCanvas = createPencilKitCanvas(frame: view.frame, delegate: self) 41 | view.addSubview(pencilKitCanvas) 42 | } 43 | 44 | } 45 | 46 | extension PencilKitViewController: PencilKitInterface { } 47 | 48 | extension PencilKitViewController: PencilKitDelegate { } 49 | -------------------------------------------------------------------------------- /PencilKitExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /PencilKitExample/PencilKit View/PKCanvas.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PKCanvas.swift 3 | // PencilKitDemo 4 | // 5 | // Created by Yoel Lev on 17/08/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import PencilKit 11 | 12 | class PKCanvas: UIView { 13 | 14 | var canvasView: PKCanvasView! 15 | weak var pencilKitDelegate: PencilKitDelegate? 16 | 17 | //MARK: - iOS Life Cycle 18 | override init(frame: CGRect) { 19 | super.init(frame: frame) 20 | setupPencilKitCanvas() 21 | } 22 | 23 | required init?(coder: NSCoder) { 24 | fatalError("init(coder:) has not been implemented") 25 | } 26 | 27 | func updateCanvasOrientation(with frame: CGRect) { 28 | self.canvasView.frame = frame 29 | self.frame = frame 30 | } 31 | 32 | private func setupPencilKitCanvas() { 33 | canvasView = PKCanvasView(frame:self.bounds) 34 | canvasView.delegate = self 35 | canvasView.alwaysBounceVertical = false 36 | canvasView.allowsFingerDrawing = true 37 | canvasView.becomeFirstResponder() 38 | addSubview(canvasView) 39 | 40 | if let window = UIApplication.shared.windows.last, let toolPicker = PKToolPicker.shared(for: window) { 41 | toolPicker.setVisible(true, forFirstResponder: canvasView) 42 | toolPicker.addObserver(canvasView) 43 | toolPicker.addObserver(self) 44 | canvasView.becomeFirstResponder() 45 | } 46 | } 47 | 48 | } 49 | 50 | 51 | // MARK: Canvas View Delegate 52 | extension PKCanvas: PKCanvasViewDelegate { 53 | 54 | /// Delegate method: Note that the drawing has changed. 55 | func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) { 56 | print("canvasViewDrawingDidChange") 57 | } 58 | } 59 | 60 | extension PKCanvas: PKToolPickerObserver { 61 | 62 | func toolPickerSelectedToolDidChange(_ toolPicker: PKToolPicker) { 63 | print("toolPickerSelectedToolDidChange") 64 | } 65 | 66 | func toolPickerIsRulerActiveDidChange(_ toolPicker: PKToolPicker) { 67 | print("toolPickerIsRulerActiveDidChange") 68 | } 69 | 70 | func toolPickerVisibilityDidChange(_ toolPicker: PKToolPicker) { 71 | print("toolPickerVisibilityDidChange") 72 | } 73 | 74 | func toolPickerFramesObscuredDidChange(_ toolPicker: PKToolPicker) { 75 | print("toolPickerFramesObscuredDidChange") 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /PencilKitExample/PencilKit View/PencilKitInterface.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PencilKitInterface.swift 3 | // PencilKitDemo 4 | // 5 | // Created by Yoel Lev on 27/08/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol PencilKitDelegate: class { 12 | func snapshot(from canvas: PKCanvas) -> UIImage 13 | } 14 | 15 | extension PencilKitDelegate { 16 | 17 | func snapshot(from canvas: PKCanvas) -> UIImage { 18 | //Take PencilKit Drawings snapshot 19 | return UIImage() 20 | } 21 | } 22 | 23 | protocol PencilKitInterface: NSObject { 24 | var pencilKitCanvas: PKCanvas { get set } 25 | func createPencilKitCanvas(frame: CGRect, delegate: PencilKitDelegate) -> PKCanvas 26 | func updateCanvasOrientation(with frame: CGRect) 27 | } 28 | 29 | extension PencilKitInterface { 30 | 31 | func createPencilKitCanvas(frame: CGRect, delegate: PencilKitDelegate) -> PKCanvas { 32 | pencilKitCanvas = PKCanvas(frame: frame) 33 | pencilKitCanvas.pencilKitDelegate = delegate 34 | return pencilKitCanvas 35 | } 36 | 37 | func updateCanvasOrientation(with frame: CGRect) { 38 | pencilKitCanvas.updateCanvasOrientation(with: frame) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PencilKitExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // PencilKitExample 4 | // 5 | // Created by Yoel Lev on 20/09/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /PencilKitExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PencilKitExampleTests/PencilKitExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PencilKitExampleTests.swift 3 | // PencilKitExampleTests 4 | // 5 | // Created by Yoel Lev on 20/09/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PencilKitExample 11 | 12 | class PencilKitExampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /PencilKitExampleUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PencilKitExampleUITests/PencilKitExampleUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PencilKitExampleUITests.swift 3 | // PencilKitExampleUITests 4 | // 5 | // Created by Yoel Lev on 20/09/2019. 6 | // Copyright © 2019 Yoel Lev. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class PencilKitExampleUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | } 25 | 26 | func testExample() { 27 | // UI tests must launch the application that they test. 28 | let app = XCUIApplication() 29 | app.launch() 30 | 31 | // Use recording to get started writing UI tests. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | func testLaunchPerformance() { 36 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 37 | // This measures how long it takes to launch your application. 38 | measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { 39 | XCUIApplication().launch() 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pencil Kit Example 2 | Implemetation of PencilKit using protocol oriented programming 3 | 4 | 5 | # Resources 6 | This repository contains an Xcode example project for the blog post at [PencilKit. Protocol Oriented Programming. Swift.](https://medium.com/p/af4e8f285476/edit). 7 | 8 | ![Xcode 11.0+](https://img.shields.io/badge/Xcode-11.0%2B-blue.svg) 9 | ![iOS 13.0+](https://img.shields.io/badge/iOS-13.0%2B-blue.svg) 10 | ![Swift 5.1+](https://img.shields.io/badge/Swift-5.1%2B-orange.svg) 11 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 12 | 13 | 14 | ![](pencilKitOverview.gif) 15 | -------------------------------------------------------------------------------- /pencilKitOverview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoelL/PencilKitExample/73d47408c62b4b449beb298386a01eb242432e4d/pencilKitOverview.gif --------------------------------------------------------------------------------