├── UIImagePlusPDF
├── dora.pdf
├── Assets.xcassets
│ ├── Contents.json
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── ViewController.swift
├── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.storyboard
└── AppDelegate.swift
├── UIImagePlusPDFTests
├── cat.pdf
├── Info.plist
└── UIImagePlusPDFTests.swift
├── UIImagePlusPDF.xcodeproj
├── project.xcworkspace
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── project.pbxproj
├── UIImagePlusPDF.podspec
├── LICENSE
├── README.md
└── UIImage+PDF
└── UIImage+PDF.swift
/UIImagePlusPDF/dora.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaMishchenko/UIImagePlusPDF/HEAD/UIImagePlusPDF/dora.pdf
--------------------------------------------------------------------------------
/UIImagePlusPDFTests/cat.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaMishchenko/UIImagePlusPDF/HEAD/UIImagePlusPDFTests/cat.pdf
--------------------------------------------------------------------------------
/UIImagePlusPDF/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/UIImagePlusPDF.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/UIImagePlusPDF.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'UIImagePlusPDF'
3 | s.version = '1.2.0'
4 | s.summary = 'UIImage PDF extensions'
5 |
6 | s.description = <<-DESC
7 | UIImage PDF extensions.
8 | DESC
9 |
10 | s.homepage = 'https://github.com/DimaMishchenko/UIImagePlusPDF'
11 | s.license = { :type => 'MIT', :file => 'LICENSE' }
12 | s.author = { 'Dima Mishchenko' => 'narmdv5@gmail.com' }
13 | s.source = { :git => 'https://github.com/DimaMishchenko/UIImagePlusPDF.git', :tag => s.version.to_s }
14 |
15 | s.ios.deployment_target = '9.0'
16 | s.source_files = 'UIImage+PDF/*'
17 | s.swift_version = '5.0'
18 |
19 | end
--------------------------------------------------------------------------------
/UIImagePlusPDFTests/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 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 DimaMishchenko
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/UIImagePlusPDF/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 | $(MARKETING_VERSION)
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
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 |
--------------------------------------------------------------------------------
/UIImagePlusPDF/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // UIImagePlusPDF
4 | //
5 | // Created by Dima Mishchenko on 16.05.2018.
6 | // Copyright © 2018 Dima. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | view.backgroundColor = .systemTeal
17 |
18 | /**
19 | * Caching options:
20 | *
21 | * - Memory: UIImage.pdfCacheInMemory = true
22 | * - Disk: UIImage.pdfCacheOnDisk = true
23 | */
24 |
25 | guard let image = UIImage.pdfImage(with: "dora", width: 350) else { return }
26 |
27 | /**
28 | * Other options:
29 | *
30 | * - Original PDF size: UIImage.pdfImage(with: "dora")
31 | *
32 | * - With custom width: UIImage.pdfImage(with: "dora", width: 350)
33 | *
34 | * - With custom height: UIImage.pdfImage(with: "dora", height: 350)
35 | *
36 | * - With custom size: UIImage.pdfImage(with: "dora", size: CGSize(width: 300, height: 400))
37 | *
38 | * - With page number: UIImage.pdfImage(with: "multipage pdf file", width: 300, pageNumber: 2)
39 | *
40 | * - Same with resource url: UIImage.pdfImage(with: URL(string: "path"))
41 | *
42 | */
43 |
44 | let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
45 | imageView.image = image
46 | imageView.center = view.center
47 | view.addSubview(imageView)
48 | }
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/UIImagePlusPDF/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/UIImagePlusPDF/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 |
--------------------------------------------------------------------------------
/UIImagePlusPDF/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 | }
--------------------------------------------------------------------------------
/UIImagePlusPDF/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // UIImagePlusPDF
4 | //
5 | // Created by Dima Mishchenko on 16.05.2018.
6 | // Copyright © 2018 Dima. 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 |
--------------------------------------------------------------------------------
/UIImagePlusPDFTests/UIImagePlusPDFTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UIImagePlusPDFTests.swift
3 | // UIImagePlusPDFTests
4 | //
5 | // Created by Dima Mishchenko on 16.05.2018.
6 | // Copyright © 2018 Dima. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import UIImagePlusPDF
11 |
12 | class UIImagePlusPDFTests: XCTestCase {
13 |
14 | func testImageWithName() {
15 | // given
16 | let imageName = "cat"
17 | let size: CGFloat = 69
18 |
19 | // when
20 | let imageDefault = UIImage.pdfImage(with: imageName)
21 | let imageWithWidth = UIImage.pdfImage(with: imageName, width: size)
22 | let imageWithHeight = UIImage.pdfImage(with: imageName, height: size)
23 | let imageWithSize = UIImage.pdfImage(with: imageName, size: CGSize(width: size, height: size))
24 | let imageWithPDFSize = UIImage.pdfImage(with: imageName, size: .default)
25 |
26 | // then
27 | XCTAssertNotNil(imageDefault)
28 |
29 | XCTAssertNotNil(imageWithWidth)
30 | XCTAssertEqual(imageWithWidth?.size.width, size)
31 |
32 | XCTAssertNotNil(imageWithHeight)
33 | XCTAssertEqual(imageWithWidth?.size.height, size)
34 |
35 | XCTAssertNotNil(imageWithSize)
36 | XCTAssertEqual(imageWithWidth?.size, CGSize(width: size, height: size))
37 |
38 | XCTAssertNotNil(imageWithPDFSize)
39 | }
40 |
41 | func testImageWithURL() {
42 | // given
43 | guard let imageURL = Bundle.main.url(forResource: "cat", withExtension: "pdf") else { XCTFail(); return }
44 | let size: CGFloat = 69
45 |
46 | // when
47 | let imageDefault = UIImage.pdfImage(with: imageURL)
48 | let imageWithWidth = UIImage.pdfImage(with: imageURL, width: size)
49 | let imageWithHeight = UIImage.pdfImage(with: imageURL, height: size)
50 | let imageWithSize = UIImage.pdfImage(with: imageURL, size: CGSize(width: size, height: size))
51 | let imageWithPDFSize = UIImage.pdfImage(with: imageURL, size: .default)
52 |
53 | // then
54 | XCTAssertNotNil(imageDefault)
55 |
56 | XCTAssertNotNil(imageWithWidth)
57 | XCTAssertEqual(imageWithWidth?.size.width, size)
58 |
59 | XCTAssertNotNil(imageWithHeight)
60 | XCTAssertEqual(imageWithWidth?.size.height, size)
61 |
62 | XCTAssertNotNil(imageWithSize)
63 | XCTAssertEqual(imageWithWidth?.size, CGSize(width: size, height: size))
64 |
65 | XCTAssertNotNil(imageWithPDFSize)
66 | }
67 |
68 | func testImageWithZeroSize() {
69 | // given
70 | let imageName = "cat"
71 |
72 | // when
73 | let image = UIImage.pdfImage(with: imageName, size: .zero)
74 |
75 | // then
76 | XCTAssertNil(image)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UIImagePlusPDF
2 | [](https://developer.apple.com/swift/)
3 | [](https://cocoapods.org/pods/UIImagePlusPDF)
4 | []()
5 |
6 | UIImage extensions to use PDF files.
7 | Using `UIImagePlusPDF` you can avoid a lot `png` images files (1x, 2x, 3x sizes) and simply replace each of them with only one `pdf` file.
8 |
9 | ## Installation
10 |
11 | [CocoaPods](http://www.cocoapods.org):
12 |
13 | ``` ruby
14 | pod 'UIImagePlusPDF'
15 | ```
16 |
17 | ``` swift
18 | import UIImagePlusPDF
19 | ```
20 |
21 | ## Usage
22 | **Simple example:**
23 | ``` swift
24 | let imageView = UIImageView()
25 | let image = UIImage.pdfImage(with: "imageName")
26 | imageView.image = image
27 | ```
28 | **Other options**
29 | ``` swift
30 | //with custom width
31 | UIImage.pdfImage(with: "imageName", width: 350)
32 |
33 | //with custom height
34 | UIImage.pdfImage(with: "imageName", height: 350)
35 |
36 | //with custom size
37 | UIImage.pdfImage(with: "imageName", size: CGSize(width: 300, height: 400))
38 |
39 | //with page number
40 | UIImage.pdfImage(with: "multipage pdf file", width: 300, pageNumber: 2)
41 |
42 | //same options with resource url
43 | UIImage.pdfImage(with: URL(string: "path"))
44 | ```
45 |
46 | ## Cache
47 | **Memory cache:**
48 | ``` swift
49 | //using NSCache
50 | //default is true
51 | UIImage.pdfCacheInMemory = true
52 | ```
53 | **Disk cache:**
54 | ``` swift
55 | //default is false
56 | UIImage.pdfCacheOnDisk = true
57 | ```
58 | **Cache deleting:**
59 | ``` swift
60 | //all cache
61 | UIImage.removeAllPDFCache()
62 |
63 | //all memory cache
64 | UIImage.removeAllPDFMemoryCache()
65 |
66 | //all disk cache
67 | UIImage.removeAllPDFDiskCache()
68 |
69 | //memory cached pdf with name
70 | UIImage.removeMemoryCachedPDFImage(
71 | with: "pdf name",
72 | size: imageSize,
73 | pageNumber: 1 /*optional, default is 1*/
74 | )
75 |
76 | //memory cached pdf with url
77 | UIImage.removeMemoryCachedPDFImage(
78 | with: URL(string: "path"),
79 | size: imageSize,
80 | pageNumber: 1 /*optional, default is 1*/
81 | )
82 |
83 | //disk cached pdf with name
84 | UIImage.removeDiskCachedPDFImage(
85 | with: "pdf name",
86 | size: imageSize,
87 | pageNumber: 1 /*optional, default is 1*/
88 | )
89 |
90 | //disk cached pdf with url
91 | UIImage.removeDiskCachedPDFImage(
92 | with: URL(string: "path"),
93 | size: imageSize,
94 | pageNumber: 1 /*optional, default is 1*/
95 | )
96 | ```
97 | ## License
98 | **UIImagePlusPDF** is under MIT license. See the [LICENSE](LICENSE) file for more info.
99 |
--------------------------------------------------------------------------------
/UIImage+PDF/UIImage+PDF.swift:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2018 DimaMishchenko
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | */
23 |
24 | import UIKit
25 | import Foundation
26 |
27 | // MARK: - UIImage+PDF
28 |
29 | public extension UIImage {
30 |
31 | static func pdfImage(with name: String, size: PDFImageSize, pageNumber: Int = 1) -> UIImage? {
32 |
33 | guard let url = resourceURLForName(name) else { return nil }
34 | return _pdfImage(with: url, size: size, pageNumber: pageNumber)
35 | }
36 |
37 | static func pdfImage(with name: String, width: CGFloat, pageNumber: Int = 1) -> UIImage? {
38 |
39 | guard let url = resourceURLForName(name) else { return nil }
40 | return _pdfImage(with: url, size: .customWidth(width), pageNumber: pageNumber)
41 | }
42 |
43 | static func pdfImage(with name: String, height: CGFloat, pageNumber: Int = 1) -> UIImage? {
44 |
45 | guard let url = resourceURLForName(name) else { return nil }
46 | return _pdfImage(with: url, size: .customHeight(height), pageNumber: pageNumber)
47 | }
48 |
49 | static func pdfImage(with name: String, pageNumber: Int = 1) -> UIImage? {
50 |
51 | guard let url = resourceURLForName(name) else { return nil }
52 | return _pdfImage(with: url, size: .default, pageNumber: pageNumber)
53 | }
54 |
55 | static func pdfImage(with name: String, size: CGSize, pageNumber: Int = 1) -> UIImage? {
56 |
57 | guard let url = resourceURLForName(name) else { return nil }
58 | return _pdfImage(with: url, size: .custom(size), pageNumber: pageNumber)
59 | }
60 |
61 | static func pdfImage(with url: URL, size: PDFImageSize, pageNumber: Int = 1) -> UIImage? {
62 |
63 | return _pdfImage(with:url, size: size, pageNumber: pageNumber)
64 | }
65 |
66 | static func pdfImage(with url: URL, width: CGFloat, pageNumber: Int = 1) -> UIImage? {
67 |
68 | return _pdfImage(with: url, size: .customWidth(width), pageNumber: pageNumber)
69 | }
70 |
71 | static func pdfImage(with url: URL, height: CGFloat, pageNumber: Int = 1) -> UIImage? {
72 |
73 | return _pdfImage(with: url, size: .customHeight(height), pageNumber: pageNumber)
74 | }
75 |
76 | static func pdfImage(with url: URL, pageNumber: Int = 1) -> UIImage? {
77 |
78 | return _pdfImage(with: url, size: .default, pageNumber: pageNumber)
79 | }
80 |
81 | static func pdfImage(with url: URL, size: CGSize, pageNumber: Int = 1) -> UIImage? {
82 |
83 | return _pdfImage(with:url, size: .custom(size), pageNumber: pageNumber)
84 | }
85 | }
86 |
87 | // MARK: - ImageSize
88 |
89 | extension UIImage {
90 |
91 | public enum PDFImageSize {
92 | case `default`
93 | case custom(CGSize)
94 | case customWidth(CGFloat)
95 | case customHeight(CGFloat)
96 | }
97 | }
98 |
99 | // MARK: - Private
100 |
101 | extension UIImage {
102 |
103 | private static func _pdfImage(with url: URL, size: PDFImageSize, pageNumber: Int) -> UIImage? {
104 |
105 | guard
106 | let pdf = CGPDFDocument(url as CFURL),
107 | let page = pdf.page(at: pageNumber)
108 | else { return nil }
109 |
110 | let size = pdfSize(
111 | withOrginalSize: page.getBoxRect(.mediaBox).size,
112 | selectedSize: size
113 | )
114 |
115 | if pdfCacheInMemory, let image = memoryCachedImage(url: url, size: size, pageNumber: pageNumber) {
116 | return image
117 | }
118 |
119 | guard
120 | let imageUrl = pdfCacheOnDisk ? pdfCacheURL(with: url, size: size, pageNumber: pageNumber) : url
121 | else { return nil }
122 |
123 | if
124 | pdfCacheOnDisk,
125 | FileManager.default.fileExists(atPath: imageUrl.path),
126 | let image = UIImage(contentsOfFile: imageUrl.path),
127 | let cgImage = image.cgImage {
128 |
129 | return UIImage(cgImage: cgImage, scale: UIScreen.main.scale, orientation: .up)
130 | }
131 |
132 | UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)
133 |
134 | guard let context = UIGraphicsGetCurrentContext() else { return nil }
135 |
136 | context.concatenate(CGAffineTransform(a: 1, b: .zero, c: .zero, d: -1, tx: .zero, ty: size.height))
137 | let rect = page.getBoxRect(.mediaBox)
138 | context.translateBy(x: -rect.origin.x, y: -rect.origin.y)
139 | context.scaleBy(x: size.width / rect.size.width, y: size.height / rect.size.height)
140 | context.drawPDFPage(page)
141 | let imageFromContext = UIGraphicsGetImageFromCurrentImageContext()
142 | UIGraphicsEndImageContext()
143 |
144 | guard
145 | let image = imageFromContext,
146 | let imageData = image.pngData(),
147 | let cgImage = image.cgImage
148 | else { return nil }
149 |
150 | if pdfCacheOnDisk { cacheOnDisk(data: imageData, url: imageUrl) }
151 | if pdfCacheInMemory { cacheImageInMemory(image, url: url, size: size, pageNumber: pageNumber) }
152 |
153 | return UIImage(cgImage: cgImage, scale: UIScreen.main.scale, orientation: .up)
154 | }
155 |
156 | private static func resourceURLForName(_ resourceName: String) -> URL? {
157 |
158 | let isSuffix = resourceName.lowercased().hasSuffix(".pdf")
159 | let name = isSuffix ? resourceName : resourceName + ".pdf"
160 |
161 | if let path = Bundle.main.path(forResource: name, ofType: nil) {
162 | return URL(fileURLWithPath: path)
163 | }
164 |
165 | return nil
166 | }
167 |
168 | private static func pdfSize(with url: URL, size: PDFImageSize, pageNumber: Int) -> CGSize? {
169 |
170 | guard
171 | let pdf = CGPDFDocument(url as CFURL),
172 | let page = pdf.page(at: pageNumber)
173 | else { return nil }
174 |
175 | return pdfSize(
176 | withOrginalSize: page.getBoxRect(.mediaBox).size,
177 | selectedSize: size
178 | )
179 | }
180 |
181 | private static func pdfSize(withOrginalSize orginalSize: CGSize, selectedSize: PDFImageSize) -> CGSize {
182 | switch selectedSize {
183 | case .default:
184 | return orginalSize
185 | case .custom(let size):
186 | return size
187 | case .customWidth(let width):
188 | let multiplier = width / orginalSize.width
189 | return CGSize(
190 | width: ceil(orginalSize.width * multiplier),
191 | height: ceil(orginalSize.height * multiplier)
192 | )
193 | case .customHeight(let height):
194 | let multiplier = height / orginalSize.height
195 |
196 | return CGSize(
197 | width: ceil(orginalSize.width * multiplier),
198 | height: ceil(orginalSize.height * multiplier)
199 | )
200 | }
201 | }
202 | }
203 |
204 | // MARK: - Cache Public
205 |
206 | public extension UIImage {
207 |
208 | static var pdfCacheOnDisk = false
209 | static var pdfCacheInMemory = true
210 |
211 | //all
212 |
213 | static func removeAllPDFCache() {
214 |
215 | removeAllPDFDiskCache()
216 | removeAllPDFMemoryCache()
217 | }
218 |
219 | static func removeAllPDFMemoryCache() {
220 |
221 | imageCache.removeAllObjects()
222 | }
223 |
224 | static func removeAllPDFDiskCache() {
225 |
226 | let cacheDirectory = NSSearchPathForDirectoriesInDomains(
227 | .cachesDirectory,
228 | .userDomainMask,
229 | true
230 | )[.zero] + "/" + kDiskCacheFolderName
231 |
232 | try? FileManager.default.removeItem(atPath: cacheDirectory)
233 | }
234 |
235 | //memory
236 |
237 | static func removeMemoryCachedPDFImage(with name: String, size: PDFImageSize, pageNumber: Int = 1) {
238 |
239 | guard let url = resourceURLForName(name) else { return }
240 | removeMemoryCachedPDFImage(with: url, size: size, pageNumber: pageNumber)
241 | }
242 |
243 | static func removeMemoryCachedPDFImage(with url: URL, size: PDFImageSize, pageNumber: Int = 1) {
244 |
245 | guard
246 | let size = pdfSize(with: url, size: size, pageNumber: pageNumber),
247 | let hash = pdfCacheHashString(with: url, size: size, pageNumber: pageNumber)
248 | else { return }
249 |
250 | imageCache.removeObject(forKey: NSString(string: String(hash)))
251 | }
252 |
253 | @available(*, deprecated, renamed: "removeMemoryCachedPDFImage(with:size:pageNumber:)")
254 | static func removeMemoryCachedPDFImage(with name: String, size: CGSize, pageNumber: Int = 1) {
255 |
256 | guard let url = resourceURLForName(name) else { return }
257 | removeMemoryCachedPDFImage(with: url, size: size, pageNumber: pageNumber)
258 | }
259 |
260 | @available(*, deprecated, renamed: "removeMemoryCachedPDFImage(with:size:pageNumber:)")
261 | static func removeMemoryCachedPDFImage(with url: URL, size: CGSize, pageNumber: Int = 1) {
262 |
263 | guard
264 | let size = pdfSize(with: url, size: .custom(size), pageNumber: pageNumber),
265 | let hash = pdfCacheHashString(with: url, size: size, pageNumber: pageNumber)
266 | else { return }
267 |
268 | imageCache.removeObject(forKey: NSString(string: String(hash)))
269 | }
270 |
271 | //disk
272 |
273 | static func removeDiskCachedPDFImage(with name: String, size: PDFImageSize, pageNumber: Int = 1) {
274 |
275 | guard let url = resourceURLForName(name) else { return }
276 | removeDiskCachedPDFImage(with: url, size: size, pageNumber: pageNumber)
277 | }
278 |
279 | static func removeDiskCachedPDFImage(with url: URL, size: PDFImageSize, pageNumber: Int = 1) {
280 |
281 | guard
282 | let size = pdfSize(with: url, size: size, pageNumber: pageNumber),
283 | let imageUrl = pdfCacheURL(with: url, size: size, pageNumber: pageNumber)
284 | else { return }
285 |
286 | try? FileManager.default.removeItem(at: imageUrl)
287 | }
288 |
289 | @available(*, deprecated, renamed: "removeDiskCachedPDFImage(with:size:pageNumber:)")
290 | static func removeDiskCachedPDFImage(with name: String, size: CGSize, pageNumber: Int = 1) {
291 |
292 | guard let url = resourceURLForName(name) else { return }
293 | removeDiskCachedPDFImage(with: url, size: size, pageNumber: pageNumber)
294 | }
295 |
296 | @available(*, deprecated, renamed: "removeDiskCachedPDFImage(with:size:pageNumber:)")
297 | static func removeDiskCachedPDFImage(with url: URL, size: CGSize, pageNumber: Int = 1) {
298 |
299 | guard
300 | let size = pdfSize(with: url, size: .custom(size), pageNumber: pageNumber),
301 | let imageUrl = pdfCacheURL(with: url, size: size, pageNumber: pageNumber)
302 | else { return }
303 |
304 | try? FileManager.default.removeItem(at: imageUrl)
305 | }
306 | }
307 |
308 | // MARK: - Cache Private
309 |
310 | extension UIImage {
311 |
312 | // MARK: - Memory Cache
313 |
314 | private static let imageCache = NSCache()
315 |
316 | private static func cacheImageInMemory(_ image: UIImage, url: URL, size: CGSize, pageNumber: Int) {
317 |
318 | guard let hash = pdfCacheHashString(with: url, size: size, pageNumber: pageNumber) else { return }
319 | imageCache.setObject(image, forKey: NSString(string: String(hash)))
320 | }
321 |
322 | private static func memoryCachedImage(url: URL, size: CGSize, pageNumber: Int) -> UIImage? {
323 |
324 | guard let hash = pdfCacheHashString(with: url, size: size, pageNumber: pageNumber) else { return nil }
325 | return imageCache.object(forKey: NSString(string: String(hash)))
326 | }
327 |
328 | // MARK: - Disk Cache
329 |
330 | private static let kDiskCacheFolderName = "PDFCache"
331 |
332 | private static func cacheOnDisk(data: Data, url: URL) {
333 |
334 | try? data.write(to: url, options: [])
335 | }
336 |
337 | private static func pdfCacheURL(with url: URL, size: CGSize, pageNumber: Int) -> URL? {
338 |
339 | do {
340 | guard let hash = pdfCacheHashString(with: url, size: size, pageNumber: pageNumber) else { return nil }
341 |
342 | let cacheDirectory = NSSearchPathForDirectoriesInDomains(
343 | .cachesDirectory,
344 | .userDomainMask,
345 | true
346 | )[.zero] + "/" + kDiskCacheFolderName
347 |
348 | try FileManager.default.createDirectory(
349 | atPath: cacheDirectory,
350 | withIntermediateDirectories: true,
351 | attributes: nil
352 | )
353 |
354 | return URL(fileURLWithPath: cacheDirectory + "/" + String(format:"%2X", hash) + ".png")
355 |
356 | } catch { return nil }
357 | }
358 |
359 | private static func pdfCacheHashString(with url: URL, size: CGSize, pageNumber: Int) -> Int? {
360 |
361 | guard
362 | let attributes = try? FileManager.default.attributesOfItem(atPath: url.path),
363 | let fileSize = attributes[.size] as? NSNumber,
364 | let fileDate = attributes[.modificationDate] as? Date
365 | else { return nil }
366 |
367 | let hashables =
368 | url.path +
369 | fileSize.stringValue +
370 | String(fileDate.timeIntervalSince1970) +
371 | String(describing: size) +
372 | String(describing: pageNumber)
373 |
374 | return hashables.hash
375 | }
376 | }
377 |
--------------------------------------------------------------------------------
/UIImagePlusPDF.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 96197AFA20AC63FE000A0C3C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96197AF920AC63FE000A0C3C /* AppDelegate.swift */; };
11 | 96197AFC20AC63FE000A0C3C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96197AFB20AC63FE000A0C3C /* ViewController.swift */; };
12 | 96197AFF20AC63FE000A0C3C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96197AFD20AC63FE000A0C3C /* Main.storyboard */; };
13 | 96197B0120AC6401000A0C3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96197B0020AC6401000A0C3C /* Assets.xcassets */; };
14 | 96197B0420AC6401000A0C3C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96197B0220AC6401000A0C3C /* LaunchScreen.storyboard */; };
15 | 96197B0F20AC6402000A0C3C /* UIImagePlusPDFTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96197B0E20AC6402000A0C3C /* UIImagePlusPDFTests.swift */; };
16 | 96197B1B20AC6431000A0C3C /* UIImage+PDF.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96197B1A20AC6431000A0C3C /* UIImage+PDF.swift */; };
17 | 96197B1D20AC6B41000A0C3C /* cat.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 96197B1C20AC6B41000A0C3C /* cat.pdf */; };
18 | 96DFF67220AEE5A800468D4F /* dora.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 96DFF67120AEE5A700468D4F /* dora.pdf */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXContainerItemProxy section */
22 | 96197B0B20AC6402000A0C3C /* PBXContainerItemProxy */ = {
23 | isa = PBXContainerItemProxy;
24 | containerPortal = 96197AEE20AC63FE000A0C3C /* Project object */;
25 | proxyType = 1;
26 | remoteGlobalIDString = 96197AF520AC63FE000A0C3C;
27 | remoteInfo = UIImagePlusPDF;
28 | };
29 | /* End PBXContainerItemProxy section */
30 |
31 | /* Begin PBXFileReference section */
32 | 96197AF620AC63FE000A0C3C /* UIImagePlusPDF.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIImagePlusPDF.app; sourceTree = BUILT_PRODUCTS_DIR; };
33 | 96197AF920AC63FE000A0C3C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
34 | 96197AFB20AC63FE000A0C3C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
35 | 96197AFE20AC63FE000A0C3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
36 | 96197B0020AC6401000A0C3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
37 | 96197B0320AC6401000A0C3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
38 | 96197B0520AC6401000A0C3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 96197B0A20AC6402000A0C3C /* UIImagePlusPDFTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIImagePlusPDFTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
40 | 96197B0E20AC6402000A0C3C /* UIImagePlusPDFTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImagePlusPDFTests.swift; sourceTree = ""; };
41 | 96197B1020AC6402000A0C3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
42 | 96197B1A20AC6431000A0C3C /* UIImage+PDF.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+PDF.swift"; sourceTree = ""; };
43 | 96197B1C20AC6B41000A0C3C /* cat.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = cat.pdf; sourceTree = ""; };
44 | 96DFF67120AEE5A700468D4F /* dora.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = dora.pdf; sourceTree = ""; };
45 | /* End PBXFileReference section */
46 |
47 | /* Begin PBXFrameworksBuildPhase section */
48 | 96197AF320AC63FE000A0C3C /* Frameworks */ = {
49 | isa = PBXFrameworksBuildPhase;
50 | buildActionMask = 2147483647;
51 | files = (
52 | );
53 | runOnlyForDeploymentPostprocessing = 0;
54 | };
55 | 96197B0720AC6402000A0C3C /* Frameworks */ = {
56 | isa = PBXFrameworksBuildPhase;
57 | buildActionMask = 2147483647;
58 | files = (
59 | );
60 | runOnlyForDeploymentPostprocessing = 0;
61 | };
62 | /* End PBXFrameworksBuildPhase section */
63 |
64 | /* Begin PBXGroup section */
65 | 96197AED20AC63FE000A0C3C = {
66 | isa = PBXGroup;
67 | children = (
68 | 96197B1920AC6423000A0C3C /* UIImage+PDF */,
69 | 96197AF820AC63FE000A0C3C /* UIImagePlusPDF */,
70 | 96197B0D20AC6402000A0C3C /* UIImagePlusPDFTests */,
71 | 96197AF720AC63FE000A0C3C /* Products */,
72 | );
73 | sourceTree = "";
74 | };
75 | 96197AF720AC63FE000A0C3C /* Products */ = {
76 | isa = PBXGroup;
77 | children = (
78 | 96197AF620AC63FE000A0C3C /* UIImagePlusPDF.app */,
79 | 96197B0A20AC6402000A0C3C /* UIImagePlusPDFTests.xctest */,
80 | );
81 | name = Products;
82 | sourceTree = "";
83 | };
84 | 96197AF820AC63FE000A0C3C /* UIImagePlusPDF */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 96DFF67120AEE5A700468D4F /* dora.pdf */,
88 | 96197AF920AC63FE000A0C3C /* AppDelegate.swift */,
89 | 96197AFB20AC63FE000A0C3C /* ViewController.swift */,
90 | 96197AFD20AC63FE000A0C3C /* Main.storyboard */,
91 | 96197B0020AC6401000A0C3C /* Assets.xcassets */,
92 | 96197B0220AC6401000A0C3C /* LaunchScreen.storyboard */,
93 | 96197B0520AC6401000A0C3C /* Info.plist */,
94 | );
95 | path = UIImagePlusPDF;
96 | sourceTree = "";
97 | };
98 | 96197B0D20AC6402000A0C3C /* UIImagePlusPDFTests */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 96197B1C20AC6B41000A0C3C /* cat.pdf */,
102 | 96197B0E20AC6402000A0C3C /* UIImagePlusPDFTests.swift */,
103 | 96197B1020AC6402000A0C3C /* Info.plist */,
104 | );
105 | path = UIImagePlusPDFTests;
106 | sourceTree = "";
107 | };
108 | 96197B1920AC6423000A0C3C /* UIImage+PDF */ = {
109 | isa = PBXGroup;
110 | children = (
111 | 96197B1A20AC6431000A0C3C /* UIImage+PDF.swift */,
112 | );
113 | path = "UIImage+PDF";
114 | sourceTree = "";
115 | };
116 | /* End PBXGroup section */
117 |
118 | /* Begin PBXNativeTarget section */
119 | 96197AF520AC63FE000A0C3C /* UIImagePlusPDF */ = {
120 | isa = PBXNativeTarget;
121 | buildConfigurationList = 96197B1320AC6402000A0C3C /* Build configuration list for PBXNativeTarget "UIImagePlusPDF" */;
122 | buildPhases = (
123 | 96197AF220AC63FE000A0C3C /* Sources */,
124 | 96197AF320AC63FE000A0C3C /* Frameworks */,
125 | 96197AF420AC63FE000A0C3C /* Resources */,
126 | );
127 | buildRules = (
128 | );
129 | dependencies = (
130 | );
131 | name = UIImagePlusPDF;
132 | productName = UIImagePlusPDF;
133 | productReference = 96197AF620AC63FE000A0C3C /* UIImagePlusPDF.app */;
134 | productType = "com.apple.product-type.application";
135 | };
136 | 96197B0920AC6402000A0C3C /* UIImagePlusPDFTests */ = {
137 | isa = PBXNativeTarget;
138 | buildConfigurationList = 96197B1620AC6402000A0C3C /* Build configuration list for PBXNativeTarget "UIImagePlusPDFTests" */;
139 | buildPhases = (
140 | 96197B0620AC6402000A0C3C /* Sources */,
141 | 96197B0720AC6402000A0C3C /* Frameworks */,
142 | 96197B0820AC6402000A0C3C /* Resources */,
143 | );
144 | buildRules = (
145 | );
146 | dependencies = (
147 | 96197B0C20AC6402000A0C3C /* PBXTargetDependency */,
148 | );
149 | name = UIImagePlusPDFTests;
150 | productName = UIImagePlusPDFTests;
151 | productReference = 96197B0A20AC6402000A0C3C /* UIImagePlusPDFTests.xctest */;
152 | productType = "com.apple.product-type.bundle.unit-test";
153 | };
154 | /* End PBXNativeTarget section */
155 |
156 | /* Begin PBXProject section */
157 | 96197AEE20AC63FE000A0C3C /* Project object */ = {
158 | isa = PBXProject;
159 | attributes = {
160 | LastSwiftUpdateCheck = 0930;
161 | LastUpgradeCheck = 0930;
162 | ORGANIZATIONNAME = Dima;
163 | TargetAttributes = {
164 | 96197AF520AC63FE000A0C3C = {
165 | CreatedOnToolsVersion = 9.3.1;
166 | };
167 | 96197B0920AC6402000A0C3C = {
168 | CreatedOnToolsVersion = 9.3.1;
169 | TestTargetID = 96197AF520AC63FE000A0C3C;
170 | };
171 | };
172 | };
173 | buildConfigurationList = 96197AF120AC63FE000A0C3C /* Build configuration list for PBXProject "UIImagePlusPDF" */;
174 | compatibilityVersion = "Xcode 9.3";
175 | developmentRegion = en;
176 | hasScannedForEncodings = 0;
177 | knownRegions = (
178 | en,
179 | Base,
180 | );
181 | mainGroup = 96197AED20AC63FE000A0C3C;
182 | productRefGroup = 96197AF720AC63FE000A0C3C /* Products */;
183 | projectDirPath = "";
184 | projectRoot = "";
185 | targets = (
186 | 96197AF520AC63FE000A0C3C /* UIImagePlusPDF */,
187 | 96197B0920AC6402000A0C3C /* UIImagePlusPDFTests */,
188 | );
189 | };
190 | /* End PBXProject section */
191 |
192 | /* Begin PBXResourcesBuildPhase section */
193 | 96197AF420AC63FE000A0C3C /* Resources */ = {
194 | isa = PBXResourcesBuildPhase;
195 | buildActionMask = 2147483647;
196 | files = (
197 | 96197B0420AC6401000A0C3C /* LaunchScreen.storyboard in Resources */,
198 | 96197B0120AC6401000A0C3C /* Assets.xcassets in Resources */,
199 | 96197AFF20AC63FE000A0C3C /* Main.storyboard in Resources */,
200 | 96197B1D20AC6B41000A0C3C /* cat.pdf in Resources */,
201 | 96DFF67220AEE5A800468D4F /* dora.pdf in Resources */,
202 | );
203 | runOnlyForDeploymentPostprocessing = 0;
204 | };
205 | 96197B0820AC6402000A0C3C /* Resources */ = {
206 | isa = PBXResourcesBuildPhase;
207 | buildActionMask = 2147483647;
208 | files = (
209 | );
210 | runOnlyForDeploymentPostprocessing = 0;
211 | };
212 | /* End PBXResourcesBuildPhase section */
213 |
214 | /* Begin PBXSourcesBuildPhase section */
215 | 96197AF220AC63FE000A0C3C /* Sources */ = {
216 | isa = PBXSourcesBuildPhase;
217 | buildActionMask = 2147483647;
218 | files = (
219 | 96197AFC20AC63FE000A0C3C /* ViewController.swift in Sources */,
220 | 96197B1B20AC6431000A0C3C /* UIImage+PDF.swift in Sources */,
221 | 96197AFA20AC63FE000A0C3C /* AppDelegate.swift in Sources */,
222 | );
223 | runOnlyForDeploymentPostprocessing = 0;
224 | };
225 | 96197B0620AC6402000A0C3C /* Sources */ = {
226 | isa = PBXSourcesBuildPhase;
227 | buildActionMask = 2147483647;
228 | files = (
229 | 96197B0F20AC6402000A0C3C /* UIImagePlusPDFTests.swift in Sources */,
230 | );
231 | runOnlyForDeploymentPostprocessing = 0;
232 | };
233 | /* End PBXSourcesBuildPhase section */
234 |
235 | /* Begin PBXTargetDependency section */
236 | 96197B0C20AC6402000A0C3C /* PBXTargetDependency */ = {
237 | isa = PBXTargetDependency;
238 | target = 96197AF520AC63FE000A0C3C /* UIImagePlusPDF */;
239 | targetProxy = 96197B0B20AC6402000A0C3C /* PBXContainerItemProxy */;
240 | };
241 | /* End PBXTargetDependency section */
242 |
243 | /* Begin PBXVariantGroup section */
244 | 96197AFD20AC63FE000A0C3C /* Main.storyboard */ = {
245 | isa = PBXVariantGroup;
246 | children = (
247 | 96197AFE20AC63FE000A0C3C /* Base */,
248 | );
249 | name = Main.storyboard;
250 | sourceTree = "";
251 | };
252 | 96197B0220AC6401000A0C3C /* LaunchScreen.storyboard */ = {
253 | isa = PBXVariantGroup;
254 | children = (
255 | 96197B0320AC6401000A0C3C /* Base */,
256 | );
257 | name = LaunchScreen.storyboard;
258 | sourceTree = "";
259 | };
260 | /* End PBXVariantGroup section */
261 |
262 | /* Begin XCBuildConfiguration section */
263 | 96197B1120AC6402000A0C3C /* Debug */ = {
264 | isa = XCBuildConfiguration;
265 | buildSettings = {
266 | ALWAYS_SEARCH_USER_PATHS = NO;
267 | CLANG_ANALYZER_NONNULL = YES;
268 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
270 | CLANG_CXX_LIBRARY = "libc++";
271 | CLANG_ENABLE_MODULES = YES;
272 | CLANG_ENABLE_OBJC_ARC = YES;
273 | CLANG_ENABLE_OBJC_WEAK = YES;
274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
275 | CLANG_WARN_BOOL_CONVERSION = YES;
276 | CLANG_WARN_COMMA = YES;
277 | CLANG_WARN_CONSTANT_CONVERSION = YES;
278 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
279 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
280 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
281 | CLANG_WARN_EMPTY_BODY = YES;
282 | CLANG_WARN_ENUM_CONVERSION = YES;
283 | CLANG_WARN_INFINITE_RECURSION = YES;
284 | CLANG_WARN_INT_CONVERSION = YES;
285 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
286 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
287 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
288 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
289 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
290 | CLANG_WARN_STRICT_PROTOTYPES = YES;
291 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
292 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
293 | CLANG_WARN_UNREACHABLE_CODE = YES;
294 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
295 | CODE_SIGN_IDENTITY = "iPhone Developer";
296 | COPY_PHASE_STRIP = NO;
297 | DEBUG_INFORMATION_FORMAT = dwarf;
298 | ENABLE_STRICT_OBJC_MSGSEND = YES;
299 | ENABLE_TESTABILITY = YES;
300 | GCC_C_LANGUAGE_STANDARD = gnu11;
301 | GCC_DYNAMIC_NO_PIC = NO;
302 | GCC_NO_COMMON_BLOCKS = YES;
303 | GCC_OPTIMIZATION_LEVEL = 0;
304 | GCC_PREPROCESSOR_DEFINITIONS = (
305 | "DEBUG=1",
306 | "$(inherited)",
307 | );
308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
310 | GCC_WARN_UNDECLARED_SELECTOR = YES;
311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
312 | GCC_WARN_UNUSED_FUNCTION = YES;
313 | GCC_WARN_UNUSED_VARIABLE = YES;
314 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
315 | MTL_ENABLE_DEBUG_INFO = YES;
316 | ONLY_ACTIVE_ARCH = YES;
317 | SDKROOT = iphoneos;
318 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
319 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
320 | SWIFT_VERSION = 5.0;
321 | };
322 | name = Debug;
323 | };
324 | 96197B1220AC6402000A0C3C /* Release */ = {
325 | isa = XCBuildConfiguration;
326 | buildSettings = {
327 | ALWAYS_SEARCH_USER_PATHS = NO;
328 | CLANG_ANALYZER_NONNULL = YES;
329 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
330 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
331 | CLANG_CXX_LIBRARY = "libc++";
332 | CLANG_ENABLE_MODULES = YES;
333 | CLANG_ENABLE_OBJC_ARC = YES;
334 | CLANG_ENABLE_OBJC_WEAK = YES;
335 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
336 | CLANG_WARN_BOOL_CONVERSION = YES;
337 | CLANG_WARN_COMMA = YES;
338 | CLANG_WARN_CONSTANT_CONVERSION = YES;
339 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
342 | CLANG_WARN_EMPTY_BODY = YES;
343 | CLANG_WARN_ENUM_CONVERSION = YES;
344 | CLANG_WARN_INFINITE_RECURSION = YES;
345 | CLANG_WARN_INT_CONVERSION = YES;
346 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
347 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
348 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
349 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
350 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
351 | CLANG_WARN_STRICT_PROTOTYPES = YES;
352 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
353 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
354 | CLANG_WARN_UNREACHABLE_CODE = YES;
355 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
356 | CODE_SIGN_IDENTITY = "iPhone Developer";
357 | COPY_PHASE_STRIP = NO;
358 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
359 | ENABLE_NS_ASSERTIONS = NO;
360 | ENABLE_STRICT_OBJC_MSGSEND = YES;
361 | GCC_C_LANGUAGE_STANDARD = gnu11;
362 | GCC_NO_COMMON_BLOCKS = YES;
363 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
364 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
365 | GCC_WARN_UNDECLARED_SELECTOR = YES;
366 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
367 | GCC_WARN_UNUSED_FUNCTION = YES;
368 | GCC_WARN_UNUSED_VARIABLE = YES;
369 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
370 | MTL_ENABLE_DEBUG_INFO = NO;
371 | SDKROOT = iphoneos;
372 | SWIFT_COMPILATION_MODE = wholemodule;
373 | SWIFT_OPTIMIZATION_LEVEL = "-O";
374 | SWIFT_VERSION = 5.0;
375 | VALIDATE_PRODUCT = YES;
376 | };
377 | name = Release;
378 | };
379 | 96197B1420AC6402000A0C3C /* Debug */ = {
380 | isa = XCBuildConfiguration;
381 | buildSettings = {
382 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
383 | CODE_SIGN_STYLE = Automatic;
384 | CURRENT_PROJECT_VERSION = 3;
385 | DEVELOPMENT_TEAM = 77X75EH6F4;
386 | INFOPLIST_FILE = UIImagePlusPDF/Info.plist;
387 | LD_RUNPATH_SEARCH_PATHS = (
388 | "$(inherited)",
389 | "@executable_path/Frameworks",
390 | );
391 | MARKETING_VERSION = 1.2.0;
392 | PRODUCT_BUNDLE_IDENTIFIER = com.dima.uiimage.pdf.UIImagePlusPDF;
393 | PRODUCT_NAME = "$(TARGET_NAME)";
394 | SWIFT_VERSION = 5.0;
395 | TARGETED_DEVICE_FAMILY = "1,2";
396 | };
397 | name = Debug;
398 | };
399 | 96197B1520AC6402000A0C3C /* Release */ = {
400 | isa = XCBuildConfiguration;
401 | buildSettings = {
402 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
403 | CODE_SIGN_STYLE = Automatic;
404 | CURRENT_PROJECT_VERSION = 3;
405 | DEVELOPMENT_TEAM = 77X75EH6F4;
406 | INFOPLIST_FILE = UIImagePlusPDF/Info.plist;
407 | LD_RUNPATH_SEARCH_PATHS = (
408 | "$(inherited)",
409 | "@executable_path/Frameworks",
410 | );
411 | MARKETING_VERSION = 1.2.0;
412 | PRODUCT_BUNDLE_IDENTIFIER = com.dima.uiimage.pdf.UIImagePlusPDF;
413 | PRODUCT_NAME = "$(TARGET_NAME)";
414 | SWIFT_VERSION = 5.0;
415 | TARGETED_DEVICE_FAMILY = "1,2";
416 | };
417 | name = Release;
418 | };
419 | 96197B1720AC6402000A0C3C /* Debug */ = {
420 | isa = XCBuildConfiguration;
421 | buildSettings = {
422 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
423 | BUNDLE_LOADER = "$(TEST_HOST)";
424 | CODE_SIGN_STYLE = Automatic;
425 | DEVELOPMENT_TEAM = 77X75EH6F4;
426 | INFOPLIST_FILE = UIImagePlusPDFTests/Info.plist;
427 | LD_RUNPATH_SEARCH_PATHS = (
428 | "$(inherited)",
429 | "@executable_path/Frameworks",
430 | "@loader_path/Frameworks",
431 | );
432 | PRODUCT_BUNDLE_IDENTIFIER = com.dima.uiimage.pdf.UIImagePlusPDFTests;
433 | PRODUCT_NAME = "$(TARGET_NAME)";
434 | SWIFT_VERSION = 5.0;
435 | TARGETED_DEVICE_FAMILY = "1,2";
436 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIImagePlusPDF.app/UIImagePlusPDF";
437 | };
438 | name = Debug;
439 | };
440 | 96197B1820AC6402000A0C3C /* Release */ = {
441 | isa = XCBuildConfiguration;
442 | buildSettings = {
443 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
444 | BUNDLE_LOADER = "$(TEST_HOST)";
445 | CODE_SIGN_STYLE = Automatic;
446 | DEVELOPMENT_TEAM = 77X75EH6F4;
447 | INFOPLIST_FILE = UIImagePlusPDFTests/Info.plist;
448 | LD_RUNPATH_SEARCH_PATHS = (
449 | "$(inherited)",
450 | "@executable_path/Frameworks",
451 | "@loader_path/Frameworks",
452 | );
453 | PRODUCT_BUNDLE_IDENTIFIER = com.dima.uiimage.pdf.UIImagePlusPDFTests;
454 | PRODUCT_NAME = "$(TARGET_NAME)";
455 | SWIFT_VERSION = 5.0;
456 | TARGETED_DEVICE_FAMILY = "1,2";
457 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIImagePlusPDF.app/UIImagePlusPDF";
458 | };
459 | name = Release;
460 | };
461 | /* End XCBuildConfiguration section */
462 |
463 | /* Begin XCConfigurationList section */
464 | 96197AF120AC63FE000A0C3C /* Build configuration list for PBXProject "UIImagePlusPDF" */ = {
465 | isa = XCConfigurationList;
466 | buildConfigurations = (
467 | 96197B1120AC6402000A0C3C /* Debug */,
468 | 96197B1220AC6402000A0C3C /* Release */,
469 | );
470 | defaultConfigurationIsVisible = 0;
471 | defaultConfigurationName = Release;
472 | };
473 | 96197B1320AC6402000A0C3C /* Build configuration list for PBXNativeTarget "UIImagePlusPDF" */ = {
474 | isa = XCConfigurationList;
475 | buildConfigurations = (
476 | 96197B1420AC6402000A0C3C /* Debug */,
477 | 96197B1520AC6402000A0C3C /* Release */,
478 | );
479 | defaultConfigurationIsVisible = 0;
480 | defaultConfigurationName = Release;
481 | };
482 | 96197B1620AC6402000A0C3C /* Build configuration list for PBXNativeTarget "UIImagePlusPDFTests" */ = {
483 | isa = XCConfigurationList;
484 | buildConfigurations = (
485 | 96197B1720AC6402000A0C3C /* Debug */,
486 | 96197B1820AC6402000A0C3C /* Release */,
487 | );
488 | defaultConfigurationIsVisible = 0;
489 | defaultConfigurationName = Release;
490 | };
491 | /* End XCConfigurationList section */
492 | };
493 | rootObject = 96197AEE20AC63FE000A0C3C /* Project object */;
494 | }
495 |
--------------------------------------------------------------------------------