├── PHPhotoPicker.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── felix.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── PHPhotoPicker ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── ContentView.swift ├── CustomPhotoPickerView.swift ├── Info.plist ├── PHPhotoPickerApp.swift └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json └── README.md /PHPhotoPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DCAA519E253B0D26009B778B /* PHPhotoPickerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAA519D253B0D26009B778B /* PHPhotoPickerApp.swift */; }; 11 | DCAA51A0253B0D26009B778B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAA519F253B0D26009B778B /* ContentView.swift */; }; 12 | DCAA51A2253B0D28009B778B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCAA51A1253B0D28009B778B /* Assets.xcassets */; }; 13 | DCAA51A5253B0D28009B778B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCAA51A4253B0D28009B778B /* Preview Assets.xcassets */; }; 14 | DCAA51AE253B0E5C009B778B /* CustomPhotoPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAA51AD253B0E5C009B778B /* CustomPhotoPickerView.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | DCAA519A253B0D26009B778B /* PHPhotoPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PHPhotoPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | DCAA519D253B0D26009B778B /* PHPhotoPickerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHPhotoPickerApp.swift; sourceTree = ""; }; 20 | DCAA519F253B0D26009B778B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | DCAA51A1253B0D28009B778B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | DCAA51A4253B0D28009B778B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | DCAA51A6253B0D28009B778B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | DCAA51AD253B0E5C009B778B /* CustomPhotoPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPhotoPickerView.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | DCAA5197253B0D26009B778B /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | DCAA5191253B0D26009B778B = { 39 | isa = PBXGroup; 40 | children = ( 41 | DCAA519C253B0D26009B778B /* PHPhotoPicker */, 42 | DCAA519B253B0D26009B778B /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | DCAA519B253B0D26009B778B /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | DCAA519A253B0D26009B778B /* PHPhotoPicker.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | DCAA519C253B0D26009B778B /* PHPhotoPicker */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | DCAA519D253B0D26009B778B /* PHPhotoPickerApp.swift */, 58 | DCAA519F253B0D26009B778B /* ContentView.swift */, 59 | DCAA51A1253B0D28009B778B /* Assets.xcassets */, 60 | DCAA51A6253B0D28009B778B /* Info.plist */, 61 | DCAA51A3253B0D28009B778B /* Preview Content */, 62 | DCAA51AD253B0E5C009B778B /* CustomPhotoPickerView.swift */, 63 | ); 64 | path = PHPhotoPicker; 65 | sourceTree = ""; 66 | }; 67 | DCAA51A3253B0D28009B778B /* Preview Content */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | DCAA51A4253B0D28009B778B /* Preview Assets.xcassets */, 71 | ); 72 | path = "Preview Content"; 73 | sourceTree = ""; 74 | }; 75 | /* End PBXGroup section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | DCAA5199253B0D26009B778B /* PHPhotoPicker */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = DCAA51A9253B0D28009B778B /* Build configuration list for PBXNativeTarget "PHPhotoPicker" */; 81 | buildPhases = ( 82 | DCAA5196253B0D26009B778B /* Sources */, 83 | DCAA5197253B0D26009B778B /* Frameworks */, 84 | DCAA5198253B0D26009B778B /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = PHPhotoPicker; 91 | productName = PHPhotoPicker; 92 | productReference = DCAA519A253B0D26009B778B /* PHPhotoPicker.app */; 93 | productType = "com.apple.product-type.application"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | DCAA5192253B0D26009B778B /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | LastSwiftUpdateCheck = 1200; 102 | LastUpgradeCheck = 1200; 103 | TargetAttributes = { 104 | DCAA5199253B0D26009B778B = { 105 | CreatedOnToolsVersion = 12.0.1; 106 | }; 107 | }; 108 | }; 109 | buildConfigurationList = DCAA5195253B0D26009B778B /* Build configuration list for PBXProject "PHPhotoPicker" */; 110 | compatibilityVersion = "Xcode 9.3"; 111 | developmentRegion = en; 112 | hasScannedForEncodings = 0; 113 | knownRegions = ( 114 | en, 115 | Base, 116 | ); 117 | mainGroup = DCAA5191253B0D26009B778B; 118 | productRefGroup = DCAA519B253B0D26009B778B /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | DCAA5199253B0D26009B778B /* PHPhotoPicker */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | DCAA5198253B0D26009B778B /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | DCAA51A5253B0D28009B778B /* Preview Assets.xcassets in Resources */, 133 | DCAA51A2253B0D28009B778B /* Assets.xcassets in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | DCAA5196253B0D26009B778B /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | DCAA51A0253B0D26009B778B /* ContentView.swift in Sources */, 145 | DCAA51AE253B0E5C009B778B /* CustomPhotoPickerView.swift in Sources */, 146 | DCAA519E253B0D26009B778B /* PHPhotoPickerApp.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | DCAA51A7253B0D28009B778B /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 180 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 181 | CLANG_WARN_STRICT_PROTOTYPES = YES; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu11; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 205 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 206 | MTL_FAST_MATH = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | }; 212 | name = Debug; 213 | }; 214 | DCAA51A8253B0D28009B778B /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_ENABLE_OBJC_WEAK = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 241 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 242 | CLANG_WARN_STRICT_PROTOTYPES = YES; 243 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 244 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 245 | CLANG_WARN_UNREACHABLE_CODE = YES; 246 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu11; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | MTL_FAST_MATH = YES; 262 | SDKROOT = iphoneos; 263 | SWIFT_COMPILATION_MODE = wholemodule; 264 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 265 | VALIDATE_PRODUCT = YES; 266 | }; 267 | name = Release; 268 | }; 269 | DCAA51AA253B0D28009B778B /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 274 | CODE_SIGN_STYLE = Automatic; 275 | DEVELOPMENT_ASSET_PATHS = "\"PHPhotoPicker/Preview Content\""; 276 | DEVELOPMENT_TEAM = 9CZ464YT65; 277 | ENABLE_PREVIEWS = YES; 278 | INFOPLIST_FILE = PHPhotoPicker/Info.plist; 279 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 280 | LD_RUNPATH_SEARCH_PATHS = ( 281 | "$(inherited)", 282 | "@executable_path/Frameworks", 283 | ); 284 | PRODUCT_BUNDLE_IDENTIFIER = com.felixlarsen.PHPhotoPicker; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | SWIFT_VERSION = 5.0; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | }; 289 | name = Debug; 290 | }; 291 | DCAA51AB253B0D28009B778B /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 296 | CODE_SIGN_STYLE = Automatic; 297 | DEVELOPMENT_ASSET_PATHS = "\"PHPhotoPicker/Preview Content\""; 298 | DEVELOPMENT_TEAM = 9CZ464YT65; 299 | ENABLE_PREVIEWS = YES; 300 | INFOPLIST_FILE = PHPhotoPicker/Info.plist; 301 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 302 | LD_RUNPATH_SEARCH_PATHS = ( 303 | "$(inherited)", 304 | "@executable_path/Frameworks", 305 | ); 306 | PRODUCT_BUNDLE_IDENTIFIER = com.felixlarsen.PHPhotoPicker; 307 | PRODUCT_NAME = "$(TARGET_NAME)"; 308 | SWIFT_VERSION = 5.0; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | }; 311 | name = Release; 312 | }; 313 | /* End XCBuildConfiguration section */ 314 | 315 | /* Begin XCConfigurationList section */ 316 | DCAA5195253B0D26009B778B /* Build configuration list for PBXProject "PHPhotoPicker" */ = { 317 | isa = XCConfigurationList; 318 | buildConfigurations = ( 319 | DCAA51A7253B0D28009B778B /* Debug */, 320 | DCAA51A8253B0D28009B778B /* Release */, 321 | ); 322 | defaultConfigurationIsVisible = 0; 323 | defaultConfigurationName = Release; 324 | }; 325 | DCAA51A9253B0D28009B778B /* Build configuration list for PBXNativeTarget "PHPhotoPicker" */ = { 326 | isa = XCConfigurationList; 327 | buildConfigurations = ( 328 | DCAA51AA253B0D28009B778B /* Debug */, 329 | DCAA51AB253B0D28009B778B /* Release */, 330 | ); 331 | defaultConfigurationIsVisible = 0; 332 | defaultConfigurationName = Release; 333 | }; 334 | /* End XCConfigurationList section */ 335 | }; 336 | rootObject = DCAA5192253B0D26009B778B /* Project object */; 337 | } 338 | -------------------------------------------------------------------------------- /PHPhotoPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PHPhotoPicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PHPhotoPicker.xcodeproj/xcuserdata/felix.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PHPhotoPicker.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PHPhotoPicker/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 | -------------------------------------------------------------------------------- /PHPhotoPicker/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 | -------------------------------------------------------------------------------- /PHPhotoPicker/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /PHPhotoPicker/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // PHPhotoPicker 4 | // 5 | // Created by Felix Houghton-Larsen on 17.10.20. 6 | // 7 | 8 | import SwiftUI 9 | import MapKit 10 | 11 | struct ContentView: View { 12 | static let dateFormat: DateFormatter = { 13 | let formatter = DateFormatter() 14 | formatter.dateStyle = .medium 15 | return formatter 16 | }() 17 | 18 | @State var showSheet = false 19 | @State var selectedImage: UIImage? 20 | @State var date: Date? 21 | @State var region = MKCoordinateRegion( 22 | center: CLLocationCoordinate2D( 23 | latitude: 20.0, 24 | longitude: 20.0), 25 | latitudinalMeters: .init(10000), 26 | longitudinalMeters: .init(10000)) 27 | 28 | var body: some View { 29 | let regionWithOffset = Binding( 30 | get: { 31 | let offsetCenter = CLLocationCoordinate2D(latitude: region.center.latitude + region.span.latitudeDelta * 0.30, longitude: region.center.longitude) 32 | return MKCoordinateRegion( 33 | center: offsetCenter, 34 | span: region.span) 35 | }, 36 | set: { 37 | $0 38 | } 39 | ) 40 | return ZStack { 41 | Map(coordinateRegion: regionWithOffset, 42 | interactionModes: MapInteractionModes.all, 43 | showsUserLocation: false, 44 | annotationItems: [region.center]) { 45 | l in 46 | MapPin(coordinate: l) 47 | } 48 | VStack { 49 | if let date = date { 50 | Text("\(date, formatter: Self.dateFormat)") 51 | .padding(8) 52 | .background(LinearGradient(gradient: Gradient(colors: [Color.black.opacity(0.9), Color.black.opacity(0.7)]), startPoint: .top, endPoint: .bottom)) 53 | .cornerRadius(10.0) 54 | .foregroundColor(.white) 55 | .padding(8) 56 | 57 | } 58 | if let image = selectedImage { 59 | Image(uiImage: image) 60 | .resizable() 61 | .aspectRatio(contentMode: .fit) 62 | .clipShape(Circle()) 63 | .overlay(Circle().stroke(Color.white, lineWidth: 4)) 64 | .shadow(radius: 10) 65 | .padding(8) 66 | } 67 | Spacer() 68 | Button(action: { 69 | showSheet.toggle() 70 | }) { 71 | Image(systemName: "photo") 72 | 73 | } 74 | .frame(width: 50, height: 50) 75 | .background(Color.white) 76 | .clipShape(Circle()) 77 | .shadow(radius: 10) 78 | .padding() 79 | } 80 | 81 | 82 | }.sheet(isPresented: $showSheet) { 83 | CustomPhotoPickerView(selectedImage: $selectedImage, date: $date, location: $region.center) 84 | } 85 | } 86 | } 87 | 88 | struct ContentView_Previews: PreviewProvider { 89 | 90 | static var previews: some View { 91 | ContentView(showSheet: false, selectedImage: image(), date: Date(), region: MKCoordinateRegion( 92 | center: CLLocationCoordinate2D( 93 | latitude: 20.0, 94 | longitude: 20.0), 95 | latitudinalMeters: .init(10000), 96 | longitudinalMeters: .init(10000))) 97 | } 98 | static func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { 99 | return UIGraphicsImageRenderer(size: size).image { rendererContext in 100 | UIColor.orange.setFill() 101 | rendererContext.fill(CGRect(origin: .zero, size: size)) 102 | } 103 | } 104 | } 105 | 106 | extension CLLocationCoordinate2D: Identifiable, Hashable, Equatable { 107 | public var id: Int { 108 | return hashValue 109 | } 110 | 111 | public func hash(into hasher: inout Hasher) { 112 | hasher.combine(latitude) 113 | hasher.combine(longitude) 114 | } 115 | 116 | public static func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool { 117 | return lhs.longitude == rhs.longitude && lhs.latitude == rhs.latitude 118 | } 119 | 120 | public static func <(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool { 121 | return lhs.longitude < rhs.longitude 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /PHPhotoPicker/CustomPhotoPickerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomPhotoPicker.swift 3 | // PHPhotoPicker 4 | // 5 | // Created by Felix Houghton-Larsen on 17.10.20. 6 | // 7 | 8 | import SwiftUI 9 | import PhotosUI 10 | 11 | struct CustomPhotoPickerView: UIViewControllerRepresentable { 12 | 13 | @Binding var selectedImage: UIImage? 14 | @Binding var date: Date? 15 | @Binding var location: CLLocationCoordinate2D 16 | 17 | @Environment(\.presentationMode) var presentationMode 18 | 19 | func makeUIViewController(context: Context) -> PHPickerViewController { 20 | var config = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) 21 | config.filter = .images 22 | config.selectionLimit = 1 23 | let controller = PHPickerViewController(configuration: config) 24 | controller.delegate = context.coordinator 25 | return controller 26 | } 27 | 28 | func makeCoordinator() -> CustomPhotoPickerView.Coordinator { 29 | return Coordinator(self) 30 | } 31 | 32 | 33 | func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { 34 | } 35 | 36 | class Coordinator: PHPickerViewControllerDelegate { 37 | func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { 38 | parent.presentationMode.wrappedValue.dismiss() 39 | guard !results.isEmpty else { 40 | return 41 | } 42 | 43 | let imageResult = results[0] 44 | 45 | if let assetId = imageResult.assetIdentifier { 46 | let assetResults = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil) 47 | DispatchQueue.main.async { 48 | self.parent.date = assetResults.firstObject?.creationDate 49 | if let coordinate = assetResults.firstObject?.location?.coordinate { 50 | self.parent.location = coordinate 51 | } 52 | } 53 | } 54 | if imageResult.itemProvider.canLoadObject(ofClass: UIImage.self) { 55 | imageResult.itemProvider.loadObject(ofClass: UIImage.self) { (selectedImage, error) in 56 | if let error = error { 57 | print(error.localizedDescription) 58 | } else { 59 | DispatchQueue.main.async { 60 | self.parent.selectedImage = selectedImage as? UIImage 61 | } 62 | } 63 | } 64 | } 65 | } 66 | 67 | private let parent: CustomPhotoPickerView 68 | init(_ parent: CustomPhotoPickerView) { 69 | self.parent = parent 70 | } 71 | } 72 | } 73 | 74 | struct CustomPhotoPicker_Previews: PreviewProvider { 75 | static var previews: some View { 76 | CustomPhotoPickerView(selectedImage: Binding.constant(nil), date: Binding.constant(nil), location: Binding.constant(CLLocationCoordinate2D(latitude: 2.0, longitude: 2.0))) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /PHPhotoPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPhotoLibraryUsageDescription 6 | Need date and location 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIApplicationSceneManifest 26 | 27 | UIApplicationSupportsMultipleScenes 28 | 29 | 30 | UIApplicationSupportsIndirectInputEvents 31 | 32 | UILaunchScreen 33 | 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /PHPhotoPicker/PHPhotoPickerApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PHPhotoPickerApp.swift 3 | // PHPhotoPicker 4 | // 5 | // Created by Felix Houghton-Larsen on 17.10.20. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct PHPhotoPickerApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PHPhotoPicker/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHPicker Example 2 | How to get metadata from photo with PHPicker using SwiftUI. 3 | 4 | The corresponding blog post can be found [here](https://www.felixlarsen.com/blog/photo-metadata-phpickerview). 5 |

6 | 7 | 8 |

9 | --------------------------------------------------------------------------------