├── .gitignore ├── Example ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Example │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── test-image.imageset │ │ │ ├── Contents.json │ │ │ └── test-image.jpg │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ ├── SwiftUIExampleView.swift │ └── UIKitExampleViewController.swift └── PrivateImageExample.png ├── LICENSE ├── Package.swift ├── README.md └── Sources └── PrivateImage ├── CGImage+Extensions.swift ├── PrivateImageView.swift └── UIPrivateImageView.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1CE36C6C2783394B00B5B4CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CE36C6B2783394B00B5B4CF /* AppDelegate.swift */; }; 11 | 1CE36C6E2783394B00B5B4CF /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CE36C6D2783394B00B5B4CF /* SceneDelegate.swift */; }; 12 | 1CE36C702783394B00B5B4CF /* UIKitExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CE36C6F2783394B00B5B4CF /* UIKitExampleViewController.swift */; }; 13 | 1CE36C752783394C00B5B4CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1CE36C742783394C00B5B4CF /* Assets.xcassets */; }; 14 | 1CE36C782783394C00B5B4CF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1CE36C762783394C00B5B4CF /* LaunchScreen.storyboard */; }; 15 | 1CE36C8227833A7B00B5B4CF /* PrivateImage in Frameworks */ = {isa = PBXBuildFile; productRef = 1CE36C8127833A7B00B5B4CF /* PrivateImage */; }; 16 | 1CE36C842783406300B5B4CF /* SwiftUIExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CE36C832783406300B5B4CF /* SwiftUIExampleView.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 1CE36C682783394B00B5B4CF /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 1CE36C6B2783394B00B5B4CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 1CE36C6D2783394B00B5B4CF /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | 1CE36C6F2783394B00B5B4CF /* UIKitExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitExampleViewController.swift; sourceTree = ""; }; 24 | 1CE36C742783394C00B5B4CF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 1CE36C772783394C00B5B4CF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | 1CE36C792783394C00B5B4CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 1CE36C7F27833A1500B5B4CF /* PrivateImage */ = {isa = PBXFileReference; lastKnownFileType = folder; name = PrivateImage; path = ../..; sourceTree = ""; }; 28 | 1CE36C832783406300B5B4CF /* SwiftUIExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIExampleView.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 1CE36C652783394B00B5B4CF /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | 1CE36C8227833A7B00B5B4CF /* PrivateImage in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 1CE36C5F2783394B00B5B4CF = { 44 | isa = PBXGroup; 45 | children = ( 46 | 1CE36C6A2783394B00B5B4CF /* Example */, 47 | 1CE36C692783394B00B5B4CF /* Products */, 48 | 1CE36C8027833A7B00B5B4CF /* Frameworks */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | 1CE36C692783394B00B5B4CF /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 1CE36C682783394B00B5B4CF /* Example.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | 1CE36C6A2783394B00B5B4CF /* Example */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 1CE36C6B2783394B00B5B4CF /* AppDelegate.swift */, 64 | 1CE36C6D2783394B00B5B4CF /* SceneDelegate.swift */, 65 | 1CE36C6F2783394B00B5B4CF /* UIKitExampleViewController.swift */, 66 | 1CE36C832783406300B5B4CF /* SwiftUIExampleView.swift */, 67 | 1CE36C742783394C00B5B4CF /* Assets.xcassets */, 68 | 1CE36C762783394C00B5B4CF /* LaunchScreen.storyboard */, 69 | 1CE36C7F27833A1500B5B4CF /* PrivateImage */, 70 | 1CE36C792783394C00B5B4CF /* Info.plist */, 71 | ); 72 | path = Example; 73 | sourceTree = ""; 74 | }; 75 | 1CE36C8027833A7B00B5B4CF /* Frameworks */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 1CE36C672783394B00B5B4CF /* Example */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 1CE36C7C2783394C00B5B4CF /* Build configuration list for PBXNativeTarget "Example" */; 88 | buildPhases = ( 89 | 1CE36C642783394B00B5B4CF /* Sources */, 90 | 1CE36C652783394B00B5B4CF /* Frameworks */, 91 | 1CE36C662783394B00B5B4CF /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = Example; 98 | packageProductDependencies = ( 99 | 1CE36C8127833A7B00B5B4CF /* PrivateImage */, 100 | ); 101 | productName = Example; 102 | productReference = 1CE36C682783394B00B5B4CF /* Example.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | 1CE36C602783394B00B5B4CF /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | BuildIndependentTargetsInParallel = 1; 112 | LastSwiftUpdateCheck = 1310; 113 | LastUpgradeCheck = 1310; 114 | TargetAttributes = { 115 | 1CE36C672783394B00B5B4CF = { 116 | CreatedOnToolsVersion = 13.1; 117 | }; 118 | }; 119 | }; 120 | buildConfigurationList = 1CE36C632783394B00B5B4CF /* Build configuration list for PBXProject "Example" */; 121 | compatibilityVersion = "Xcode 13.0"; 122 | developmentRegion = en; 123 | hasScannedForEncodings = 0; 124 | knownRegions = ( 125 | en, 126 | Base, 127 | ); 128 | mainGroup = 1CE36C5F2783394B00B5B4CF; 129 | productRefGroup = 1CE36C692783394B00B5B4CF /* Products */; 130 | projectDirPath = ""; 131 | projectRoot = ""; 132 | targets = ( 133 | 1CE36C672783394B00B5B4CF /* Example */, 134 | ); 135 | }; 136 | /* End PBXProject section */ 137 | 138 | /* Begin PBXResourcesBuildPhase section */ 139 | 1CE36C662783394B00B5B4CF /* Resources */ = { 140 | isa = PBXResourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 1CE36C782783394C00B5B4CF /* LaunchScreen.storyboard in Resources */, 144 | 1CE36C752783394C00B5B4CF /* Assets.xcassets in Resources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXResourcesBuildPhase section */ 149 | 150 | /* Begin PBXSourcesBuildPhase section */ 151 | 1CE36C642783394B00B5B4CF /* Sources */ = { 152 | isa = PBXSourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | 1CE36C702783394B00B5B4CF /* UIKitExampleViewController.swift in Sources */, 156 | 1CE36C842783406300B5B4CF /* SwiftUIExampleView.swift in Sources */, 157 | 1CE36C6C2783394B00B5B4CF /* AppDelegate.swift in Sources */, 158 | 1CE36C6E2783394B00B5B4CF /* SceneDelegate.swift in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin PBXVariantGroup section */ 165 | 1CE36C762783394C00B5B4CF /* LaunchScreen.storyboard */ = { 166 | isa = PBXVariantGroup; 167 | children = ( 168 | 1CE36C772783394C00B5B4CF /* Base */, 169 | ); 170 | name = LaunchScreen.storyboard; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXVariantGroup section */ 174 | 175 | /* Begin XCBuildConfiguration section */ 176 | 1CE36C7A2783394C00B5B4CF /* Debug */ = { 177 | isa = XCBuildConfiguration; 178 | buildSettings = { 179 | ALWAYS_SEARCH_USER_PATHS = NO; 180 | CLANG_ANALYZER_NONNULL = YES; 181 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 182 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 183 | CLANG_CXX_LIBRARY = "libc++"; 184 | CLANG_ENABLE_MODULES = YES; 185 | CLANG_ENABLE_OBJC_ARC = YES; 186 | CLANG_ENABLE_OBJC_WEAK = YES; 187 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 188 | CLANG_WARN_BOOL_CONVERSION = YES; 189 | CLANG_WARN_COMMA = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 192 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 193 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 200 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 203 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 204 | CLANG_WARN_STRICT_PROTOTYPES = YES; 205 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 206 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 207 | CLANG_WARN_UNREACHABLE_CODE = YES; 208 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu11; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 228 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 229 | MTL_FAST_MATH = YES; 230 | ONLY_ACTIVE_ARCH = YES; 231 | SDKROOT = iphoneos; 232 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 233 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 234 | }; 235 | name = Debug; 236 | }; 237 | 1CE36C7B2783394C00B5B4CF /* Release */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_ANALYZER_NONNULL = YES; 242 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_ENABLE_OBJC_WEAK = YES; 248 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_COMMA = YES; 251 | CLANG_WARN_CONSTANT_CONVERSION = YES; 252 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INFINITE_RECURSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 260 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 261 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 263 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 264 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 265 | CLANG_WARN_STRICT_PROTOTYPES = YES; 266 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 267 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | COPY_PHASE_STRIP = NO; 271 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 272 | ENABLE_NS_ASSERTIONS = NO; 273 | ENABLE_STRICT_OBJC_MSGSEND = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu11; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 283 | MTL_ENABLE_DEBUG_INFO = NO; 284 | MTL_FAST_MATH = YES; 285 | SDKROOT = iphoneos; 286 | SWIFT_COMPILATION_MODE = wholemodule; 287 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 288 | VALIDATE_PRODUCT = YES; 289 | }; 290 | name = Release; 291 | }; 292 | 1CE36C7D2783394C00B5B4CF /* Debug */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 296 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 297 | CODE_SIGN_STYLE = Automatic; 298 | CURRENT_PROJECT_VERSION = 1; 299 | DEVELOPMENT_TEAM = U9WLLAC7UL; 300 | GENERATE_INFOPLIST_FILE = YES; 301 | INFOPLIST_FILE = Example/Info.plist; 302 | INFOPLIST_KEY_CFBundleDisplayName = PrivateImageExample; 303 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 304 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 305 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 306 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 307 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 308 | LD_RUNPATH_SEARCH_PATHS = ( 309 | "$(inherited)", 310 | "@executable_path/Frameworks", 311 | ); 312 | MARKETING_VERSION = 1.0.0; 313 | PRODUCT_BUNDLE_IDENTIFIER = com.shvul.PrivateImageExample; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | SWIFT_EMIT_LOC_STRINGS = YES; 316 | SWIFT_VERSION = 5.0; 317 | TARGETED_DEVICE_FAMILY = "1,2"; 318 | }; 319 | name = Debug; 320 | }; 321 | 1CE36C7E2783394C00B5B4CF /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 325 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 326 | CODE_SIGN_STYLE = Automatic; 327 | CURRENT_PROJECT_VERSION = 1; 328 | DEVELOPMENT_TEAM = U9WLLAC7UL; 329 | GENERATE_INFOPLIST_FILE = YES; 330 | INFOPLIST_FILE = Example/Info.plist; 331 | INFOPLIST_KEY_CFBundleDisplayName = PrivateImageExample; 332 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 333 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 334 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 335 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 336 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 337 | LD_RUNPATH_SEARCH_PATHS = ( 338 | "$(inherited)", 339 | "@executable_path/Frameworks", 340 | ); 341 | MARKETING_VERSION = 1.0.0; 342 | PRODUCT_BUNDLE_IDENTIFIER = com.shvul.PrivateImageExample; 343 | PRODUCT_NAME = "$(TARGET_NAME)"; 344 | SWIFT_EMIT_LOC_STRINGS = YES; 345 | SWIFT_VERSION = 5.0; 346 | TARGETED_DEVICE_FAMILY = "1,2"; 347 | }; 348 | name = Release; 349 | }; 350 | /* End XCBuildConfiguration section */ 351 | 352 | /* Begin XCConfigurationList section */ 353 | 1CE36C632783394B00B5B4CF /* Build configuration list for PBXProject "Example" */ = { 354 | isa = XCConfigurationList; 355 | buildConfigurations = ( 356 | 1CE36C7A2783394C00B5B4CF /* Debug */, 357 | 1CE36C7B2783394C00B5B4CF /* Release */, 358 | ); 359 | defaultConfigurationIsVisible = 0; 360 | defaultConfigurationName = Release; 361 | }; 362 | 1CE36C7C2783394C00B5B4CF /* Build configuration list for PBXNativeTarget "Example" */ = { 363 | isa = XCConfigurationList; 364 | buildConfigurations = ( 365 | 1CE36C7D2783394C00B5B4CF /* Debug */, 366 | 1CE36C7E2783394C00B5B4CF /* Release */, 367 | ); 368 | defaultConfigurationIsVisible = 0; 369 | defaultConfigurationName = Release; 370 | }; 371 | /* End XCConfigurationList section */ 372 | 373 | /* Begin XCSwiftPackageProductDependency section */ 374 | 1CE36C8127833A7B00B5B4CF /* PrivateImage */ = { 375 | isa = XCSwiftPackageProductDependency; 376 | productName = PrivateImage; 377 | }; 378 | /* End XCSwiftPackageProductDependency section */ 379 | }; 380 | rootObject = 1CE36C602783394B00B5B4CF /* Project object */; 381 | } 382 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @main 4 | final class AppDelegate: UIResponder, UIApplicationDelegate { 5 | 6 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 7 | return true 8 | } 9 | 10 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 11 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/test-image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "test-image.jpg", 5 | "idiom" : "universal" 6 | } 7 | ], 8 | "info" : { 9 | "author" : "xcode", 10 | "version" : 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/test-image.imageset/test-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shvul/PrivateImage/ea96d9045498ba5eb0f37d7ddf693b7f39b6b97a/Example/Example/Assets.xcassets/test-image.imageset/test-image.jpg -------------------------------------------------------------------------------- /Example/Example/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 | 33 | 34 | -------------------------------------------------------------------------------- /Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Example/Example/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import SwiftUI 3 | 4 | final class SceneDelegate: UIResponder, UIWindowSceneDelegate { 5 | 6 | var window: UIWindow? 7 | 8 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 9 | guard let windowScene = scene as? UIWindowScene else { return } 10 | let window = UIWindow(windowScene: windowScene) 11 | 12 | window.rootViewController = UIKitExampleViewController() 13 | // window.rootViewController = UIHostingController(rootView: SwiftUIExampleView()) 14 | window.makeKeyAndVisible() 15 | self.window = window 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Example/Example/SwiftUIExampleView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import PrivateImage 3 | 4 | struct SwiftUIExampleView: View { 5 | 6 | @State var preventCapture = true 7 | 8 | var body: some View { 9 | VStack { 10 | Text("Example") 11 | PrivateImageView(image: UIImage(named: "test-image"), preventCapture: self.preventCapture) 12 | .imageContentMode(imageContentMode: .resizeAspectFill) 13 | Toggle("Prevent capture", isOn: self.$preventCapture) 14 | .padding(EdgeInsets(top: 0, leading: 10, bottom: 10, trailing: 10)) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/Example/UIKitExampleViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import PrivateImage 3 | 4 | final class UIKitExampleViewController: UIViewController { 5 | 6 | override func viewDidLoad() { 7 | super.viewDidLoad() 8 | let imageView = UIPrivateImageView(image: UIImage(named: "test-image")) 9 | imageView.translatesAutoresizingMaskIntoConstraints = false 10 | self.view.addSubview(imageView) 11 | 12 | NSLayoutConstraint.activate([ 13 | imageView.topAnchor.constraint(equalTo: self.view.topAnchor), 14 | imageView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor), 15 | imageView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), 16 | imageView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor) 17 | ]) 18 | 19 | imageView.imageContentMode = .resizeAspect 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Example/PrivateImageExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shvul/PrivateImage/ea96d9045498ba5eb0f37d7ddf693b7f39b6b97a/Example/PrivateImageExample.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Pavel Serdziukou 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 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "PrivateImage", 7 | platforms: [ 8 | .iOS(.v13), 9 | ], 10 | products: [ 11 | .library( 12 | name: "PrivateImage", 13 | targets: ["PrivateImage"]), 14 | ], 15 | targets: [ 16 | .target( 17 | name: "PrivateImage", 18 | dependencies: [] 19 | ), 20 | ] 21 | ) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SecretImage 2 | 3 | Image view with DRM protection for SwiftUI and UIKit. 4 | 5 | ## What? 6 | 7 | This view can't be captured via iOS screenshot feature or screen recording. 8 | 9 | 10 | 11 | ## Usage 12 | 13 | Create `PrivateImageView` for SwiftUI and `UIPrivateImageView` for UIKit and pass UIImage as input: 14 | 15 | ``` swift 16 | PrivateImageView(image: UIImage(named: "test-image")) 17 | ``` 18 | 19 | It will automatically prevent capture for this content image. 20 | 21 | For more examples check out [Example Project](/Example/) 22 | 23 | ## Installation 24 | 25 | Use SPM: 26 | 27 | ``` swift 28 | dependencies: [ 29 | .package(url: "https://github.com/shvul/PrivateImage.git", .upToNextMajor(from: "1.0.0")) 30 | ] 31 | ``` 32 | -------------------------------------------------------------------------------- /Sources/PrivateImage/CGImage+Extensions.swift: -------------------------------------------------------------------------------- 1 | import CoreGraphics 2 | import AVFoundation 3 | import CoreVideo 4 | 5 | extension CGImage { 6 | var sampleBuffer: CMSampleBuffer? { 7 | guard let pixelBuffer = self.pixelBuffer else { return nil } 8 | CVPixelBufferLockBaseAddress(pixelBuffer, .readOnly) 9 | defer { CVPixelBufferUnlockBaseAddress(pixelBuffer, .readOnly) } 10 | 11 | guard let formatDescription = try? CMVideoFormatDescription(imageBuffer: pixelBuffer) else { return nil } 12 | let timingInfo = CMSampleTimingInfo( 13 | duration: CMTime(value: 1, timescale: 30), 14 | presentationTimeStamp: .zero, 15 | decodeTimeStamp: .invalid 16 | ) 17 | return try? CMSampleBuffer( 18 | imageBuffer: pixelBuffer, 19 | formatDescription: formatDescription, 20 | sampleTiming: timingInfo 21 | ) 22 | } 23 | 24 | var pixelBuffer: CVPixelBuffer? { 25 | var pixelBuffer: CVPixelBuffer? = nil 26 | let ioSurfaceProperties = NSMutableDictionary() 27 | let options = NSMutableDictionary() 28 | options.setObject(ioSurfaceProperties, forKey: kCVPixelBufferIOSurfacePropertiesKey as NSString) 29 | 30 | 31 | CVPixelBufferCreate( 32 | kCFAllocatorDefault, 33 | Int(self.width), 34 | Int(self.height), 35 | kCVPixelFormatType_32ARGB, 36 | options as CFDictionary, 37 | &pixelBuffer 38 | ) 39 | guard let pixelBuffer = pixelBuffer else { 40 | return nil 41 | } 42 | CVPixelBufferLockBaseAddress(pixelBuffer, []) 43 | defer { CVPixelBufferUnlockBaseAddress(pixelBuffer, []) } 44 | 45 | let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer) 46 | guard let context = CGContext( 47 | data: baseAddress, 48 | width: Int(self.width), 49 | height: Int(self.height), 50 | bitsPerComponent: 8, 51 | bytesPerRow: CVPixelBufferGetBytesPerRow(pixelBuffer), 52 | space: CGColorSpaceCreateDeviceRGB(), 53 | bitmapInfo: CGBitmapInfo.byteOrder32Big.rawValue | CGImageAlphaInfo.premultipliedFirst.rawValue 54 | ) else { return nil } 55 | let frame = CGRect( 56 | origin: .zero, 57 | size: CGSize(width: self.width, height: self.height) 58 | ) 59 | context.clear(frame) 60 | context.draw(self, in: frame) 61 | 62 | return pixelBuffer 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Sources/PrivateImage/PrivateImageView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import AVFoundation 3 | 4 | public struct PrivateImageView: UIViewRepresentable { 5 | 6 | private var image: UIImage? 7 | private var imageContentMode: AVLayerVideoGravity 8 | private var preventCapture: Bool 9 | 10 | public init( 11 | image: UIImage? = nil, 12 | imageContentMode: AVLayerVideoGravity = .resizeAspect, 13 | preventCapture: Bool = true 14 | ) { 15 | self.image = image 16 | self.imageContentMode = imageContentMode 17 | self.preventCapture = preventCapture 18 | } 19 | 20 | public func makeUIView(context: Context) -> UIPrivateImageView { 21 | let view = UIPrivateImageView(image: self.image) 22 | view.preventsCapture = self.preventCapture 23 | view.imageContentMode = self.imageContentMode 24 | return view 25 | } 26 | 27 | public func updateUIView(_ uiView: UIPrivateImageView, context: Context) { 28 | uiView.imageContentMode = self.imageContentMode 29 | uiView.preventsCapture = self.preventCapture 30 | uiView.updateImage(to: self.image) 31 | } 32 | } 33 | 34 | public extension PrivateImageView { 35 | func imageContentMode(imageContentMode: AVLayerVideoGravity) -> PrivateImageView { 36 | var view = self 37 | view.imageContentMode = imageContentMode 38 | return view 39 | } 40 | 41 | func image(_ image: UIImage?) -> PrivateImageView { 42 | var view = self 43 | view.image = image 44 | return view 45 | } 46 | 47 | func preventCapture(_ prevent: Bool) -> PrivateImageView { 48 | var view = self 49 | view.preventCapture = prevent 50 | return view 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sources/PrivateImage/UIPrivateImageView.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import AVFoundation 3 | 4 | public class UIPrivateImageView: UIView { 5 | public init(image: UIImage? = nil) { 6 | super.init(frame: .zero) 7 | self.layer.preventsCapture = true 8 | image.flatMap(self.updateImage(to:)) 9 | } 10 | 11 | required init?(coder: NSCoder) { 12 | fatalError("init(coder:) has not been implemented") 13 | } 14 | 15 | override public class var layerClass: AnyClass { 16 | AVSampleBufferDisplayLayer.self 17 | } 18 | 19 | override public var layer: AVSampleBufferDisplayLayer { 20 | super.layer as! AVSampleBufferDisplayLayer 21 | } 22 | 23 | public var preventsCapture: Bool { 24 | get { 25 | self.layer.preventsCapture 26 | } 27 | set { 28 | self.layer.preventsCapture = newValue 29 | } 30 | } 31 | 32 | public var imageContentMode: AVLayerVideoGravity { 33 | get { 34 | self.layer.videoGravity 35 | } 36 | set { 37 | self.layer.videoGravity = newValue 38 | } 39 | } 40 | 41 | public func updateImage(to image: UIImage?) { 42 | self.layer.flushAndRemoveImage() 43 | guard let sampleBuffer = image?.cgImage?.sampleBuffer else { return } 44 | self.layer.enqueue(sampleBuffer) 45 | } 46 | } 47 | --------------------------------------------------------------------------------