Skip to content

Commit b990ab4

Browse files
authored
Merge pull request #16 from arduino/xcode-12
Optimize for iOS 14 and Xcode 12
2 parents eb89772 + c1f7704 commit b990ab4

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

ScienceJournal.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@
31383138
isa = PBXProject;
31393139
attributes = {
31403140
LastSwiftUpdateCheck = 0820;
3141-
LastUpgradeCheck = 0940;
3141+
LastUpgradeCheck = 1200;
31423142
ORGANIZATIONNAME = Arduino;
31433143
TargetAttributes = {
31443144
68EBA6D91E20421E0089FF7F = {
@@ -3168,10 +3168,9 @@
31683168
};
31693169
buildConfigurationList = 68EBA6D51E20421E0089FF7F /* Build configuration list for PBXProject "ScienceJournal" */;
31703170
compatibilityVersion = "Xcode 3.2";
3171-
developmentRegion = English;
3171+
developmentRegion = en;
31723172
hasScannedForEncodings = 0;
31733173
knownRegions = (
3174-
English,
31753174
ar,
31763175
bg,
31773176
bs,
@@ -3249,6 +3248,7 @@
32493248
zh_CN,
32503249
zh_HK,
32513250
zh_TW,
3251+
Base,
32523252
);
32533253
mainGroup = 68EBA6D11E20421E0089FF7F;
32543254
productRefGroup = 68EBA6DB1E20421E0089FF7F /* Products */;
@@ -4151,6 +4151,7 @@
41514151
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
41524152
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
41534153
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
4154+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
41544155
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
41554156
CLANG_WARN_STRICT_PROTOTYPES = YES;
41564157
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -4319,6 +4320,7 @@
43194320
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
43204321
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
43214322
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
4323+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
43224324
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
43234325
CLANG_WARN_STRICT_PROTOTYPES = YES;
43244326
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -4506,6 +4508,7 @@
45064508
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
45074509
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
45084510
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
4511+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
45094512
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
45104513
CLANG_WARN_STRICT_PROTOTYPES = YES;
45114514
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -4565,6 +4568,7 @@
45654568
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
45664569
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
45674570
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
4571+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
45684572
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
45694573
CLANG_WARN_STRICT_PROTOTYPES = YES;
45704574
CLANG_WARN_SUSPICIOUS_MOVE = YES;

ScienceJournal.xcodeproj/xcshareddata/xcschemes/ScienceJournal.xcscheme

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1200"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -27,6 +27,15 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "68EBA6D91E20421E0089FF7F"
34+
BuildableName = "ScienceJournal.app"
35+
BlueprintName = "ScienceJournal"
36+
ReferencedContainer = "container:ScienceJournal.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3039
<Testables>
3140
<TestableReference
3241
skipped = "NO">
@@ -49,17 +58,6 @@
4958
</BuildableReference>
5059
</TestableReference>
5160
</Testables>
52-
<MacroExpansion>
53-
<BuildableReference
54-
BuildableIdentifier = "primary"
55-
BlueprintIdentifier = "68EBA6D91E20421E0089FF7F"
56-
BuildableName = "ScienceJournal.app"
57-
BlueprintName = "ScienceJournal"
58-
ReferencedContainer = "container:ScienceJournal.xcodeproj">
59-
</BuildableReference>
60-
</MacroExpansion>
61-
<AdditionalOptions>
62-
</AdditionalOptions>
6361
</TestAction>
6462
<LaunchAction
6563
buildConfiguration = "Debug"
@@ -81,8 +79,6 @@
8179
ReferencedContainer = "container:ScienceJournal.xcodeproj">
8280
</BuildableReference>
8381
</BuildableProductRunnable>
84-
<AdditionalOptions>
85-
</AdditionalOptions>
8682
</LaunchAction>
8783
<ProfileAction
8884
buildConfiguration = "Debug"

ScienceJournal/UI/PhotoLibraryDataSource.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,31 @@ class PhotoLibraryDataSource: NSObject, PHPhotoLibraryChangeObserver {
9090

9191
/// The permissions state of the capturer.
9292
var isPhotoLibraryPermissionGranted: Bool {
93-
let authStatus = PHPhotoLibrary.authorizationStatus()
93+
let authStatus: PHAuthorizationStatus
94+
if #available(iOS 14, *) {
95+
authStatus = PHPhotoLibrary.authorizationStatus(for: .readWrite)
96+
} else {
97+
authStatus = PHPhotoLibrary.authorizationStatus()
98+
}
9499
switch authStatus {
95100
case .denied, .restricted: return false
96-
case .authorized: return true
101+
case .authorized, .limited: return true
97102
case .notDetermined:
98-
// Prompt user for the permission to use the camera.
99-
PHPhotoLibrary.requestAuthorization({ (status) in
103+
let handler: (PHAuthorizationStatus) -> Void = { status in
100104
DispatchQueue.main.sync {
101105
let granted = status == .authorized
102106
self.delegate?.photoLibraryDataSourcePermissionsDidChange(accessGranted: granted)
103107
}
104-
})
108+
}
109+
110+
// Prompt user for the permission to use the camera.
111+
if #available(iOS 14, *) {
112+
PHPhotoLibrary.requestAuthorization(for: .readWrite, handler: handler)
113+
} else {
114+
PHPhotoLibrary.requestAuthorization(handler)
115+
}
105116
return false
117+
@unknown default: return false
106118
}
107119
}
108120

0 commit comments

Comments
 (0)