├── .github
└── workflows
│ ├── build.yml
│ └── pages.yml
├── .gitignore
├── .swiftpm
└── xcode
│ └── package.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── Example
├── PermissionDirectorExample.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── PermissionDirectorExample
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── Contents.json
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
├── LICENSE
├── Package.swift
├── PermissionDirector iOS
├── Info.plist
└── PermissionDirector_iOS.h
├── PermissionDirector.podspec
├── PermissionDirector.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcshareddata
│ └── xcschemes
│ ├── PermissionDirector iOS.xcscheme
│ └── PermissionDirector.xcscheme
├── PermissionDirector
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── Contents.json
└── Info.plist
├── README.md
├── Sources
├── PermissionAlert.swift
├── PermissionDirector.swift
├── PermissionProtocol.swift
└── Permissions.swift
├── Tests
├── LinuxMain.swift
└── PermissionDirectorTests
│ ├── PermissionDirectorTests.swift
│ └── XCTestManifests.swift
├── logo.jpg
└── shortcut.gif
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 |
9 | jobs:
10 | build:
11 | name: Build
12 | runs-on: macos-latest
13 |
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v3
17 | - name: Build
18 | run: |
19 | cd Example
20 | xcodebuild -project PermissionDirectorExample.xcodeproj -scheme PermissionDirectorExample -derivedDataPath build -configuration Debug clean build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" CODE_SIGN_IDENTITY="" CODE_SIGN_ENTITLEMENTS=""
21 |
--------------------------------------------------------------------------------
/.github/workflows/pages.yml:
--------------------------------------------------------------------------------
1 | # Sample workflow for building and deploying a Jekyll site to GitHub Pages
2 | name: Deploy Jekyll with GitHub Pages dependencies preinstalled
3 |
4 | on:
5 | # Runs on pushes targeting the default branch
6 | push:
7 | branches: ["master"]
8 |
9 | # Allows you to run this workflow manually from the Actions tab
10 | workflow_dispatch:
11 |
12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13 | permissions:
14 | contents: read
15 | pages: write
16 | id-token: write
17 |
18 | # Allow one concurrent deployment
19 | concurrency:
20 | group: "pages"
21 | cancel-in-progress: true
22 |
23 | jobs:
24 | # Build job
25 | build:
26 | runs-on: ubuntu-latest
27 | steps:
28 | - name: Checkout
29 | uses: actions/checkout@v3
30 | - name: Setup Pages
31 | uses: actions/configure-pages@v2
32 | - name: Build with Jekyll
33 | uses: actions/jekyll-build-pages@v1
34 | with:
35 | source: ./
36 | destination: ./_site
37 | - name: Upload artifact
38 | uses: actions/upload-pages-artifact@v1
39 |
40 | # Deployment job
41 | deploy:
42 | environment:
43 | name: github-pages
44 | url: ${{ steps.deployment.outputs.page_url }}
45 | runs-on: ubuntu-latest
46 | needs: build
47 | steps:
48 | - name: Deploy to GitHub Pages
49 | id: deployment
50 | uses: actions/deploy-pages@v1
51 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | # Package.resolved
41 | .build/
42 |
43 | # CocoaPods
44 | #
45 | # We recommend against adding the Pods directory to your .gitignore. However
46 | # you should judge for yourself, the pros and cons are mentioned at:
47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
48 | #
49 | # Pods/
50 |
51 | # Carthage
52 | #
53 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
54 | # Carthage/Checkouts
55 |
56 | Carthage/Build
57 |
58 | # fastlane
59 | #
60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
61 | # screenshots whenever they are needed.
62 | # For more information about the recommended setup visit:
63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
64 |
65 | fastlane/report.xml
66 | fastlane/Preview.html
67 | fastlane/screenshots/**/*.png
68 | fastlane/test_output
69 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 708BBC34224DFB8C00166CC2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC33224DFB8C00166CC2 /* AppDelegate.swift */; };
11 | 708BBC36224DFB8C00166CC2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC35224DFB8C00166CC2 /* ViewController.swift */; };
12 | 708BBC39224DFB8C00166CC2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 708BBC37224DFB8C00166CC2 /* Main.storyboard */; };
13 | 708BBC3B224DFB8D00166CC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 708BBC3A224DFB8D00166CC2 /* Assets.xcassets */; };
14 | 708BBC3E224DFB8D00166CC2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 708BBC3C224DFB8D00166CC2 /* LaunchScreen.storyboard */; };
15 | 708BBC5F224DFD9900166CC2 /* PermissionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC5B224DFD9900166CC2 /* PermissionProtocol.swift */; };
16 | 708BBC60224DFD9900166CC2 /* Permissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC5C224DFD9900166CC2 /* Permissions.swift */; };
17 | 708BBC61224DFD9900166CC2 /* PermissionAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC5D224DFD9900166CC2 /* PermissionAlert.swift */; };
18 | 708BBC62224DFD9900166CC2 /* PermissionDirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC5E224DFD9900166CC2 /* PermissionDirector.swift */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXFileReference section */
22 | 708BBC30224DFB8C00166CC2 /* PermissionDirectorExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PermissionDirectorExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
23 | 708BBC33224DFB8C00166CC2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
24 | 708BBC35224DFB8C00166CC2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
25 | 708BBC38224DFB8C00166CC2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
26 | 708BBC3A224DFB8D00166CC2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
27 | 708BBC3D224DFB8D00166CC2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
28 | 708BBC3F224DFB8D00166CC2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
29 | 708BBC5B224DFD9900166CC2 /* PermissionProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionProtocol.swift; sourceTree = ""; };
30 | 708BBC5C224DFD9900166CC2 /* Permissions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Permissions.swift; sourceTree = ""; };
31 | 708BBC5D224DFD9900166CC2 /* PermissionAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionAlert.swift; sourceTree = ""; };
32 | 708BBC5E224DFD9900166CC2 /* PermissionDirector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionDirector.swift; sourceTree = ""; };
33 | /* End PBXFileReference section */
34 |
35 | /* Begin PBXFrameworksBuildPhase section */
36 | 708BBC2D224DFB8C00166CC2 /* Frameworks */ = {
37 | isa = PBXFrameworksBuildPhase;
38 | buildActionMask = 2147483647;
39 | files = (
40 | );
41 | runOnlyForDeploymentPostprocessing = 0;
42 | };
43 | /* End PBXFrameworksBuildPhase section */
44 |
45 | /* Begin PBXGroup section */
46 | 708BBC27224DFB8B00166CC2 = {
47 | isa = PBXGroup;
48 | children = (
49 | 708BBC32224DFB8C00166CC2 /* PermissionDirectorExample */,
50 | 708BBC31224DFB8C00166CC2 /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | 708BBC31224DFB8C00166CC2 /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | 708BBC30224DFB8C00166CC2 /* PermissionDirectorExample.app */,
58 | );
59 | name = Products;
60 | sourceTree = "";
61 | };
62 | 708BBC32224DFB8C00166CC2 /* PermissionDirectorExample */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 708BBC5A224DFD9900166CC2 /* Sources */,
66 | 708BBC33224DFB8C00166CC2 /* AppDelegate.swift */,
67 | 708BBC35224DFB8C00166CC2 /* ViewController.swift */,
68 | 708BBC37224DFB8C00166CC2 /* Main.storyboard */,
69 | 708BBC3A224DFB8D00166CC2 /* Assets.xcassets */,
70 | 708BBC3C224DFB8D00166CC2 /* LaunchScreen.storyboard */,
71 | 708BBC3F224DFB8D00166CC2 /* Info.plist */,
72 | );
73 | path = PermissionDirectorExample;
74 | sourceTree = "";
75 | };
76 | 708BBC5A224DFD9900166CC2 /* Sources */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 708BBC5B224DFD9900166CC2 /* PermissionProtocol.swift */,
80 | 708BBC5C224DFD9900166CC2 /* Permissions.swift */,
81 | 708BBC5D224DFD9900166CC2 /* PermissionAlert.swift */,
82 | 708BBC5E224DFD9900166CC2 /* PermissionDirector.swift */,
83 | );
84 | name = Sources;
85 | path = ../../Sources;
86 | sourceTree = "";
87 | };
88 | /* End PBXGroup section */
89 |
90 | /* Begin PBXNativeTarget section */
91 | 708BBC2F224DFB8C00166CC2 /* PermissionDirectorExample */ = {
92 | isa = PBXNativeTarget;
93 | buildConfigurationList = 708BBC42224DFB8D00166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirectorExample" */;
94 | buildPhases = (
95 | 708BBC2C224DFB8C00166CC2 /* Sources */,
96 | 708BBC2D224DFB8C00166CC2 /* Frameworks */,
97 | 708BBC2E224DFB8C00166CC2 /* Resources */,
98 | );
99 | buildRules = (
100 | );
101 | dependencies = (
102 | );
103 | name = PermissionDirectorExample;
104 | productName = PermissionDirectorExample;
105 | productReference = 708BBC30224DFB8C00166CC2 /* PermissionDirectorExample.app */;
106 | productType = "com.apple.product-type.application";
107 | };
108 | /* End PBXNativeTarget section */
109 |
110 | /* Begin PBXProject section */
111 | 708BBC28224DFB8B00166CC2 /* Project object */ = {
112 | isa = PBXProject;
113 | attributes = {
114 | LastSwiftUpdateCheck = 1020;
115 | LastUpgradeCheck = 1020;
116 | ORGANIZATIONNAME = SoolyChristina;
117 | TargetAttributes = {
118 | 708BBC2F224DFB8C00166CC2 = {
119 | CreatedOnToolsVersion = 10.2;
120 | };
121 | };
122 | };
123 | buildConfigurationList = 708BBC2B224DFB8B00166CC2 /* Build configuration list for PBXProject "PermissionDirectorExample" */;
124 | compatibilityVersion = "Xcode 9.3";
125 | developmentRegion = en;
126 | hasScannedForEncodings = 0;
127 | knownRegions = (
128 | en,
129 | Base,
130 | );
131 | mainGroup = 708BBC27224DFB8B00166CC2;
132 | productRefGroup = 708BBC31224DFB8C00166CC2 /* Products */;
133 | projectDirPath = "";
134 | projectRoot = "";
135 | targets = (
136 | 708BBC2F224DFB8C00166CC2 /* PermissionDirectorExample */,
137 | );
138 | };
139 | /* End PBXProject section */
140 |
141 | /* Begin PBXResourcesBuildPhase section */
142 | 708BBC2E224DFB8C00166CC2 /* Resources */ = {
143 | isa = PBXResourcesBuildPhase;
144 | buildActionMask = 2147483647;
145 | files = (
146 | 708BBC3E224DFB8D00166CC2 /* LaunchScreen.storyboard in Resources */,
147 | 708BBC3B224DFB8D00166CC2 /* Assets.xcassets in Resources */,
148 | 708BBC39224DFB8C00166CC2 /* Main.storyboard in Resources */,
149 | );
150 | runOnlyForDeploymentPostprocessing = 0;
151 | };
152 | /* End PBXResourcesBuildPhase section */
153 |
154 | /* Begin PBXSourcesBuildPhase section */
155 | 708BBC2C224DFB8C00166CC2 /* Sources */ = {
156 | isa = PBXSourcesBuildPhase;
157 | buildActionMask = 2147483647;
158 | files = (
159 | 708BBC62224DFD9900166CC2 /* PermissionDirector.swift in Sources */,
160 | 708BBC60224DFD9900166CC2 /* Permissions.swift in Sources */,
161 | 708BBC36224DFB8C00166CC2 /* ViewController.swift in Sources */,
162 | 708BBC34224DFB8C00166CC2 /* AppDelegate.swift in Sources */,
163 | 708BBC5F224DFD9900166CC2 /* PermissionProtocol.swift in Sources */,
164 | 708BBC61224DFD9900166CC2 /* PermissionAlert.swift in Sources */,
165 | );
166 | runOnlyForDeploymentPostprocessing = 0;
167 | };
168 | /* End PBXSourcesBuildPhase section */
169 |
170 | /* Begin PBXVariantGroup section */
171 | 708BBC37224DFB8C00166CC2 /* Main.storyboard */ = {
172 | isa = PBXVariantGroup;
173 | children = (
174 | 708BBC38224DFB8C00166CC2 /* Base */,
175 | );
176 | name = Main.storyboard;
177 | sourceTree = "";
178 | };
179 | 708BBC3C224DFB8D00166CC2 /* LaunchScreen.storyboard */ = {
180 | isa = PBXVariantGroup;
181 | children = (
182 | 708BBC3D224DFB8D00166CC2 /* Base */,
183 | );
184 | name = LaunchScreen.storyboard;
185 | sourceTree = "";
186 | };
187 | /* End PBXVariantGroup section */
188 |
189 | /* Begin XCBuildConfiguration section */
190 | 708BBC40224DFB8D00166CC2 /* Debug */ = {
191 | isa = XCBuildConfiguration;
192 | buildSettings = {
193 | ALWAYS_SEARCH_USER_PATHS = NO;
194 | CLANG_ANALYZER_NONNULL = YES;
195 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
196 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
197 | CLANG_CXX_LIBRARY = "libc++";
198 | CLANG_ENABLE_MODULES = YES;
199 | CLANG_ENABLE_OBJC_ARC = YES;
200 | CLANG_ENABLE_OBJC_WEAK = YES;
201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
202 | CLANG_WARN_BOOL_CONVERSION = YES;
203 | CLANG_WARN_COMMA = YES;
204 | CLANG_WARN_CONSTANT_CONVERSION = YES;
205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
208 | CLANG_WARN_EMPTY_BODY = YES;
209 | CLANG_WARN_ENUM_CONVERSION = YES;
210 | CLANG_WARN_INFINITE_RECURSION = YES;
211 | CLANG_WARN_INT_CONVERSION = YES;
212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
217 | CLANG_WARN_STRICT_PROTOTYPES = YES;
218 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
219 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
220 | CLANG_WARN_UNREACHABLE_CODE = YES;
221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222 | CODE_SIGN_IDENTITY = "iPhone Developer";
223 | COPY_PHASE_STRIP = NO;
224 | DEBUG_INFORMATION_FORMAT = dwarf;
225 | ENABLE_STRICT_OBJC_MSGSEND = YES;
226 | ENABLE_TESTABILITY = YES;
227 | GCC_C_LANGUAGE_STANDARD = gnu11;
228 | GCC_DYNAMIC_NO_PIC = NO;
229 | GCC_NO_COMMON_BLOCKS = YES;
230 | GCC_OPTIMIZATION_LEVEL = 0;
231 | GCC_PREPROCESSOR_DEFINITIONS = (
232 | "DEBUG=1",
233 | "$(inherited)",
234 | );
235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
237 | GCC_WARN_UNDECLARED_SELECTOR = YES;
238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
239 | GCC_WARN_UNUSED_FUNCTION = YES;
240 | GCC_WARN_UNUSED_VARIABLE = YES;
241 | IPHONEOS_DEPLOYMENT_TARGET = 12.2;
242 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
243 | MTL_FAST_MATH = YES;
244 | ONLY_ACTIVE_ARCH = YES;
245 | SDKROOT = iphoneos;
246 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
247 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
248 | };
249 | name = Debug;
250 | };
251 | 708BBC41224DFB8D00166CC2 /* Release */ = {
252 | isa = XCBuildConfiguration;
253 | buildSettings = {
254 | ALWAYS_SEARCH_USER_PATHS = NO;
255 | CLANG_ANALYZER_NONNULL = YES;
256 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
258 | CLANG_CXX_LIBRARY = "libc++";
259 | CLANG_ENABLE_MODULES = YES;
260 | CLANG_ENABLE_OBJC_ARC = YES;
261 | CLANG_ENABLE_OBJC_WEAK = YES;
262 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
263 | CLANG_WARN_BOOL_CONVERSION = YES;
264 | CLANG_WARN_COMMA = YES;
265 | CLANG_WARN_CONSTANT_CONVERSION = YES;
266 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
267 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
268 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
269 | CLANG_WARN_EMPTY_BODY = YES;
270 | CLANG_WARN_ENUM_CONVERSION = YES;
271 | CLANG_WARN_INFINITE_RECURSION = YES;
272 | CLANG_WARN_INT_CONVERSION = YES;
273 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
274 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
275 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
277 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
278 | CLANG_WARN_STRICT_PROTOTYPES = YES;
279 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
280 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
281 | CLANG_WARN_UNREACHABLE_CODE = YES;
282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
283 | CODE_SIGN_IDENTITY = "iPhone Developer";
284 | COPY_PHASE_STRIP = NO;
285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
286 | ENABLE_NS_ASSERTIONS = NO;
287 | ENABLE_STRICT_OBJC_MSGSEND = YES;
288 | GCC_C_LANGUAGE_STANDARD = gnu11;
289 | GCC_NO_COMMON_BLOCKS = YES;
290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292 | GCC_WARN_UNDECLARED_SELECTOR = YES;
293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294 | GCC_WARN_UNUSED_FUNCTION = YES;
295 | GCC_WARN_UNUSED_VARIABLE = YES;
296 | IPHONEOS_DEPLOYMENT_TARGET = 12.2;
297 | MTL_ENABLE_DEBUG_INFO = NO;
298 | MTL_FAST_MATH = YES;
299 | SDKROOT = iphoneos;
300 | SWIFT_COMPILATION_MODE = wholemodule;
301 | SWIFT_OPTIMIZATION_LEVEL = "-O";
302 | VALIDATE_PRODUCT = YES;
303 | };
304 | name = Release;
305 | };
306 | 708BBC43224DFB8D00166CC2 /* Debug */ = {
307 | isa = XCBuildConfiguration;
308 | buildSettings = {
309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
310 | CODE_SIGN_STYLE = Automatic;
311 | DEVELOPMENT_TEAM = MTV47GTW4C;
312 | INFOPLIST_FILE = PermissionDirectorExample/Info.plist;
313 | LD_RUNPATH_SEARCH_PATHS = (
314 | "$(inherited)",
315 | "@executable_path/Frameworks",
316 | );
317 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirectorExample;
318 | PRODUCT_NAME = "$(TARGET_NAME)";
319 | SWIFT_VERSION = 5.0;
320 | TARGETED_DEVICE_FAMILY = "1,2";
321 | };
322 | name = Debug;
323 | };
324 | 708BBC44224DFB8D00166CC2 /* Release */ = {
325 | isa = XCBuildConfiguration;
326 | buildSettings = {
327 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
328 | CODE_SIGN_STYLE = Automatic;
329 | DEVELOPMENT_TEAM = MTV47GTW4C;
330 | INFOPLIST_FILE = PermissionDirectorExample/Info.plist;
331 | LD_RUNPATH_SEARCH_PATHS = (
332 | "$(inherited)",
333 | "@executable_path/Frameworks",
334 | );
335 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirectorExample;
336 | PRODUCT_NAME = "$(TARGET_NAME)";
337 | SWIFT_VERSION = 5.0;
338 | TARGETED_DEVICE_FAMILY = "1,2";
339 | };
340 | name = Release;
341 | };
342 | /* End XCBuildConfiguration section */
343 |
344 | /* Begin XCConfigurationList section */
345 | 708BBC2B224DFB8B00166CC2 /* Build configuration list for PBXProject "PermissionDirectorExample" */ = {
346 | isa = XCConfigurationList;
347 | buildConfigurations = (
348 | 708BBC40224DFB8D00166CC2 /* Debug */,
349 | 708BBC41224DFB8D00166CC2 /* Release */,
350 | );
351 | defaultConfigurationIsVisible = 0;
352 | defaultConfigurationName = Release;
353 | };
354 | 708BBC42224DFB8D00166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirectorExample" */ = {
355 | isa = XCConfigurationList;
356 | buildConfigurations = (
357 | 708BBC43224DFB8D00166CC2 /* Debug */,
358 | 708BBC44224DFB8D00166CC2 /* Release */,
359 | );
360 | defaultConfigurationIsVisible = 0;
361 | defaultConfigurationName = Release;
362 | };
363 | /* End XCConfigurationList section */
364 | };
365 | rootObject = 708BBC28224DFB8B00166CC2 /* Project object */;
366 | }
367 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/22.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/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 | }
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/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 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
27 |
34 |
41 |
48 |
55 |
62 |
69 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/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 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSCalendarsUsageDescription
24 | 用于日程
25 | NSCameraUsageDescription
26 | 用于拍照
27 | NSContactsUsageDescription
28 | 用于打电话
29 | NSLocationAlwaysAndWhenInUseUsageDescription
30 | 用于Always定位
31 | NSLocationWhenInUseUsageDescription
32 | 用于WhenInUse定位
33 | NSMicrophoneUsageDescription
34 | 用于录音
35 | NSPhotoLibraryUsageDescription
36 | 用于上传动态
37 | UILaunchStoryboardName
38 | LaunchScreen
39 | UIMainStoryboardFile
40 | Main
41 | UIRequiredDeviceCapabilities
42 |
43 | armv7
44 |
45 | UISupportedInterfaceOrientations
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationLandscapeLeft
49 | UIInterfaceOrientationLandscapeRight
50 |
51 | UISupportedInterfaceOrientations~ipad
52 |
53 | UIInterfaceOrientationPortrait
54 | UIInterfaceOrientationPortraitUpsideDown
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Example/PermissionDirectorExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/22.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | }
17 |
18 | @IBAction func cameraAction(_ sender: UIButton) {
19 | if !PermissionDirector.isAuthorized(for: .camera) {
20 | PermissionDirector.requestAuthorization(for: .camera) { (result) in
21 | if result == .authorized {
22 | print("camera permission has been authorized")
23 | }
24 | }
25 | } else {
26 | showAlert(title: "camera")
27 | }
28 | }
29 |
30 | @IBAction func microhoneAction(_ sender: Any) {
31 | if !PermissionDirector.isAuthorized(for: .microphone) {
32 | PermissionDirector.requestAuthorization(for: .microphone) { (result) in
33 | if result == .authorized {
34 | print("microphone permission has been authorized")
35 | }
36 | }
37 | } else {
38 | showAlert(title: "microphone")
39 | }
40 | }
41 |
42 | @IBAction func notificationAction(_ sender: Any) {
43 | if !PermissionDirector.isAuthorized(for: .notification) {
44 | PermissionDirector.requestAuthorization(for: .notification) { (result) in
45 | if result == .authorized {
46 | print("notification permission has been authorized")
47 | }
48 | }
49 | } else {
50 | showAlert(title: "notification")
51 | }
52 | }
53 |
54 | @IBAction func phonebookAction(_ sender: Any) {
55 | if !PermissionDirector.isAuthorized(for: .phonebook) {
56 | PermissionDirector.requestAuthorization(for: .phonebook) { (result) in
57 | if result == .authorized {
58 | print("phonebook permission has been authorized")
59 | }
60 | }
61 | } else {
62 | showAlert(title: "phonebook")
63 | }
64 | }
65 | @IBAction func photoAction(_ sender: Any) {
66 | if !PermissionDirector.isAuthorized(for: .photo) {
67 | PermissionDirector.requestAuthorization(for: .photo) { (result) in
68 | if result == .authorized {
69 | print("photo library permission has been authorized")
70 | }
71 | }
72 | } else {
73 | showAlert(title: "photo library")
74 | }
75 | }
76 |
77 | @IBAction func calendarAction(_ sender: Any) {
78 | if !PermissionDirector.isAuthorized(for: .calendar) {
79 | PermissionDirector.requestAuthorization(for: .calendar) { (result) in
80 | if result == .authorized {
81 | print("calendar permission has been authorized")
82 | }
83 | }
84 | } else {
85 | showAlert(title: "calendar")
86 | }
87 | }
88 |
89 | @IBAction func locationWhenInUseAction(_ sender: Any) {
90 | if !PermissionDirector.isAuthorized(for: .location(.whenInUse)) {
91 | PermissionDirector.requestAuthorization(for: .location(.whenInUse)) { (result) in
92 | if result == .authorized {
93 | print("location(whenInUse) permission has been authorized")
94 | }
95 | }
96 | } else {
97 | showAlert(title: "location(whenInUse)")
98 | }
99 | }
100 |
101 | @IBAction func locationAlwaysAction(_ sender: Any) {
102 | if !PermissionDirector.isAuthorized(for: .location(.always)) {
103 | PermissionDirector.requestAuthorization(for: .location(.always)) { (result) in
104 | if result == .authorized {
105 | print("location(always) permission has been authorized")
106 | }
107 | }
108 | } else {
109 | showAlert(title: "location(always)")
110 | }
111 | }
112 |
113 | func showAlert(title: String) {
114 | let alert = UIAlertController(title: title, message: "\(title) permission has been authorized", preferredStyle: .alert)
115 | let okAction = UIAlertAction(title: "OK", style: .default)
116 | alert.addAction(okAction)
117 | present(alert, animated: true)
118 | }
119 |
120 | }
121 |
122 | class PermissionToastView: UIView {
123 | required init(type: PermissionType) {
124 | super.init(frame: CGRect())
125 | }
126 |
127 | required init?(coder aDecoder: NSCoder) {
128 | fatalError("init(coder:) has not been implemented")
129 | }
130 | }
131 | extension PermissionToastView: PermissionAlertProtocol {
132 | func show() {
133 |
134 | }
135 | }
136 |
137 |
138 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 SoolyChristina
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.0
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "PermissionDirector",
8 | platforms: [.iOS(.v9)],
9 | products: [
10 | // Products define the executables and libraries produced by a package, and make them visible to other packages.
11 | .library(
12 | name: "PermissionDirector",
13 | targets: ["PermissionDirector"]),
14 | ],
15 | dependencies: [
16 | // Dependencies declare other packages that this package depends on.
17 | // .package(url: /* package url */, from: "1.0.0"),
18 | ],
19 | targets: [
20 | // Targets are the basic building blocks of a package. A target can define a module or a test suite.
21 | // Targets can depend on other targets in this package, and on products in packages which this package depends on.
22 | .target(
23 | name: "PermissionDirector",
24 | dependencies: [],
25 | path: "Sources"),
26 | .testTarget(
27 | name: "PermissionDirectorTests",
28 | dependencies: ["PermissionDirector"]),
29 | ],
30 | swiftLanguageVersions: [.v5]
31 | )
32 |
--------------------------------------------------------------------------------
/PermissionDirector iOS/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 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/PermissionDirector iOS/PermissionDirector_iOS.h:
--------------------------------------------------------------------------------
1 | //
2 | // PermissionDirector_iOS.h
3 | // PermissionDirector iOS
4 | //
5 | // Created by SoolyChristina on 2019/3/29.
6 | // Copyright © 2019 SoolyChristina. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for PermissionDirector_iOS.
12 | FOUNDATION_EXPORT double PermissionDirector_iOSVersionNumber;
13 |
14 | //! Project version string for PermissionDirector_iOS.
15 | FOUNDATION_EXPORT const unsigned char PermissionDirector_iOSVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/PermissionDirector.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "PermissionDirector"
3 | s.version = "0.0.6"
4 | s.summary = "iOS Permission manager."
5 | s.description = <<-DESC
6 | PermissionDirector is a iOS permission manager.
7 | DESC
8 | s.homepage = "https://github.com/SoolyChristy/PermissionDirector"
9 | s.license = { :type => "MIT", :file => "LICENSE" }
10 | s.author = { "SoolyChristy" => "imsooly@163.com" }
11 | s.source = { :git => "https://github.com/SoolyChristy/PermissionDirector.git", :tag => s.version }
12 | s.source_files = ["Sources/*.swift"]
13 | s.platform = :ios, '9.0'
14 | s.swift_version = '5.0'
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/PermissionDirector.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 708BBBFE224DF95800166CC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 708BBBFD224DF95800166CC2 /* Assets.xcassets */; };
11 | 708BBC11224DFA0500166CC2 /* PermissionDirector_iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 708BBC0F224DFA0500166CC2 /* PermissionDirector_iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
12 | 708BBC14224DFA0500166CC2 /* PermissionDirector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 708BBC0D224DFA0500166CC2 /* PermissionDirector.framework */; };
13 | 708BBC15224DFA0500166CC2 /* PermissionDirector.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 708BBC0D224DFA0500166CC2 /* PermissionDirector.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 708BBC50224DFD6700166CC2 /* PermissionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4C224DFD6700166CC2 /* PermissionProtocol.swift */; };
15 | 708BBC51224DFD6700166CC2 /* PermissionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4C224DFD6700166CC2 /* PermissionProtocol.swift */; };
16 | 708BBC52224DFD6700166CC2 /* Permissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4D224DFD6700166CC2 /* Permissions.swift */; };
17 | 708BBC53224DFD6700166CC2 /* Permissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4D224DFD6700166CC2 /* Permissions.swift */; };
18 | 708BBC54224DFD6700166CC2 /* PermissionAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4E224DFD6700166CC2 /* PermissionAlert.swift */; };
19 | 708BBC55224DFD6700166CC2 /* PermissionAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4E224DFD6700166CC2 /* PermissionAlert.swift */; };
20 | 708BBC56224DFD6700166CC2 /* PermissionDirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4F224DFD6700166CC2 /* PermissionDirector.swift */; };
21 | 708BBC57224DFD6700166CC2 /* PermissionDirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708BBC4F224DFD6700166CC2 /* PermissionDirector.swift */; };
22 | /* End PBXBuildFile section */
23 |
24 | /* Begin PBXContainerItemProxy section */
25 | 708BBC12224DFA0500166CC2 /* PBXContainerItemProxy */ = {
26 | isa = PBXContainerItemProxy;
27 | containerPortal = 708BBBEB224DF95600166CC2 /* Project object */;
28 | proxyType = 1;
29 | remoteGlobalIDString = 708BBC0C224DFA0500166CC2;
30 | remoteInfo = "PermissionDirector iOS";
31 | };
32 | /* End PBXContainerItemProxy section */
33 |
34 | /* Begin PBXCopyFilesBuildPhase section */
35 | 708BBC19224DFA0500166CC2 /* Embed Frameworks */ = {
36 | isa = PBXCopyFilesBuildPhase;
37 | buildActionMask = 2147483647;
38 | dstPath = "";
39 | dstSubfolderSpec = 10;
40 | files = (
41 | 708BBC15224DFA0500166CC2 /* PermissionDirector.framework in Embed Frameworks */,
42 | );
43 | name = "Embed Frameworks";
44 | runOnlyForDeploymentPostprocessing = 0;
45 | };
46 | /* End PBXCopyFilesBuildPhase section */
47 |
48 | /* Begin PBXFileReference section */
49 | 708BBBF3224DF95600166CC2 /* PermissionDirector.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PermissionDirector.app; sourceTree = BUILT_PRODUCTS_DIR; };
50 | 708BBBFD224DF95800166CC2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
51 | 708BBC02224DF95800166CC2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
52 | 708BBC0D224DFA0500166CC2 /* PermissionDirector.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PermissionDirector.framework; sourceTree = BUILT_PRODUCTS_DIR; };
53 | 708BBC0F224DFA0500166CC2 /* PermissionDirector_iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PermissionDirector_iOS.h; sourceTree = ""; };
54 | 708BBC10224DFA0500166CC2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
55 | 708BBC4C224DFD6700166CC2 /* PermissionProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionProtocol.swift; sourceTree = ""; };
56 | 708BBC4D224DFD6700166CC2 /* Permissions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Permissions.swift; sourceTree = ""; };
57 | 708BBC4E224DFD6700166CC2 /* PermissionAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionAlert.swift; sourceTree = ""; };
58 | 708BBC4F224DFD6700166CC2 /* PermissionDirector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionDirector.swift; sourceTree = ""; };
59 | /* End PBXFileReference section */
60 |
61 | /* Begin PBXFrameworksBuildPhase section */
62 | 708BBBF0224DF95600166CC2 /* Frameworks */ = {
63 | isa = PBXFrameworksBuildPhase;
64 | buildActionMask = 2147483647;
65 | files = (
66 | 708BBC14224DFA0500166CC2 /* PermissionDirector.framework in Frameworks */,
67 | );
68 | runOnlyForDeploymentPostprocessing = 0;
69 | };
70 | 708BBC0A224DFA0500166CC2 /* Frameworks */ = {
71 | isa = PBXFrameworksBuildPhase;
72 | buildActionMask = 2147483647;
73 | files = (
74 | );
75 | runOnlyForDeploymentPostprocessing = 0;
76 | };
77 | /* End PBXFrameworksBuildPhase section */
78 |
79 | /* Begin PBXGroup section */
80 | 708BBBEA224DF95600166CC2 = {
81 | isa = PBXGroup;
82 | children = (
83 | 708BBBF5224DF95600166CC2 /* PermissionDirector */,
84 | 708BBC0E224DFA0500166CC2 /* PermissionDirector iOS */,
85 | 708BBBF4224DF95600166CC2 /* Products */,
86 | );
87 | sourceTree = "";
88 | };
89 | 708BBBF4224DF95600166CC2 /* Products */ = {
90 | isa = PBXGroup;
91 | children = (
92 | 708BBBF3224DF95600166CC2 /* PermissionDirector.app */,
93 | 708BBC0D224DFA0500166CC2 /* PermissionDirector.framework */,
94 | );
95 | name = Products;
96 | sourceTree = "";
97 | };
98 | 708BBBF5224DF95600166CC2 /* PermissionDirector */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 708BBBFD224DF95800166CC2 /* Assets.xcassets */,
102 | 708BBC02224DF95800166CC2 /* Info.plist */,
103 | 708BBC4B224DFD6700166CC2 /* Sources */,
104 | );
105 | path = PermissionDirector;
106 | sourceTree = "";
107 | };
108 | 708BBC0E224DFA0500166CC2 /* PermissionDirector iOS */ = {
109 | isa = PBXGroup;
110 | children = (
111 | 708BBC0F224DFA0500166CC2 /* PermissionDirector_iOS.h */,
112 | 708BBC10224DFA0500166CC2 /* Info.plist */,
113 | );
114 | path = "PermissionDirector iOS";
115 | sourceTree = "";
116 | };
117 | 708BBC4B224DFD6700166CC2 /* Sources */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 708BBC4C224DFD6700166CC2 /* PermissionProtocol.swift */,
121 | 708BBC4D224DFD6700166CC2 /* Permissions.swift */,
122 | 708BBC4E224DFD6700166CC2 /* PermissionAlert.swift */,
123 | 708BBC4F224DFD6700166CC2 /* PermissionDirector.swift */,
124 | );
125 | path = Sources;
126 | sourceTree = SOURCE_ROOT;
127 | };
128 | /* End PBXGroup section */
129 |
130 | /* Begin PBXHeadersBuildPhase section */
131 | 708BBC08224DFA0500166CC2 /* Headers */ = {
132 | isa = PBXHeadersBuildPhase;
133 | buildActionMask = 2147483647;
134 | files = (
135 | 708BBC11224DFA0500166CC2 /* PermissionDirector_iOS.h in Headers */,
136 | );
137 | runOnlyForDeploymentPostprocessing = 0;
138 | };
139 | /* End PBXHeadersBuildPhase section */
140 |
141 | /* Begin PBXNativeTarget section */
142 | 708BBBF2224DF95600166CC2 /* PermissionDirector */ = {
143 | isa = PBXNativeTarget;
144 | buildConfigurationList = 708BBC05224DF95800166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirector" */;
145 | buildPhases = (
146 | 708BBBEF224DF95600166CC2 /* Sources */,
147 | 708BBBF0224DF95600166CC2 /* Frameworks */,
148 | 708BBBF1224DF95600166CC2 /* Resources */,
149 | 708BBC19224DFA0500166CC2 /* Embed Frameworks */,
150 | );
151 | buildRules = (
152 | );
153 | dependencies = (
154 | 708BBC13224DFA0500166CC2 /* PBXTargetDependency */,
155 | );
156 | name = PermissionDirector;
157 | productName = PermissionDirector;
158 | productReference = 708BBBF3224DF95600166CC2 /* PermissionDirector.app */;
159 | productType = "com.apple.product-type.application";
160 | };
161 | 708BBC0C224DFA0500166CC2 /* PermissionDirector iOS */ = {
162 | isa = PBXNativeTarget;
163 | buildConfigurationList = 708BBC16224DFA0500166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirector iOS" */;
164 | buildPhases = (
165 | 708BBC08224DFA0500166CC2 /* Headers */,
166 | 708BBC09224DFA0500166CC2 /* Sources */,
167 | 708BBC0A224DFA0500166CC2 /* Frameworks */,
168 | 708BBC0B224DFA0500166CC2 /* Resources */,
169 | );
170 | buildRules = (
171 | );
172 | dependencies = (
173 | );
174 | name = "PermissionDirector iOS";
175 | productName = "PermissionDirector iOS";
176 | productReference = 708BBC0D224DFA0500166CC2 /* PermissionDirector.framework */;
177 | productType = "com.apple.product-type.framework";
178 | };
179 | /* End PBXNativeTarget section */
180 |
181 | /* Begin PBXProject section */
182 | 708BBBEB224DF95600166CC2 /* Project object */ = {
183 | isa = PBXProject;
184 | attributes = {
185 | LastSwiftUpdateCheck = 1020;
186 | LastUpgradeCheck = 1020;
187 | ORGANIZATIONNAME = SoolyChristina;
188 | TargetAttributes = {
189 | 708BBBF2224DF95600166CC2 = {
190 | CreatedOnToolsVersion = 10.2;
191 | };
192 | 708BBC0C224DFA0500166CC2 = {
193 | CreatedOnToolsVersion = 10.2;
194 | };
195 | };
196 | };
197 | buildConfigurationList = 708BBBEE224DF95600166CC2 /* Build configuration list for PBXProject "PermissionDirector" */;
198 | compatibilityVersion = "Xcode 9.3";
199 | developmentRegion = en;
200 | hasScannedForEncodings = 0;
201 | knownRegions = (
202 | en,
203 | Base,
204 | );
205 | mainGroup = 708BBBEA224DF95600166CC2;
206 | productRefGroup = 708BBBF4224DF95600166CC2 /* Products */;
207 | projectDirPath = "";
208 | projectRoot = "";
209 | targets = (
210 | 708BBBF2224DF95600166CC2 /* PermissionDirector */,
211 | 708BBC0C224DFA0500166CC2 /* PermissionDirector iOS */,
212 | );
213 | };
214 | /* End PBXProject section */
215 |
216 | /* Begin PBXResourcesBuildPhase section */
217 | 708BBBF1224DF95600166CC2 /* Resources */ = {
218 | isa = PBXResourcesBuildPhase;
219 | buildActionMask = 2147483647;
220 | files = (
221 | 708BBBFE224DF95800166CC2 /* Assets.xcassets in Resources */,
222 | );
223 | runOnlyForDeploymentPostprocessing = 0;
224 | };
225 | 708BBC0B224DFA0500166CC2 /* Resources */ = {
226 | isa = PBXResourcesBuildPhase;
227 | buildActionMask = 2147483647;
228 | files = (
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | /* End PBXResourcesBuildPhase section */
233 |
234 | /* Begin PBXSourcesBuildPhase section */
235 | 708BBBEF224DF95600166CC2 /* Sources */ = {
236 | isa = PBXSourcesBuildPhase;
237 | buildActionMask = 2147483647;
238 | files = (
239 | 708BBC56224DFD6700166CC2 /* PermissionDirector.swift in Sources */,
240 | 708BBC52224DFD6700166CC2 /* Permissions.swift in Sources */,
241 | 708BBC54224DFD6700166CC2 /* PermissionAlert.swift in Sources */,
242 | 708BBC50224DFD6700166CC2 /* PermissionProtocol.swift in Sources */,
243 | );
244 | runOnlyForDeploymentPostprocessing = 0;
245 | };
246 | 708BBC09224DFA0500166CC2 /* Sources */ = {
247 | isa = PBXSourcesBuildPhase;
248 | buildActionMask = 2147483647;
249 | files = (
250 | 708BBC57224DFD6700166CC2 /* PermissionDirector.swift in Sources */,
251 | 708BBC53224DFD6700166CC2 /* Permissions.swift in Sources */,
252 | 708BBC55224DFD6700166CC2 /* PermissionAlert.swift in Sources */,
253 | 708BBC51224DFD6700166CC2 /* PermissionProtocol.swift in Sources */,
254 | );
255 | runOnlyForDeploymentPostprocessing = 0;
256 | };
257 | /* End PBXSourcesBuildPhase section */
258 |
259 | /* Begin PBXTargetDependency section */
260 | 708BBC13224DFA0500166CC2 /* PBXTargetDependency */ = {
261 | isa = PBXTargetDependency;
262 | target = 708BBC0C224DFA0500166CC2 /* PermissionDirector iOS */;
263 | targetProxy = 708BBC12224DFA0500166CC2 /* PBXContainerItemProxy */;
264 | };
265 | /* End PBXTargetDependency section */
266 |
267 | /* Begin XCBuildConfiguration section */
268 | 708BBC03224DF95800166CC2 /* Debug */ = {
269 | isa = XCBuildConfiguration;
270 | buildSettings = {
271 | ALWAYS_SEARCH_USER_PATHS = NO;
272 | CLANG_ANALYZER_NONNULL = YES;
273 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
275 | CLANG_CXX_LIBRARY = "libc++";
276 | CLANG_ENABLE_MODULES = YES;
277 | CLANG_ENABLE_OBJC_ARC = YES;
278 | CLANG_ENABLE_OBJC_WEAK = YES;
279 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
280 | CLANG_WARN_BOOL_CONVERSION = YES;
281 | CLANG_WARN_COMMA = YES;
282 | CLANG_WARN_CONSTANT_CONVERSION = YES;
283 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
284 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
285 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
286 | CLANG_WARN_EMPTY_BODY = YES;
287 | CLANG_WARN_ENUM_CONVERSION = YES;
288 | CLANG_WARN_INFINITE_RECURSION = YES;
289 | CLANG_WARN_INT_CONVERSION = YES;
290 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
291 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
292 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
293 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
294 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
295 | CLANG_WARN_STRICT_PROTOTYPES = YES;
296 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
297 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
298 | CLANG_WARN_UNREACHABLE_CODE = YES;
299 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
300 | CODE_SIGN_IDENTITY = "iPhone Developer";
301 | COPY_PHASE_STRIP = NO;
302 | DEBUG_INFORMATION_FORMAT = dwarf;
303 | ENABLE_STRICT_OBJC_MSGSEND = YES;
304 | ENABLE_TESTABILITY = YES;
305 | GCC_C_LANGUAGE_STANDARD = gnu11;
306 | GCC_DYNAMIC_NO_PIC = NO;
307 | GCC_NO_COMMON_BLOCKS = YES;
308 | GCC_OPTIMIZATION_LEVEL = 0;
309 | GCC_PREPROCESSOR_DEFINITIONS = (
310 | "DEBUG=1",
311 | "$(inherited)",
312 | );
313 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
314 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
315 | GCC_WARN_UNDECLARED_SELECTOR = YES;
316 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
317 | GCC_WARN_UNUSED_FUNCTION = YES;
318 | GCC_WARN_UNUSED_VARIABLE = YES;
319 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
320 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
321 | MTL_FAST_MATH = YES;
322 | ONLY_ACTIVE_ARCH = YES;
323 | SDKROOT = iphoneos;
324 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
325 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
326 | SWIFT_VERSION = 5.0;
327 | };
328 | name = Debug;
329 | };
330 | 708BBC04224DF95800166CC2 /* Release */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = NO;
334 | CLANG_ANALYZER_NONNULL = YES;
335 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
337 | CLANG_CXX_LIBRARY = "libc++";
338 | CLANG_ENABLE_MODULES = YES;
339 | CLANG_ENABLE_OBJC_ARC = YES;
340 | CLANG_ENABLE_OBJC_WEAK = YES;
341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
342 | CLANG_WARN_BOOL_CONVERSION = YES;
343 | CLANG_WARN_COMMA = YES;
344 | CLANG_WARN_CONSTANT_CONVERSION = YES;
345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
347 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
348 | CLANG_WARN_EMPTY_BODY = YES;
349 | CLANG_WARN_ENUM_CONVERSION = YES;
350 | CLANG_WARN_INFINITE_RECURSION = YES;
351 | CLANG_WARN_INT_CONVERSION = YES;
352 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
353 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
354 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
356 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
357 | CLANG_WARN_STRICT_PROTOTYPES = YES;
358 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
359 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
360 | CLANG_WARN_UNREACHABLE_CODE = YES;
361 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
362 | CODE_SIGN_IDENTITY = "iPhone Developer";
363 | COPY_PHASE_STRIP = NO;
364 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
365 | ENABLE_NS_ASSERTIONS = NO;
366 | ENABLE_STRICT_OBJC_MSGSEND = YES;
367 | GCC_C_LANGUAGE_STANDARD = gnu11;
368 | GCC_NO_COMMON_BLOCKS = YES;
369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
371 | GCC_WARN_UNDECLARED_SELECTOR = YES;
372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
373 | GCC_WARN_UNUSED_FUNCTION = YES;
374 | GCC_WARN_UNUSED_VARIABLE = YES;
375 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
376 | MTL_ENABLE_DEBUG_INFO = NO;
377 | MTL_FAST_MATH = YES;
378 | SDKROOT = iphoneos;
379 | SWIFT_COMPILATION_MODE = wholemodule;
380 | SWIFT_OPTIMIZATION_LEVEL = "-O";
381 | SWIFT_VERSION = 5.0;
382 | VALIDATE_PRODUCT = YES;
383 | };
384 | name = Release;
385 | };
386 | 708BBC06224DF95800166CC2 /* Debug */ = {
387 | isa = XCBuildConfiguration;
388 | buildSettings = {
389 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
390 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
391 | CODE_SIGN_STYLE = Automatic;
392 | DEVELOPMENT_TEAM = MTV47GTW4C;
393 | INFOPLIST_FILE = PermissionDirector/Info.plist;
394 | LD_RUNPATH_SEARCH_PATHS = (
395 | "$(inherited)",
396 | "@executable_path/Frameworks",
397 | );
398 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirector;
399 | PRODUCT_NAME = "$(TARGET_NAME)";
400 | SWIFT_VERSION = 5.0;
401 | TARGETED_DEVICE_FAMILY = "1,2";
402 | };
403 | name = Debug;
404 | };
405 | 708BBC07224DF95800166CC2 /* Release */ = {
406 | isa = XCBuildConfiguration;
407 | buildSettings = {
408 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
409 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
410 | CODE_SIGN_STYLE = Automatic;
411 | DEVELOPMENT_TEAM = MTV47GTW4C;
412 | INFOPLIST_FILE = PermissionDirector/Info.plist;
413 | LD_RUNPATH_SEARCH_PATHS = (
414 | "$(inherited)",
415 | "@executable_path/Frameworks",
416 | );
417 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirector;
418 | PRODUCT_NAME = "$(TARGET_NAME)";
419 | SWIFT_VERSION = 5.0;
420 | TARGETED_DEVICE_FAMILY = "1,2";
421 | };
422 | name = Release;
423 | };
424 | 708BBC17224DFA0500166CC2 /* Debug */ = {
425 | isa = XCBuildConfiguration;
426 | buildSettings = {
427 | CODE_SIGN_IDENTITY = "";
428 | CODE_SIGN_STYLE = Automatic;
429 | CURRENT_PROJECT_VERSION = 1;
430 | DEFINES_MODULE = YES;
431 | DEVELOPMENT_TEAM = MTV47GTW4C;
432 | DYLIB_COMPATIBILITY_VERSION = 1;
433 | DYLIB_CURRENT_VERSION = 1;
434 | DYLIB_INSTALL_NAME_BASE = "@rpath";
435 | INFOPLIST_FILE = "PermissionDirector iOS/Info.plist";
436 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
437 | LD_RUNPATH_SEARCH_PATHS = (
438 | "$(inherited)",
439 | "@executable_path/Frameworks",
440 | "@loader_path/Frameworks",
441 | );
442 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirector;
443 | PRODUCT_NAME = PermissionDirector;
444 | SKIP_INSTALL = YES;
445 | SWIFT_VERSION = 5.0;
446 | TARGETED_DEVICE_FAMILY = "1,2";
447 | VERSIONING_SYSTEM = "apple-generic";
448 | VERSION_INFO_PREFIX = "";
449 | };
450 | name = Debug;
451 | };
452 | 708BBC18224DFA0500166CC2 /* Release */ = {
453 | isa = XCBuildConfiguration;
454 | buildSettings = {
455 | CODE_SIGN_IDENTITY = "";
456 | CODE_SIGN_STYLE = Automatic;
457 | CURRENT_PROJECT_VERSION = 1;
458 | DEFINES_MODULE = YES;
459 | DEVELOPMENT_TEAM = MTV47GTW4C;
460 | DYLIB_COMPATIBILITY_VERSION = 1;
461 | DYLIB_CURRENT_VERSION = 1;
462 | DYLIB_INSTALL_NAME_BASE = "@rpath";
463 | INFOPLIST_FILE = "PermissionDirector iOS/Info.plist";
464 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
465 | LD_RUNPATH_SEARCH_PATHS = (
466 | "$(inherited)",
467 | "@executable_path/Frameworks",
468 | "@loader_path/Frameworks",
469 | );
470 | PRODUCT_BUNDLE_IDENTIFIER = Sooly.PermissionDirector;
471 | PRODUCT_NAME = PermissionDirector;
472 | SKIP_INSTALL = YES;
473 | SWIFT_VERSION = 5.0;
474 | TARGETED_DEVICE_FAMILY = "1,2";
475 | VERSIONING_SYSTEM = "apple-generic";
476 | VERSION_INFO_PREFIX = "";
477 | };
478 | name = Release;
479 | };
480 | /* End XCBuildConfiguration section */
481 |
482 | /* Begin XCConfigurationList section */
483 | 708BBBEE224DF95600166CC2 /* Build configuration list for PBXProject "PermissionDirector" */ = {
484 | isa = XCConfigurationList;
485 | buildConfigurations = (
486 | 708BBC03224DF95800166CC2 /* Debug */,
487 | 708BBC04224DF95800166CC2 /* Release */,
488 | );
489 | defaultConfigurationIsVisible = 0;
490 | defaultConfigurationName = Release;
491 | };
492 | 708BBC05224DF95800166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirector" */ = {
493 | isa = XCConfigurationList;
494 | buildConfigurations = (
495 | 708BBC06224DF95800166CC2 /* Debug */,
496 | 708BBC07224DF95800166CC2 /* Release */,
497 | );
498 | defaultConfigurationIsVisible = 0;
499 | defaultConfigurationName = Release;
500 | };
501 | 708BBC16224DFA0500166CC2 /* Build configuration list for PBXNativeTarget "PermissionDirector iOS" */ = {
502 | isa = XCConfigurationList;
503 | buildConfigurations = (
504 | 708BBC17224DFA0500166CC2 /* Debug */,
505 | 708BBC18224DFA0500166CC2 /* Release */,
506 | );
507 | defaultConfigurationIsVisible = 0;
508 | defaultConfigurationName = Release;
509 | };
510 | /* End XCConfigurationList section */
511 | };
512 | rootObject = 708BBBEB224DF95600166CC2 /* Project object */;
513 | }
514 |
--------------------------------------------------------------------------------
/PermissionDirector.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/PermissionDirector.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/PermissionDirector.xcodeproj/xcshareddata/xcschemes/PermissionDirector iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/PermissionDirector.xcodeproj/xcshareddata/xcschemes/PermissionDirector.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/PermissionDirector/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 | }
--------------------------------------------------------------------------------
/PermissionDirector/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/PermissionDirector/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 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | ### 说明
3 | - 请求从未询问的权限会弹出系统的权限窗口
4 | - 请求用户曾经拒绝的权限会展示弹窗提示用户,用户选择同意则跳入系统设置由用户手动打开此权限
5 | ### 效果
6 | 
7 |
8 | ### Cocoapods
9 | 在```podfile```添加
10 | ```
11 | pod 'PermissionDirector'
12 | ```
13 |
14 | ### Carthage
15 | 在```cartfile```添加
16 | ```
17 | github "SoolyChristy/PermissionDirector"
18 | ```
19 | ### Swift Package Manager
20 | 两种方式
21 | - 在```package.swift```添加
22 | ```swift
23 | dependencies: [
24 | .package(url: "https://github.com/SoolyChristy/PermissionDirector.git", from: "0.0.4")
25 | ]
26 | ```
27 | - 在Xcode11中的PROJECT - Swift Packages 添加
28 |
29 | ### 使用
30 | ```swift
31 | if !PermissionDirector.isAuthorized(for: .camera) {
32 | PermissionDirector.requestAuthorization(for: .camera) { (result) in
33 | if result == .authorized {
34 | print("camera permission has been authorized")
35 | }
36 | }
37 | }
38 | ```
39 | ### 自定义弹窗
40 | - 自定义UIView实现`PermissionAlertProtocol`协议
41 | ```swift
42 | public protocol PermissionAlertProtocol: class {
43 | /// 提供弹窗实例
44 | ///
45 | /// - Parameter type: 权限类型
46 | /// - Returns: 弹窗实例
47 | init(type: PermissionType)
48 |
49 | /// 展示弹窗
50 | func show()
51 | }
52 | ```
53 | ```swift
54 | class PermissionHudView: UIView, PermissionAlertProtocol {
55 | required init(type: PermissionType) {
56 | super.init(frame: CGRect())
57 | // 你的实现
58 | }
59 |
60 | func show() {
61 | // 你的实现
62 | }
63 | }
64 | ```
65 | - 更改弹窗类型
66 | ```swift
67 | PermissionDirector.alertType = PermissionHudView.self
68 | ```
69 |
--------------------------------------------------------------------------------
/Sources/PermissionAlert.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PermissionAlert.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/24.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | public protocol PermissionAlertProtocol: AnyObject {
12 | /// 提供弹窗实例
13 | ///
14 | /// - Parameter type: 权限类型
15 | /// - Returns: 弹窗实例
16 | init(type: PermissionType)
17 |
18 | /// 展示弹窗
19 | func show()
20 | }
21 |
22 | extension PermissionAlertProtocol {
23 | func gotoSetting() {
24 | guard let settingUrl = URL(string: UIApplication.openSettingsURLString) else {
25 | return
26 | }
27 | if #available(iOS 10.0, *) {
28 | UIApplication.shared.open(settingUrl, options: [:])
29 | } else {
30 | UIApplication.shared.openURL(settingUrl)
31 | }
32 | }
33 | }
34 |
35 | final class PermissionAlertView: UIView {
36 | required init(type: PermissionType) {
37 | self.type = type
38 | super.init(frame: CGRect())
39 | setupUI()
40 | }
41 |
42 | required init?(coder aDecoder: NSCoder) {
43 | fatalError("init(coder:) has not been implemente")
44 | }
45 |
46 | private func setupUI() {
47 | translatesAutoresizingMaskIntoConstraints = false
48 |
49 | let coverView = UIView()
50 | coverView.backgroundColor = UIColor.black.withAlphaComponent(0.48)
51 | self.addSubview(coverView)
52 | coverView.translatesAutoresizingMaskIntoConstraints = false
53 | coverView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
54 | coverView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
55 | coverView.topAnchor.constraint(equalTo: topAnchor).isActive = true
56 | coverView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
57 |
58 | let contentView = UIView()
59 | contentView.layer.cornerRadius = 4
60 | contentView.backgroundColor = .white
61 | self.addSubview(contentView)
62 | contentView.translatesAutoresizingMaskIntoConstraints = false
63 |
64 | let data = DataSource(type: type)
65 |
66 | let titleLabel = UILabel()
67 | titleLabel.font = UIFont.systemFont(ofSize: scale(iPhone8Design: 17))
68 | titleLabel.textColor = .black
69 | titleLabel.text = "允许访问你的“\(data.title)”"
70 | contentView.addSubview(titleLabel)
71 | titleLabel.translatesAutoresizingMaskIntoConstraints = false
72 | titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: scale(iPhone8Design: 18)).isActive = true
73 | titleLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true
74 |
75 | let descriptionLabel = UILabel()
76 | descriptionLabel.font = UIFont.systemFont(ofSize: 16)
77 | descriptionLabel.textColor = .gray
78 | descriptionLabel.text = data.description
79 | descriptionLabel.textAlignment = .center
80 | descriptionLabel.numberOfLines = 0
81 | descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
82 | contentView.addSubview(descriptionLabel)
83 | descriptionLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: scale(iPhone8Design: 16)).isActive = true
84 | descriptionLabel.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: scale(iPhone8Design: 16)).isActive = true
85 | descriptionLabel.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: scale(iPhone8Design: -16)).isActive = true
86 | let textSize = (data.description as NSString).boundingRect(with: CGSize(width: scale(iPhone8Design: 250), height: CGFloat(MAXFLOAT)), options: [.truncatesLastVisibleLine, .usesDeviceMetrics
87 | , .usesFontLeading, .usesLineFragmentOrigin], attributes: [.font: UIFont.systemFont(ofSize: 16)], context: nil)
88 |
89 | let cancleButton = UIButton()
90 | cancleButton.translatesAutoresizingMaskIntoConstraints = false
91 | cancleButton.setTitle("NO", for: .normal)
92 | cancleButton.setTitleColor(.gray, for: .normal)
93 | cancleButton.titleLabel?.font = UIFont.systemFont(ofSize: scale(iPhone8Design: 16))
94 | cancleButton.addTarget(self, action: #selector(cancleButtonAction), for: .touchUpInside)
95 | contentView.addSubview(cancleButton)
96 |
97 | let okButton = UIButton()
98 | okButton.translatesAutoresizingMaskIntoConstraints = false
99 | okButton.setTitle("YES", for: .normal)
100 | okButton.setTitleColor(.black, for: .normal)
101 | okButton.titleLabel?.font = UIFont.systemFont(ofSize: scale(iPhone8Design: 16), weight: .medium)
102 | okButton.addTarget(self, action: #selector(okButtonAction), for: .touchUpInside)
103 | contentView.addSubview(okButton)
104 |
105 | cancleButton.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true
106 | cancleButton.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
107 | cancleButton.rightAnchor.constraint(equalTo: okButton.leftAnchor).isActive = true
108 | cancleButton.heightAnchor.constraint(equalToConstant: 44).isActive = true
109 | okButton.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
110 | okButton.rightAnchor.constraint(equalTo: contentView.rightAnchor).isActive = true
111 | okButton.widthAnchor.constraint(equalTo: cancleButton.widthAnchor).isActive = true
112 | okButton.heightAnchor.constraint(equalToConstant: 44).isActive = true
113 |
114 | contentView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
115 | contentView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
116 | contentView.heightAnchor.constraint(equalToConstant: scale(iPhone8Design: 118) + textSize.height).isActive = true
117 | contentView.widthAnchor.constraint(equalToConstant: scale(iPhone8Design: 282)).isActive = true
118 | }
119 |
120 | private func scale(iPhone8Design x: CGFloat) -> CGFloat {
121 | return x * UIScreen.main.bounds.width / 375.0
122 | }
123 |
124 | @objc private func okButtonAction() {
125 | hide()
126 | gotoSetting()
127 | }
128 |
129 | @objc private func cancleButtonAction() {
130 | hide()
131 | }
132 |
133 | private func hide() {
134 | UIView.animate(withDuration: 0.25, animations: {
135 | self.alpha = 0
136 | }) { (_) in
137 | self.removeFromSuperview()
138 | }
139 | }
140 |
141 | private let type: PermissionType
142 | }
143 |
144 | extension PermissionAlertView: PermissionAlertProtocol {
145 |
146 | func show() {
147 | let window = UIApplication.shared.keyWindow ?? UIWindow()
148 | window.addSubview(self)
149 | leftAnchor.constraint(equalTo: window.leftAnchor).isActive = true
150 | rightAnchor.constraint(equalTo: window.rightAnchor).isActive = true
151 | topAnchor.constraint(equalTo: window.topAnchor).isActive = true
152 | bottomAnchor.constraint(equalTo: window.bottomAnchor).isActive = true
153 | alpha = 0
154 | UIView.animate(withDuration: 0.25) {
155 | self.alpha = 1
156 | }
157 | }
158 | }
159 |
160 | extension PermissionAlertView {
161 | private struct DataSource {
162 | let title: String
163 | let description: String
164 |
165 | init(type: PermissionType) {
166 | switch type {
167 | case .calendar:
168 | self.init(title: "日历", description: infoDescription(for: "NSCalendarsUsageDescription"))
169 | case .reminder:
170 | self.init(title: "提醒事项", description: infoDescription(for: "NSRemindersUsageDescription"))
171 | case .camera:
172 | self.init(title: "相机", description: infoDescription(for: "NSCameraUsageDescription"))
173 | case .location(let type):
174 | let infoKey = type == .always ? "NSLocationAlwaysAndWhenInUseUsageDescription" : "NSLocationWhenInUseUsageDescription"
175 | self.init(title: "定位", description: infoDescription(for: infoKey))
176 | case .microphone:
177 | self.init(title: "麦克风", description: infoDescription(for: "NSMicrophoneUsageDescription"))
178 | case .notification:
179 | self.init(title: "通知", description: "开启通知更好的使用app")
180 | case .phonebook:
181 | self.init(title: "通讯录", description: infoDescription(for: "NSContactsUsageDescription"))
182 | case .photo:
183 | self.init(title: "照片", description: infoDescription(for: "NSPhotoLibraryUsageDescription"))
184 | }
185 | }
186 |
187 | private init(title: String, description: String) {
188 | self.title = title
189 | self.description = description
190 | }
191 | }
192 | }
193 |
194 | private func infoDescription(for infoKey: String) -> String {
195 | guard let infoDic = Bundle.main.infoDictionary,
196 | let description = infoDic[infoKey] as? String else {
197 | return "更好的使用app"
198 | }
199 | return description
200 | }
201 |
--------------------------------------------------------------------------------
/Sources/PermissionDirector.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PermissionDirector.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/22.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension PermissionDirector {
12 | /// 检查权限是否取得授权
13 | ///
14 | /// - Parameter type: 权限类型
15 | /// - Returns: 是否授权
16 | public static func isAuthorized(for type: PermissionType) -> Bool {
17 | return permissionFactory(for: type).status == .authorized
18 | }
19 |
20 | /// 弹出权限弹窗询问用户是否授权
21 | /// 若用户未决定此权限则唤起系统权限弹窗,若用户已拒绝此权限则跳入系统设置引导用户打开权限
22 | ///
23 | /// - Parameters:
24 | /// - type: 权限类型
25 | /// - completionHandler: 完成回调
26 | public static func requestAuthorization(for type: PermissionType, completionHandler: @escaping Handler) {
27 | permissionFactory(for: type).requestAuthorization(completionHandler: completionHandler)
28 | }
29 |
30 | /// 弹窗类型
31 | /// 自定义弹窗需提供一个遵循`PermissionAlertProtocol`的类型
32 | /// 默认弹窗类型为 `PermissionAlertView`
33 | public static var alertType: PermissionAlertProtocol.Type = PermissionAlertView.self
34 | }
35 |
36 | extension PermissionDirector {
37 | private static func permissionFactory(for type: PermissionType) -> PermissionProtocol {
38 | switch type {
39 | case .microphone:
40 | return MicrophonePermission()
41 | case .photo:
42 | return PhotoPermission()
43 | case .camera:
44 | return CameraPermission()
45 | case .location(let locationType):
46 | return LocationPermission(type: locationType)
47 | case .notification:
48 | return NotificationPermission()
49 | case .phonebook:
50 | return PhonebookPermission()
51 | case .calendar:
52 | return CalendarPermission(type: .event)
53 | case .reminder:
54 | return CalendarPermission(type: .reminder)
55 | }
56 | }
57 | }
58 |
59 | public struct PermissionDirector {
60 | private init() {}
61 | }
62 |
--------------------------------------------------------------------------------
/Sources/PermissionProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PermissionProtocol.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/22.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public typealias Handler = (PermissionResult) -> ()
12 |
13 | public enum PermissionType {
14 |
15 | public enum LocationType {
16 | case whenInUse, always, both
17 | }
18 |
19 | case microphone, photo, camera, notification, phonebook, calendar, reminder
20 | case location(LocationType)
21 | }
22 |
23 | public enum PermissionResult {
24 | case authorized, denied, unknow
25 | }
26 |
27 | enum PermissionStatus {
28 | case notDetermined, restricted, denied, authorized
29 | }
30 |
31 | protocol PermissionProtocol {
32 | var status: PermissionStatus { get }
33 | func requestAuthorization(completionHandler: @escaping Handler)
34 | }
35 |
--------------------------------------------------------------------------------
/Sources/Permissions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Permissions.swift
3 | // PermissionDirector
4 | //
5 | // Created by SoolyChristina on 2018/10/22.
6 | // Copyright © 2018 SoolyChristina. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import EventKit
11 | import AVFoundation
12 | import Contacts
13 | import UserNotifications
14 | import NotificationCenter
15 | import Photos
16 |
17 | struct MicrophonePermission: PermissionProtocol {
18 | var status: PermissionStatus {
19 | let status = AVAudioSession.sharedInstance().recordPermission
20 | switch status {
21 | case .denied:
22 | return .denied
23 | case .granted:
24 | return .authorized
25 | case .undetermined:
26 | return .notDetermined
27 | default:
28 | return .denied
29 | }
30 | }
31 |
32 | func requestAuthorization(completionHandler: @escaping Handler) {
33 | switch status {
34 | case .authorized:
35 | completionHandler(.authorized)
36 | case .denied, .restricted:
37 | let alert = PermissionDirector.alertType.init(type: .microphone)
38 | alert.show()
39 | completionHandler(.unknow)
40 | break
41 | case .notDetermined:
42 | AVAudioSession.sharedInstance().requestRecordPermission { (granted) in
43 | completionHandler(granted ? .authorized : .denied)
44 | }
45 | }
46 | }
47 | }
48 |
49 | struct PhotoPermission: PermissionProtocol {
50 | var status: PermissionStatus {
51 | let status = PHPhotoLibrary.authorizationStatus()
52 | switch status {
53 | case .authorized:
54 | return .authorized
55 | case .denied:
56 | return .denied
57 | case .notDetermined:
58 | return .notDetermined
59 | case .restricted:
60 | return .restricted
61 | default:
62 | return .denied
63 | }
64 | }
65 |
66 | func requestAuthorization(completionHandler: @escaping Handler) {
67 | switch status {
68 | case .authorized:
69 | completionHandler(.authorized)
70 | case .denied, .restricted:
71 | let alert = PermissionDirector.alertType.init(type: .photo)
72 | alert.show()
73 | completionHandler(.unknow)
74 | break
75 | case .notDetermined:
76 | PHPhotoLibrary.requestAuthorization { (status) in
77 | completionHandler(status == .authorized ? .authorized : .denied)
78 | }
79 | }
80 | }
81 | }
82 |
83 | struct CameraPermission: PermissionProtocol {
84 | var status: PermissionStatus {
85 | let status = AVCaptureDevice.authorizationStatus(for: .video)
86 | switch status {
87 | case .denied:
88 | return .denied
89 | case .restricted:
90 | return .restricted
91 | case .notDetermined:
92 | return .notDetermined
93 | case .authorized:
94 | return .authorized
95 | default:
96 | return .denied
97 | }
98 | }
99 |
100 | func requestAuthorization(completionHandler: @escaping Handler) {
101 | switch status {
102 | case .authorized:
103 | completionHandler(.authorized)
104 | case .denied, .restricted:
105 | let alert = PermissionDirector.alertType.init(type: .camera)
106 | alert.show()
107 | completionHandler(.unknow)
108 | break
109 | case .notDetermined:
110 | AVCaptureDevice.requestAccess(for: .video) { (granted) in
111 | granted ? completionHandler(.authorized) : completionHandler(.denied)
112 | }
113 | }
114 | }
115 | }
116 |
117 | struct LocationPermission: PermissionProtocol {
118 | init(type: PermissionType.LocationType) {
119 | self.type = type
120 | }
121 |
122 | var status: PermissionStatus {
123 | let status = CLLocationManager.authorizationStatus()
124 | switch status {
125 | case .denied:
126 | return .denied
127 | case .notDetermined:
128 | return .notDetermined
129 | case .authorizedAlways:
130 | return (type == .always || type == .both) ? .authorized : .denied
131 | case .authorizedWhenInUse:
132 | return (type == .whenInUse || type == .both) ? .authorized : .denied
133 | case .restricted:
134 | return .restricted
135 | default:
136 | return .denied
137 | }
138 | }
139 |
140 | func requestAuthorization(completionHandler: @escaping Handler) {
141 | switch status {
142 | case .authorized:
143 | completionHandler(.authorized)
144 | case .denied, .restricted:
145 | let alert = PermissionDirector.alertType.init(type: .location(type))
146 | alert.show()
147 | completionHandler(.unknow)
148 | break
149 | case .notDetermined:
150 | type == .always ? locationManager.requestAlwaysAuthorization() : locationManager.requestWhenInUseAuthorization()
151 | }
152 | }
153 |
154 | private let type: PermissionType.LocationType
155 | }
156 |
157 | private let locationManager = CLLocationManager()
158 |
159 | struct NotificationPermission: PermissionProtocol {
160 | var status: PermissionStatus {
161 | if #available(iOS 10.0, *) {
162 | var status = UNAuthorizationStatus.denied
163 | let sm = DispatchSemaphore(value: 0)
164 | UNUserNotificationCenter.current().getNotificationSettings { (settings) in
165 | status = settings.authorizationStatus
166 | sm.signal()
167 | }
168 | _ = sm.wait(timeout: .now() + 10)
169 |
170 | switch status {
171 | case .authorized:
172 | return .authorized
173 | case .denied, .provisional:
174 | return .denied
175 | case .notDetermined:
176 | return .notDetermined
177 | default:
178 | return .denied
179 | }
180 | } else {
181 | return .notDetermined
182 | }
183 | }
184 |
185 | func requestAuthorization(completionHandler: @escaping Handler) {
186 | switch status {
187 | case .authorized:
188 | completionHandler(.authorized)
189 | case .denied, .restricted:
190 | let alert = PermissionDirector.alertType.init(type: .notification)
191 | alert.show()
192 | completionHandler(.unknow)
193 | break
194 | case .notDetermined:
195 | if #available(iOS 10.0, *) {
196 | UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
197 | granted ? completionHandler(.authorized) : completionHandler(.denied)
198 | }
199 | } else {
200 | let settings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil)
201 | UIApplication.shared.registerUserNotificationSettings(settings)
202 | UIApplication.shared.registerForRemoteNotifications()
203 | }
204 | }
205 | }
206 | }
207 |
208 | struct PhonebookPermission: PermissionProtocol {
209 | var status: PermissionStatus {
210 | let status = CNContactStore .authorizationStatus(for: .contacts)
211 | switch status {
212 | case .denied:
213 | return .denied
214 | case .authorized:
215 | return .authorized
216 | case .notDetermined:
217 | return .notDetermined
218 | case .restricted:
219 | return .restricted
220 | default:
221 | return .denied
222 | }
223 | }
224 |
225 | func requestAuthorization(completionHandler: @escaping Handler) {
226 | switch status {
227 | case .authorized:
228 | completionHandler(.authorized)
229 | case .denied, .restricted:
230 | let alert = PermissionDirector.alertType.init(type: .phonebook)
231 | alert.show()
232 | completionHandler(.unknow)
233 | break
234 | case .notDetermined:
235 | let store = CNContactStore()
236 | store.requestAccess(for: .contacts) { (granted, _) in
237 | granted ? completionHandler(.authorized) : completionHandler(.denied)
238 | }
239 | }
240 | }
241 | }
242 |
243 | struct CalendarPermission: PermissionProtocol {
244 | init(type: EKEntityType) {
245 | self.type = type
246 | }
247 |
248 | var status: PermissionStatus {
249 | let status = EKEventStore.authorizationStatus(for: type)
250 | switch status {
251 | case .denied:
252 | return .denied
253 | case .authorized:
254 | return .authorized
255 | case .restricted:
256 | return .restricted
257 | case .notDetermined:
258 | return .notDetermined
259 | default:
260 | return .denied
261 | }
262 | }
263 |
264 | func requestAuthorization(completionHandler: @escaping Handler) {
265 | switch status {
266 | case .authorized:
267 | completionHandler(.authorized)
268 | case .denied, .restricted:
269 | let alert = PermissionDirector.alertType.init(type: .calendar)
270 | alert.show()
271 | completionHandler(.unknow)
272 | break
273 | case .notDetermined:
274 | let store = EKEventStore()
275 | store.requestAccess(to: type) { (granted, _) in
276 | granted ? completionHandler(.authorized) : completionHandler(.denied)
277 | }
278 | }
279 | }
280 |
281 | private let type: EKEntityType
282 | }
283 |
--------------------------------------------------------------------------------
/Tests/LinuxMain.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 |
3 | import PermissionDirectorTests
4 |
5 | var tests = [XCTestCaseEntry]()
6 | tests += PermissionDirectorTests.allTests()
7 | XCTMain(tests)
8 |
--------------------------------------------------------------------------------
/Tests/PermissionDirectorTests/PermissionDirectorTests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | @testable import PermissionDirector
3 |
4 | final class PermissionDirectorTests: XCTestCase {
5 | func testExample() {
6 | // This is an example of a functional test case.
7 | // Use XCTAssert and related functions to verify your tests produce the correct
8 | // results.
9 | XCTAssertEqual(PermissionDirector().text, "Hello, World!")
10 | }
11 |
12 | static var allTests = [
13 | ("testExample", testExample),
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/Tests/PermissionDirectorTests/XCTestManifests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 |
3 | #if !canImport(ObjectiveC)
4 | public func allTests() -> [XCTestCaseEntry] {
5 | return [
6 | testCase(PermissionDirectorTests.allTests),
7 | ]
8 | }
9 | #endif
10 |
--------------------------------------------------------------------------------
/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoolyChristy/PermissionDirector/906e1d805260cfde2b279e34ff2a43c0ac69ce40/logo.jpg
--------------------------------------------------------------------------------
/shortcut.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoolyChristy/PermissionDirector/906e1d805260cfde2b279e34ff2a43c0ac69ce40/shortcut.gif
--------------------------------------------------------------------------------