├── .gitignore ├── .travis.yml ├── AdaptationKit.podspec ├── AdaptationKit ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── Adaptation.swift │ ├── Screen.swift │ ├── ScreenMatchable.swift │ └── UI.swift ├── Example ├── AdaptationKit.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── AdaptationKit-Example.xcscheme ├── AdaptationKit.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── AdaptationKit │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── Podfile ├── Podfile.lock └── Tests │ ├── AdaptationSpec.swift │ ├── Info.plist │ ├── ScreenMatchableSpec.swift │ └── Tests.swift ├── LICENSE ├── README.md ├── README_CN.md ├── _Pods.xcodeproj └── images ├── adaptConstant.jpg ├── adaptConstantEffect.jpg ├── adaptFont.jpg ├── adaptFontEffect.jpg └── inch.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | # Pods/ 38 | Example/Pods 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/AdaptationKit.xcworkspace -scheme AdaptationKit-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /AdaptationKit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint AdaptationKit.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'AdaptationKit' 11 | s.version = '0.1.1' 12 | s.swift_version = '5.0' 13 | s.summary = 'auto adaptation solution.' 14 | s.description = '📱 screen auto adaptation solution.' 15 | s.homepage = 'https://github.com/catchzeng/AdaptationKit' 16 | s.license = { :type => 'MIT', :file => 'LICENSE' } 17 | s.author = { 'catchzeng' => '891793848@qq.com' } 18 | s.source = { :git => 'https://github.com/catchzeng/AdaptationKit.git', :tag => s.version.to_s } 19 | s.ios.deployment_target = '9.0' 20 | s.source_files = 'AdaptationKit/Classes/**/*' 21 | end 22 | -------------------------------------------------------------------------------- /AdaptationKit/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/AdaptationKit/Assets/.gitkeep -------------------------------------------------------------------------------- /AdaptationKit/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/AdaptationKit/Classes/.gitkeep -------------------------------------------------------------------------------- /AdaptationKit/Classes/Adaptation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Adaptation.swift 3 | // AdaptationKit 4 | // 5 | // Created by CatchZeng on 2019/1/4. 6 | // 7 | 8 | import Foundation 9 | 10 | public class AdaptationRule { 11 | internal var baseScreen: Screen 12 | internal var map = [Screen : Double]() 13 | 14 | public static let `default` = AdaptationRule(baseScreen: .i8) 15 | 16 | public init(baseScreen: Screen) { 17 | self.baseScreen = baseScreen 18 | } 19 | 20 | @discardableResult 21 | public func set(screen: Screen, ratio: Double) -> AdaptationRule { 22 | map[screen] = ratio 23 | return self 24 | } 25 | } 26 | 27 | public struct AdaptationKit { 28 | private static var inchRule = AdaptationRule.default 29 | private static var fontRule = AdaptationRule.default 30 | 31 | public static func set(inchRule: AdaptationRule) { 32 | self.inchRule = inchRule 33 | } 34 | 35 | public static func set(fontRule: AdaptationRule) { 36 | self.fontRule = fontRule 37 | } 38 | 39 | internal static func adaptInch(_ origin: Double) -> Double { 40 | return adapt(origin, rule: inchRule) 41 | } 42 | 43 | internal static func adaptFont(_ origin: Double) -> Double { 44 | return adapt(origin, rule: fontRule) 45 | } 46 | 47 | internal static func adaptInch(_ origin: CGFloat) -> CGFloat { 48 | return origin.adaptInch() 49 | } 50 | 51 | internal static func adaptFont(_ origin: CGFloat) -> CGFloat { 52 | return origin.adaptFont() 53 | } 54 | 55 | private static func adapt(_ origin: Double, rule: AdaptationRule) -> Double { 56 | if let ratio = rule.map[Screen.current] { 57 | return origin * ratio 58 | } else { 59 | let base = Double(rule.baseScreen.size.width) 60 | let width = Double(min(UIScreen.main.bounds.width, UIScreen.main.bounds.height)) 61 | return origin * (width / base) 62 | } 63 | } 64 | } 65 | 66 | public protocol Adaptable { 67 | func adaptInch() -> Self 68 | func adaptFont() -> Self 69 | } 70 | 71 | extension Double: Adaptable { 72 | public func adaptInch() -> Double { 73 | return AdaptationKit.adaptInch(self) 74 | } 75 | 76 | public func adaptFont() -> Double { 77 | return AdaptationKit.adaptFont(self) 78 | } 79 | } 80 | 81 | extension BinaryFloatingPoint { 82 | public func adaptInch() -> T where T : BinaryFloatingPoint { 83 | let temp = Double("\(self)") ?? 0 84 | return T(temp.adaptInch()) 85 | } 86 | 87 | public func adaptFont() -> T where T : BinaryFloatingPoint { 88 | let temp = Double("\(self)") ?? 0 89 | return T(temp.adaptFont()) 90 | } 91 | } 92 | 93 | extension BinaryInteger { 94 | public func adaptInch() -> T where T : BinaryInteger { 95 | let temp = Double("\(self)") ?? 0 96 | return T(temp.adaptInch()) 97 | } 98 | 99 | public func adaptFont() -> T where T : BinaryInteger { 100 | let temp = Double("\(self)") ?? 0 101 | return T(temp.adaptFont()) 102 | } 103 | } 104 | 105 | // MARK: operator 106 | 107 | postfix operator ~ 108 | public postfix func ~ (value: CGFloat) -> CGFloat { 109 | return value.adaptInch() 110 | } 111 | 112 | public postfix func ~ (value: Double) -> Double { 113 | return value.adaptInch() 114 | } 115 | 116 | public postfix func ~ (value: Float) -> Float { 117 | return value.adaptInch() 118 | } 119 | 120 | public postfix func ~ (value: Int) -> Int { 121 | return value.adaptInch() 122 | } 123 | 124 | public postfix func ~ (value: UInt) -> UInt { 125 | return value.adaptInch() 126 | } 127 | 128 | postfix operator ≈ 129 | public postfix func ≈ (value: CGFloat) -> CGFloat { 130 | return value.adaptFont() 131 | } 132 | 133 | public postfix func ≈ (value: Double) -> Double { 134 | return value.adaptFont() 135 | } 136 | 137 | public postfix func ≈ (value: Float) -> Float { 138 | return value.adaptFont() 139 | } 140 | 141 | public postfix func ≈ (value: Int) -> Int { 142 | return value.adaptFont() 143 | } 144 | 145 | public postfix func ≈ (value: UInt) -> UInt { 146 | return value.adaptFont() 147 | } 148 | 149 | 150 | -------------------------------------------------------------------------------- /AdaptationKit/Classes/Screen.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Screen.swift 3 | // AdaptationKit 4 | // 5 | // Created by CatchZeng on 2019/1/4. 6 | // 7 | 8 | import Foundation 9 | import UIKit 10 | 11 | /// Screen 12 | /// 13 | /// - i4: iPhone 4s 14 | /// - iSE: iPhone SE 15 | /// - i8: iPhone 8 16 | /// - i8P: iPhone 8 Plus 17 | /// - iX: iPhone X 18 | /// - iXR: iPhone XR 19 | /// - iXMAX: iPhone XS Max 20 | /// - p97: iPad 9.7 inch 21 | /// - p105: iPad 10.5 inch 22 | /// - p11: iPad 11 inch 23 | /// - p129: iPad 12.9 inch 24 | public enum Screen { 25 | case unknown 26 | case i4 27 | case iSE 28 | case i8 29 | case i8P 30 | case iX 31 | case iXR 32 | case iXMAX 33 | case p97 34 | case p105 35 | case p11 36 | case p129 37 | } 38 | 39 | extension Screen { 40 | public static let current: Screen = { 41 | let width = min(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height) 42 | let height = max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height) 43 | let scale = UIScreen.main.scale 44 | let size = CGSize(width: width, height: height) 45 | 46 | // For iPad2 47 | if size == Screen.p97.size { 48 | return .p97 49 | } 50 | 51 | let nativeSize = CGSize(width: width*scale, height: height*scale) 52 | 53 | switch nativeSize { 54 | case Screen.i4.nativeSize: 55 | return .i4 56 | case Screen.iSE.nativeSize: 57 | return .iSE 58 | case Screen.i8.nativeSize: 59 | return .i8 60 | case Screen.i8P.nativeSize: 61 | return .i8P 62 | case Screen.iX.nativeSize: 63 | return .iX 64 | case Screen.iXR.nativeSize: 65 | return .iXR 66 | case Screen.iXMAX.nativeSize: 67 | return .iXMAX 68 | case Screen.p97.nativeSize: 69 | return .p97 70 | case Screen.p105.nativeSize: 71 | return .p105 72 | case Screen.p11.nativeSize: 73 | return .p11 74 | case Screen.p129.nativeSize: 75 | return .p129 76 | default : 77 | return .unknown 78 | } 79 | }() 80 | } 81 | 82 | // MARK: - @see https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html#//apple_ref/doc/uid/TP40013599-CH108-SW1 83 | extension Screen { 84 | var size: CGSize { 85 | switch self { 86 | case .unknown: 87 | return CGSize(width: 320, height: 480) 88 | case .i4: 89 | return CGSize(width: 320, height: 480) 90 | case .iSE: 91 | return CGSize(width: 320, height: 568) 92 | case .i8: 93 | return CGSize(width: 375, height: 667) 94 | case .i8P: 95 | return CGSize(width: 414, height: 736) 96 | case .iX: 97 | return CGSize(width: 375, height: 812) 98 | case .iXR: 99 | return CGSize(width: 414, height: 896) 100 | case .iXMAX: 101 | return CGSize(width: 414, height: 896) 102 | case .p97: 103 | return CGSize(width: 768, height: 1024) 104 | case .p105: 105 | return CGSize(width: 834, height: 1112) 106 | case .p11: 107 | return CGSize(width: 834, height: 1194) 108 | case .p129: 109 | return CGSize(width: 1024, height: 1366) 110 | } 111 | } 112 | 113 | var scale: CGFloat { 114 | switch self { 115 | case .unknown: 116 | return 2 117 | case .i4: 118 | return 2 119 | case .iSE: 120 | return 2 121 | case .i8: 122 | return 2 123 | case .i8P: 124 | return 3 125 | case .iX: 126 | return 3 127 | case .iXR: 128 | return 2 129 | case .iXMAX: 130 | return 3 131 | case .p97: 132 | return 2 133 | case .p105: 134 | return 2 135 | case .p11: 136 | return 2 137 | case .p129: 138 | return 2 139 | } 140 | } 141 | 142 | var nativeSize: CGSize { 143 | return CGSize(width: size.width*scale, height: size.height*scale) 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /AdaptationKit/Classes/ScreenMatchable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScreenMatchable.swift 3 | // AdaptationKit 4 | // 5 | // Created by CatchZeng on 2019/1/4. 6 | // 7 | 8 | import Foundation 9 | 10 | public protocol ScreenMatchable { 11 | func phone(_ value: Self) -> Self 12 | func pad(_ value: Self) -> Self 13 | func i4(_ value: Self) -> Self 14 | func iSE(_ value: Self) -> Self 15 | func i8(_ value: Self) -> Self 16 | func i8P(_ value: Self) -> Self 17 | func iX(_ value: Self) -> Self 18 | func iXR(_ value: Self) -> Self 19 | func iXMAX(_ value: Self) -> Self 20 | func p97(_ value: Self) -> Self 21 | func p105(_ value: Self) -> Self 22 | func p11(_ value: Self) -> Self 23 | func p129(_ value: Self) -> Self 24 | func match(_ screen: Screen, _ value: Self) -> Self 25 | func match(_ screens: [Screen], _ value: Self) -> Self 26 | } 27 | 28 | extension ScreenMatchable { 29 | public func phone(_ value: Self) -> Self { 30 | return UI_USER_INTERFACE_IDIOM() == .phone ? value : self 31 | } 32 | 33 | public func pad(_ value: Self) -> Self { 34 | return UI_USER_INTERFACE_IDIOM() == .pad ? value : self 35 | } 36 | 37 | public func i4(_ value: Self) -> Self { 38 | return match(.i4, value) 39 | } 40 | 41 | public func iSE(_ value: Self) -> Self { 42 | return match(.iSE, value) 43 | } 44 | 45 | public func i8(_ value: Self) -> Self { 46 | return match(.i8, value) 47 | } 48 | 49 | public func i8P(_ value: Self) -> Self { 50 | return match(.i8P, value) 51 | } 52 | 53 | public func iX(_ value: Self) -> Self { 54 | return match(.iX, value) 55 | } 56 | 57 | public func iXR(_ value: Self) -> Self { 58 | return match(.iXR, value) 59 | } 60 | 61 | public func iXMAX(_ value: Self) -> Self { 62 | return match(.iXMAX, value) 63 | } 64 | 65 | public func p97(_ value: Self) -> Self { 66 | return match(.p97, value) 67 | } 68 | 69 | public func p105(_ value: Self) -> Self { 70 | return match(.p105, value) 71 | } 72 | 73 | public func p11(_ value: Self) -> Self { 74 | return match(.p11, value) 75 | } 76 | 77 | public func p129(_ value: Self) -> Self { 78 | return match(.p129, value) 79 | } 80 | 81 | public func match(_ screen: Screen, _ value: Self) -> Self { 82 | return Screen.current == screen ? value : self 83 | } 84 | 85 | public func match(_ screens: [Screen], _ value: Self) -> Self { 86 | return screens.contains(Screen.current) ? value : self 87 | } 88 | } 89 | 90 | extension Int: ScreenMatchable {} 91 | extension Float: ScreenMatchable {} 92 | extension Double: ScreenMatchable {} 93 | extension String: ScreenMatchable {} 94 | extension CGRect: ScreenMatchable {} 95 | extension CGSize: ScreenMatchable {} 96 | extension CGFloat: ScreenMatchable {} 97 | extension CGPoint: ScreenMatchable {} 98 | extension UIEdgeInsets: ScreenMatchable {} 99 | -------------------------------------------------------------------------------- /AdaptationKit/Classes/UI.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UI.swift 3 | // AdaptationKit 4 | // 5 | // Created by CatchZeng on 2019/1/5. 6 | // 7 | 8 | import Foundation 9 | 10 | extension UILabel { 11 | @IBInspectable public var adaptFont: Bool { 12 | get { return self.adaptFont } 13 | set { 14 | guard newValue else { return } 15 | font = UIFont(name: font.fontName, size: AdaptationKit.adaptFont(font.pointSize)) 16 | } 17 | } 18 | } 19 | 20 | extension UITextView { 21 | @IBInspectable public var adaptFont: Bool { 22 | get { return self.adaptFont } 23 | set { 24 | guard newValue else { return } 25 | guard let font = font else { return } 26 | self.font = UIFont(name: font.fontName, size: AdaptationKit.adaptFont(font.pointSize)) 27 | } 28 | } 29 | } 30 | 31 | extension UITextField { 32 | @IBInspectable public var adaptFont: Bool { 33 | get { return self.adaptFont } 34 | set { 35 | guard newValue else { return } 36 | guard let font = font else { return } 37 | self.font = UIFont(name: font.fontName, size: AdaptationKit.adaptFont(font.pointSize)) 38 | } 39 | } 40 | } 41 | 42 | extension NSLayoutConstraint { 43 | @IBInspectable public var adaptConstant: Bool { 44 | get { return self.adaptConstant } 45 | set { 46 | guard newValue else { return } 47 | constant = AdaptationKit.adaptInch(constant) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/AdaptationKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3FC8E6C27C3C3485F91BEE1F /* Pods_AdaptationKit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B82CDABDEE88D4AB1C37B22C /* Pods_AdaptationKit_Example.framework */; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 13 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 14 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 15 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 16 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 17 | 6293525021DF5A720083C4FB /* ScreenMatchableSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6293524F21DF5A720083C4FB /* ScreenMatchableSpec.swift */; }; 18 | 6293525221DF67310083C4FB /* AdaptationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6293525121DF67310083C4FB /* AdaptationSpec.swift */; }; 19 | 6EB414522779458B5FE07D97 /* Pods_AdaptationKit_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E765DF087BC2A6CB53C6224C /* Pods_AdaptationKit_Tests.framework */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 28 | remoteInfo = AdaptationKit; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 157AA18F089F864920265CDB /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 34 | 2D0ECAFEA57B79C6A09DF8E5 /* Pods-AdaptationKit_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdaptationKit_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AdaptationKit_Tests/Pods-AdaptationKit_Tests.debug.xcconfig"; sourceTree = ""; }; 35 | 607FACD01AFB9204008FA782 /* AdaptationKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AdaptationKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 39 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | 607FACE51AFB9204008FA782 /* AdaptationKit_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AdaptationKit_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 45 | 6293524F21DF5A720083C4FB /* ScreenMatchableSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenMatchableSpec.swift; sourceTree = ""; }; 46 | 6293525121DF67310083C4FB /* AdaptationSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptationSpec.swift; sourceTree = ""; }; 47 | 87099C51636B91B3DB03C120 /* Pods-AdaptationKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdaptationKit_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AdaptationKit_Example/Pods-AdaptationKit_Example.debug.xcconfig"; sourceTree = ""; }; 48 | A48E09D8F496F15F37F07AA2 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 49 | AD3F95F4EAD0340185C1ED0E /* Pods-AdaptationKit_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdaptationKit_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AdaptationKit_Tests/Pods-AdaptationKit_Tests.release.xcconfig"; sourceTree = ""; }; 50 | B82CDABDEE88D4AB1C37B22C /* Pods_AdaptationKit_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdaptationKit_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | C163BAA22A21D31E23DF3102 /* AdaptationKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = AdaptationKit.podspec; path = ../AdaptationKit.podspec; sourceTree = ""; }; 52 | D6F3B0AF999A1F080D2472D6 /* Pods-AdaptationKit_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdaptationKit_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-AdaptationKit_Example/Pods-AdaptationKit_Example.release.xcconfig"; sourceTree = ""; }; 53 | E765DF087BC2A6CB53C6224C /* Pods_AdaptationKit_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdaptationKit_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | 3FC8E6C27C3C3485F91BEE1F /* Pods_AdaptationKit_Example.framework in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | 6EB414522779458B5FE07D97 /* Pods_AdaptationKit_Tests.framework in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | /* End PBXFrameworksBuildPhase section */ 74 | 75 | /* Begin PBXGroup section */ 76 | 5248FD6CFA80D917DB717579 /* Frameworks */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | B82CDABDEE88D4AB1C37B22C /* Pods_AdaptationKit_Example.framework */, 80 | E765DF087BC2A6CB53C6224C /* Pods_AdaptationKit_Tests.framework */, 81 | ); 82 | name = Frameworks; 83 | sourceTree = ""; 84 | }; 85 | 607FACC71AFB9204008FA782 = { 86 | isa = PBXGroup; 87 | children = ( 88 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 89 | 607FACD21AFB9204008FA782 /* Example for AdaptationKit */, 90 | 607FACE81AFB9204008FA782 /* Tests */, 91 | 607FACD11AFB9204008FA782 /* Products */, 92 | 7198DAA3BE263E03CC88F93D /* Pods */, 93 | 5248FD6CFA80D917DB717579 /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 607FACD11AFB9204008FA782 /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 607FACD01AFB9204008FA782 /* AdaptationKit_Example.app */, 101 | 607FACE51AFB9204008FA782 /* AdaptationKit_Tests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 607FACD21AFB9204008FA782 /* Example for AdaptationKit */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 110 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 111 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 112 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 113 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 114 | 607FACD31AFB9204008FA782 /* Supporting Files */, 115 | ); 116 | name = "Example for AdaptationKit"; 117 | path = AdaptationKit; 118 | sourceTree = ""; 119 | }; 120 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 607FACD41AFB9204008FA782 /* Info.plist */, 124 | ); 125 | name = "Supporting Files"; 126 | sourceTree = ""; 127 | }; 128 | 607FACE81AFB9204008FA782 /* Tests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 132 | 6293524F21DF5A720083C4FB /* ScreenMatchableSpec.swift */, 133 | 607FACE91AFB9204008FA782 /* Supporting Files */, 134 | 6293525121DF67310083C4FB /* AdaptationSpec.swift */, 135 | ); 136 | path = Tests; 137 | sourceTree = ""; 138 | }; 139 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 607FACEA1AFB9204008FA782 /* Info.plist */, 143 | ); 144 | name = "Supporting Files"; 145 | sourceTree = ""; 146 | }; 147 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | C163BAA22A21D31E23DF3102 /* AdaptationKit.podspec */, 151 | A48E09D8F496F15F37F07AA2 /* README.md */, 152 | 157AA18F089F864920265CDB /* LICENSE */, 153 | ); 154 | name = "Podspec Metadata"; 155 | sourceTree = ""; 156 | }; 157 | 7198DAA3BE263E03CC88F93D /* Pods */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 87099C51636B91B3DB03C120 /* Pods-AdaptationKit_Example.debug.xcconfig */, 161 | D6F3B0AF999A1F080D2472D6 /* Pods-AdaptationKit_Example.release.xcconfig */, 162 | 2D0ECAFEA57B79C6A09DF8E5 /* Pods-AdaptationKit_Tests.debug.xcconfig */, 163 | AD3F95F4EAD0340185C1ED0E /* Pods-AdaptationKit_Tests.release.xcconfig */, 164 | ); 165 | name = Pods; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXGroup section */ 169 | 170 | /* Begin PBXNativeTarget section */ 171 | 607FACCF1AFB9204008FA782 /* AdaptationKit_Example */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AdaptationKit_Example" */; 174 | buildPhases = ( 175 | 5511D46D8ED9A57408097217 /* [CP] Check Pods Manifest.lock */, 176 | 607FACCC1AFB9204008FA782 /* Sources */, 177 | 607FACCD1AFB9204008FA782 /* Frameworks */, 178 | 607FACCE1AFB9204008FA782 /* Resources */, 179 | B6A95C8D890DA7418A5B9F51 /* [CP] Embed Pods Frameworks */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = AdaptationKit_Example; 186 | productName = AdaptationKit; 187 | productReference = 607FACD01AFB9204008FA782 /* AdaptationKit_Example.app */; 188 | productType = "com.apple.product-type.application"; 189 | }; 190 | 607FACE41AFB9204008FA782 /* AdaptationKit_Tests */ = { 191 | isa = PBXNativeTarget; 192 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AdaptationKit_Tests" */; 193 | buildPhases = ( 194 | 64F4B6E4E7E8E798E2BB2DE5 /* [CP] Check Pods Manifest.lock */, 195 | 607FACE11AFB9204008FA782 /* Sources */, 196 | 607FACE21AFB9204008FA782 /* Frameworks */, 197 | 607FACE31AFB9204008FA782 /* Resources */, 198 | 5DFD048B94F69E1C38B4499A /* [CP] Embed Pods Frameworks */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 204 | ); 205 | name = AdaptationKit_Tests; 206 | productName = Tests; 207 | productReference = 607FACE51AFB9204008FA782 /* AdaptationKit_Tests.xctest */; 208 | productType = "com.apple.product-type.bundle.unit-test"; 209 | }; 210 | /* End PBXNativeTarget section */ 211 | 212 | /* Begin PBXProject section */ 213 | 607FACC81AFB9204008FA782 /* Project object */ = { 214 | isa = PBXProject; 215 | attributes = { 216 | LastSwiftUpdateCheck = 0830; 217 | LastUpgradeCheck = 1020; 218 | ORGANIZATIONNAME = CocoaPods; 219 | TargetAttributes = { 220 | 607FACCF1AFB9204008FA782 = { 221 | CreatedOnToolsVersion = 6.3.1; 222 | LastSwiftMigration = 1020; 223 | }; 224 | 607FACE41AFB9204008FA782 = { 225 | CreatedOnToolsVersion = 6.3.1; 226 | LastSwiftMigration = 1020; 227 | TestTargetID = 607FACCF1AFB9204008FA782; 228 | }; 229 | }; 230 | }; 231 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "AdaptationKit" */; 232 | compatibilityVersion = "Xcode 3.2"; 233 | developmentRegion = English; 234 | hasScannedForEncodings = 0; 235 | knownRegions = ( 236 | English, 237 | en, 238 | Base, 239 | ); 240 | mainGroup = 607FACC71AFB9204008FA782; 241 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 242 | projectDirPath = ""; 243 | projectRoot = ""; 244 | targets = ( 245 | 607FACCF1AFB9204008FA782 /* AdaptationKit_Example */, 246 | 607FACE41AFB9204008FA782 /* AdaptationKit_Tests */, 247 | ); 248 | }; 249 | /* End PBXProject section */ 250 | 251 | /* Begin PBXResourcesBuildPhase section */ 252 | 607FACCE1AFB9204008FA782 /* Resources */ = { 253 | isa = PBXResourcesBuildPhase; 254 | buildActionMask = 2147483647; 255 | files = ( 256 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 257 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 258 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | 607FACE31AFB9204008FA782 /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | /* End PBXResourcesBuildPhase section */ 270 | 271 | /* Begin PBXShellScriptBuildPhase section */ 272 | 5511D46D8ED9A57408097217 /* [CP] Check Pods Manifest.lock */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputFileListPaths = ( 278 | ); 279 | inputPaths = ( 280 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 281 | "${PODS_ROOT}/Manifest.lock", 282 | ); 283 | name = "[CP] Check Pods Manifest.lock"; 284 | outputFileListPaths = ( 285 | ); 286 | outputPaths = ( 287 | "$(DERIVED_FILE_DIR)/Pods-AdaptationKit_Example-checkManifestLockResult.txt", 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | shellPath = /bin/sh; 291 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 292 | showEnvVarsInLog = 0; 293 | }; 294 | 5DFD048B94F69E1C38B4499A /* [CP] Embed Pods Frameworks */ = { 295 | isa = PBXShellScriptBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | ); 299 | inputFileListPaths = ( 300 | ); 301 | inputPaths = ( 302 | "${SRCROOT}/Pods/Target Support Files/Pods-AdaptationKit_Tests/Pods-AdaptationKit_Tests-frameworks.sh", 303 | "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", 304 | "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", 305 | ); 306 | name = "[CP] Embed Pods Frameworks"; 307 | outputFileListPaths = ( 308 | ); 309 | outputPaths = ( 310 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework", 311 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework", 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | shellPath = /bin/sh; 315 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AdaptationKit_Tests/Pods-AdaptationKit_Tests-frameworks.sh\"\n"; 316 | showEnvVarsInLog = 0; 317 | }; 318 | 64F4B6E4E7E8E798E2BB2DE5 /* [CP] Check Pods Manifest.lock */ = { 319 | isa = PBXShellScriptBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | ); 323 | inputFileListPaths = ( 324 | ); 325 | inputPaths = ( 326 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 327 | "${PODS_ROOT}/Manifest.lock", 328 | ); 329 | name = "[CP] Check Pods Manifest.lock"; 330 | outputFileListPaths = ( 331 | ); 332 | outputPaths = ( 333 | "$(DERIVED_FILE_DIR)/Pods-AdaptationKit_Tests-checkManifestLockResult.txt", 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | shellPath = /bin/sh; 337 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 338 | showEnvVarsInLog = 0; 339 | }; 340 | B6A95C8D890DA7418A5B9F51 /* [CP] Embed Pods Frameworks */ = { 341 | isa = PBXShellScriptBuildPhase; 342 | buildActionMask = 2147483647; 343 | files = ( 344 | ); 345 | inputFileListPaths = ( 346 | ); 347 | inputPaths = ( 348 | "${SRCROOT}/Pods/Target Support Files/Pods-AdaptationKit_Example/Pods-AdaptationKit_Example-frameworks.sh", 349 | "${BUILT_PRODUCTS_DIR}/AdaptationKit/AdaptationKit.framework", 350 | ); 351 | name = "[CP] Embed Pods Frameworks"; 352 | outputFileListPaths = ( 353 | ); 354 | outputPaths = ( 355 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AdaptationKit.framework", 356 | ); 357 | runOnlyForDeploymentPostprocessing = 0; 358 | shellPath = /bin/sh; 359 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AdaptationKit_Example/Pods-AdaptationKit_Example-frameworks.sh\"\n"; 360 | showEnvVarsInLog = 0; 361 | }; 362 | /* End PBXShellScriptBuildPhase section */ 363 | 364 | /* Begin PBXSourcesBuildPhase section */ 365 | 607FACCC1AFB9204008FA782 /* Sources */ = { 366 | isa = PBXSourcesBuildPhase; 367 | buildActionMask = 2147483647; 368 | files = ( 369 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 370 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 371 | ); 372 | runOnlyForDeploymentPostprocessing = 0; 373 | }; 374 | 607FACE11AFB9204008FA782 /* Sources */ = { 375 | isa = PBXSourcesBuildPhase; 376 | buildActionMask = 2147483647; 377 | files = ( 378 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 379 | 6293525221DF67310083C4FB /* AdaptationSpec.swift in Sources */, 380 | 6293525021DF5A720083C4FB /* ScreenMatchableSpec.swift in Sources */, 381 | ); 382 | runOnlyForDeploymentPostprocessing = 0; 383 | }; 384 | /* End PBXSourcesBuildPhase section */ 385 | 386 | /* Begin PBXTargetDependency section */ 387 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 388 | isa = PBXTargetDependency; 389 | target = 607FACCF1AFB9204008FA782 /* AdaptationKit_Example */; 390 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 391 | }; 392 | /* End PBXTargetDependency section */ 393 | 394 | /* Begin PBXVariantGroup section */ 395 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 396 | isa = PBXVariantGroup; 397 | children = ( 398 | 607FACDA1AFB9204008FA782 /* Base */, 399 | ); 400 | name = Main.storyboard; 401 | sourceTree = ""; 402 | }; 403 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 404 | isa = PBXVariantGroup; 405 | children = ( 406 | 607FACDF1AFB9204008FA782 /* Base */, 407 | ); 408 | name = LaunchScreen.xib; 409 | sourceTree = ""; 410 | }; 411 | /* End PBXVariantGroup section */ 412 | 413 | /* Begin XCBuildConfiguration section */ 414 | 607FACED1AFB9204008FA782 /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ALWAYS_SEARCH_USER_PATHS = NO; 418 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 419 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 420 | CLANG_CXX_LIBRARY = "libc++"; 421 | CLANG_ENABLE_MODULES = YES; 422 | CLANG_ENABLE_OBJC_ARC = YES; 423 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 424 | CLANG_WARN_BOOL_CONVERSION = YES; 425 | CLANG_WARN_COMMA = YES; 426 | CLANG_WARN_CONSTANT_CONVERSION = YES; 427 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 428 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 429 | CLANG_WARN_EMPTY_BODY = YES; 430 | CLANG_WARN_ENUM_CONVERSION = YES; 431 | CLANG_WARN_INFINITE_RECURSION = YES; 432 | CLANG_WARN_INT_CONVERSION = YES; 433 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 434 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 435 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 436 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 437 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 438 | CLANG_WARN_STRICT_PROTOTYPES = YES; 439 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 440 | CLANG_WARN_UNREACHABLE_CODE = YES; 441 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 442 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 443 | COPY_PHASE_STRIP = NO; 444 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | ENABLE_TESTABILITY = YES; 447 | GCC_C_LANGUAGE_STANDARD = gnu99; 448 | GCC_DYNAMIC_NO_PIC = NO; 449 | GCC_NO_COMMON_BLOCKS = YES; 450 | GCC_OPTIMIZATION_LEVEL = 0; 451 | GCC_PREPROCESSOR_DEFINITIONS = ( 452 | "DEBUG=1", 453 | "$(inherited)", 454 | ); 455 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 456 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 457 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 458 | GCC_WARN_UNDECLARED_SELECTOR = YES; 459 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 460 | GCC_WARN_UNUSED_FUNCTION = YES; 461 | GCC_WARN_UNUSED_VARIABLE = YES; 462 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 463 | MTL_ENABLE_DEBUG_INFO = YES; 464 | ONLY_ACTIVE_ARCH = YES; 465 | SDKROOT = iphoneos; 466 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 467 | }; 468 | name = Debug; 469 | }; 470 | 607FACEE1AFB9204008FA782 /* Release */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | ALWAYS_SEARCH_USER_PATHS = NO; 474 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 475 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 476 | CLANG_CXX_LIBRARY = "libc++"; 477 | CLANG_ENABLE_MODULES = YES; 478 | CLANG_ENABLE_OBJC_ARC = YES; 479 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 480 | CLANG_WARN_BOOL_CONVERSION = YES; 481 | CLANG_WARN_COMMA = YES; 482 | CLANG_WARN_CONSTANT_CONVERSION = YES; 483 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 484 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 485 | CLANG_WARN_EMPTY_BODY = YES; 486 | CLANG_WARN_ENUM_CONVERSION = YES; 487 | CLANG_WARN_INFINITE_RECURSION = YES; 488 | CLANG_WARN_INT_CONVERSION = YES; 489 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 490 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 491 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 492 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 493 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 494 | CLANG_WARN_STRICT_PROTOTYPES = YES; 495 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 496 | CLANG_WARN_UNREACHABLE_CODE = YES; 497 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 498 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 499 | COPY_PHASE_STRIP = NO; 500 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 501 | ENABLE_NS_ASSERTIONS = NO; 502 | ENABLE_STRICT_OBJC_MSGSEND = YES; 503 | GCC_C_LANGUAGE_STANDARD = gnu99; 504 | GCC_NO_COMMON_BLOCKS = YES; 505 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 506 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 507 | GCC_WARN_UNDECLARED_SELECTOR = YES; 508 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 509 | GCC_WARN_UNUSED_FUNCTION = YES; 510 | GCC_WARN_UNUSED_VARIABLE = YES; 511 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 512 | MTL_ENABLE_DEBUG_INFO = NO; 513 | SDKROOT = iphoneos; 514 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 515 | VALIDATE_PRODUCT = YES; 516 | }; 517 | name = Release; 518 | }; 519 | 607FACF01AFB9204008FA782 /* Debug */ = { 520 | isa = XCBuildConfiguration; 521 | baseConfigurationReference = 87099C51636B91B3DB03C120 /* Pods-AdaptationKit_Example.debug.xcconfig */; 522 | buildSettings = { 523 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 524 | DEVELOPMENT_TEAM = ""; 525 | GCC_GENERATE_TEST_COVERAGE_FILES = YES; 526 | INFOPLIST_FILE = AdaptationKit/Info.plist; 527 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 529 | MODULE_NAME = ExampleApp; 530 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 531 | PRODUCT_NAME = "$(TARGET_NAME)"; 532 | SWIFT_VERSION = 5.0; 533 | TARGETED_DEVICE_FAMILY = "1,2"; 534 | }; 535 | name = Debug; 536 | }; 537 | 607FACF11AFB9204008FA782 /* Release */ = { 538 | isa = XCBuildConfiguration; 539 | baseConfigurationReference = D6F3B0AF999A1F080D2472D6 /* Pods-AdaptationKit_Example.release.xcconfig */; 540 | buildSettings = { 541 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 542 | DEVELOPMENT_TEAM = ""; 543 | GCC_GENERATE_TEST_COVERAGE_FILES = YES; 544 | INFOPLIST_FILE = AdaptationKit/Info.plist; 545 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 546 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 547 | MODULE_NAME = ExampleApp; 548 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 549 | PRODUCT_NAME = "$(TARGET_NAME)"; 550 | SWIFT_VERSION = 5.0; 551 | TARGETED_DEVICE_FAMILY = "1,2"; 552 | }; 553 | name = Release; 554 | }; 555 | 607FACF31AFB9204008FA782 /* Debug */ = { 556 | isa = XCBuildConfiguration; 557 | baseConfigurationReference = 2D0ECAFEA57B79C6A09DF8E5 /* Pods-AdaptationKit_Tests.debug.xcconfig */; 558 | buildSettings = { 559 | FRAMEWORK_SEARCH_PATHS = ( 560 | "$(SDKROOT)/Developer/Library/Frameworks", 561 | "$(inherited)", 562 | ); 563 | GCC_GENERATE_TEST_COVERAGE_FILES = NO; 564 | GCC_PREPROCESSOR_DEFINITIONS = ( 565 | "DEBUG=1", 566 | "$(inherited)", 567 | ); 568 | INFOPLIST_FILE = Tests/Info.plist; 569 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 570 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 571 | PRODUCT_NAME = "$(TARGET_NAME)"; 572 | SWIFT_VERSION = 5.0; 573 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AdaptationKit_Example.app/AdaptationKit_Example"; 574 | }; 575 | name = Debug; 576 | }; 577 | 607FACF41AFB9204008FA782 /* Release */ = { 578 | isa = XCBuildConfiguration; 579 | baseConfigurationReference = AD3F95F4EAD0340185C1ED0E /* Pods-AdaptationKit_Tests.release.xcconfig */; 580 | buildSettings = { 581 | FRAMEWORK_SEARCH_PATHS = ( 582 | "$(SDKROOT)/Developer/Library/Frameworks", 583 | "$(inherited)", 584 | ); 585 | GCC_GENERATE_TEST_COVERAGE_FILES = NO; 586 | INFOPLIST_FILE = Tests/Info.plist; 587 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 588 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 589 | PRODUCT_NAME = "$(TARGET_NAME)"; 590 | SWIFT_VERSION = 5.0; 591 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AdaptationKit_Example.app/AdaptationKit_Example"; 592 | }; 593 | name = Release; 594 | }; 595 | /* End XCBuildConfiguration section */ 596 | 597 | /* Begin XCConfigurationList section */ 598 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "AdaptationKit" */ = { 599 | isa = XCConfigurationList; 600 | buildConfigurations = ( 601 | 607FACED1AFB9204008FA782 /* Debug */, 602 | 607FACEE1AFB9204008FA782 /* Release */, 603 | ); 604 | defaultConfigurationIsVisible = 0; 605 | defaultConfigurationName = Release; 606 | }; 607 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AdaptationKit_Example" */ = { 608 | isa = XCConfigurationList; 609 | buildConfigurations = ( 610 | 607FACF01AFB9204008FA782 /* Debug */, 611 | 607FACF11AFB9204008FA782 /* Release */, 612 | ); 613 | defaultConfigurationIsVisible = 0; 614 | defaultConfigurationName = Release; 615 | }; 616 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AdaptationKit_Tests" */ = { 617 | isa = XCConfigurationList; 618 | buildConfigurations = ( 619 | 607FACF31AFB9204008FA782 /* Debug */, 620 | 607FACF41AFB9204008FA782 /* Release */, 621 | ); 622 | defaultConfigurationIsVisible = 0; 623 | defaultConfigurationName = Release; 624 | }; 625 | /* End XCConfigurationList section */ 626 | }; 627 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 628 | } 629 | -------------------------------------------------------------------------------- /Example/AdaptationKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/AdaptationKit.xcodeproj/xcshareddata/xcschemes/AdaptationKit-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 79 | 81 | 87 | 88 | 89 | 90 | 91 | 92 | 98 | 100 | 106 | 107 | 108 | 109 | 111 | 112 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /Example/AdaptationKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/AdaptationKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/AdaptationKit/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AdaptationKit 4 | // 5 | // Created by catchzeng on 01/04/2019. 6 | // Copyright (c) 2019 catchzeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | func applicationWillResignActive(_ application: UIApplication) { 21 | // 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. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | func applicationDidEnterBackground(_ application: UIApplication) { 26 | // 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. 27 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 28 | } 29 | 30 | func applicationWillEnterForeground(_ application: UIApplication) { 31 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 32 | } 33 | 34 | func applicationDidBecomeActive(_ application: UIApplication) { 35 | // 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. 36 | } 37 | 38 | func applicationWillTerminate(_ application: UIApplication) { 39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 40 | } 41 | 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Example/AdaptationKit/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/AdaptationKit/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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Example/AdaptationKit/Images.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" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/AdaptationKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationPortraitUpsideDown 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/AdaptationKit/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AdaptationKit 4 | // 5 | // Created by catchzeng on 01/04/2019. 6 | // Copyright (c) 2019 catchzeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AdaptationKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var label: UILabel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | // label.text = "I am " + 20 | // "unkown screen" 21 | // .i4("iPhone 4 like screen.") 22 | // .i8("iPhone 8 like screen.") 23 | // .i8P("iPhone 8Plus like screen.") 24 | // .iX("iPhone X like screen.") 25 | // .iXR("iPhone XR like screen.") 26 | // .iXMAX("iPhone XMAX like screen.") 27 | // .p97("iPad 9.7 like screen.") 28 | // .p105("iPad 10.5 like screen.") 29 | // .p11("iPad 11 like screen.") 30 | // .p129("iPad 12.9 like screen.") 31 | 32 | /* 33 | * default numberOfLines = 0 34 | * iPad numberOfLines = 1 35 | * iPhone(In addition to iPhone XS Max) numberOfLines = 2 36 | * iPhone XS Max numberOfLines = 3 37 | */ 38 | // let numberOfLines = 0.pad(1).phone(2).iXMAX(3) 39 | // label.numberOfLines = numberOfLines 40 | 41 | /* 42 | * default(iPhone 8) size = 12.0 43 | * iPhone 4 size = 10.24 44 | * iPhone X MAX size = 13.248 45 | * ... 46 | */ 47 | // label.font = UIFont(name: label.font.fontName, size: 12.0.adaptFont()) 48 | 49 | /* 50 | * default(iPhone 8) testInch = 12.0 51 | * iPhone 4 testInch = 10.24 52 | * iPhone X MAX testInch = 13.248 53 | * ... 54 | */ 55 | // let testInch = 12.0.adaptInch() 56 | // print(testInch) 57 | 58 | // label.adaptFont = true 59 | 60 | // let inchRule = AdaptationRule(baseScreen: .i8) 61 | // inchRule.set(screen: .i4, ratio: 0.5) 62 | // inchRule.set(screen: .iXMAX, ratio: 1.3) 63 | // AdaptationKit.set(inchRule: inchRule) 64 | // 65 | // let fontRule = AdaptationRule(baseScreen: .i8) 66 | // fontRule.set(screen: .i4, ratio: 0.6) 67 | // fontRule.set(screen: .iXMAX, ratio: 1.5) 68 | // AdaptationKit.set(inchRule: fontRule) 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '9.0' 2 | 3 | use_frameworks! 4 | 5 | target 'AdaptationKit_Example' do 6 | pod 'AdaptationKit', :path => '../' 7 | 8 | target 'AdaptationKit_Tests' do 9 | inherit! :search_paths 10 | 11 | pod 'Quick' 12 | pod 'Nimble' 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AdaptationKit (0.1.1) 3 | - Nimble (8.0.1) 4 | - Quick (2.0.0) 5 | 6 | DEPENDENCIES: 7 | - AdaptationKit (from `../`) 8 | - Nimble 9 | - Quick 10 | 11 | SPEC REPOS: 12 | https://github.com/cocoapods/specs.git: 13 | - Nimble 14 | - Quick 15 | 16 | EXTERNAL SOURCES: 17 | AdaptationKit: 18 | :path: "../" 19 | 20 | SPEC CHECKSUMS: 21 | AdaptationKit: af5db10bccb1e032a5261e049aa30f11f5c11bf0 22 | Nimble: 45f786ae66faa9a709624227fae502db55a8bdd0 23 | Quick: ce1276c7c27ba2da3cb2fd0cde053c3648b3b22d 24 | 25 | PODFILE CHECKSUM: 3d1dab3ef08bacf588d7ac6bc918142e35e3f4a1 26 | 27 | COCOAPODS: 1.5.3 28 | -------------------------------------------------------------------------------- /Example/Tests/AdaptationSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AdaptationSpec.swift 3 | // AdaptationKit_Tests 4 | // 5 | // Created by CatchZeng on 2019/1/4. 6 | // Copyright © 2019 CocoaPods. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import Quick 11 | import Nimble 12 | import AdaptationKit 13 | 14 | class AdaptationSpec: QuickSpec { 15 | override func spec() { 16 | describe("Adaptation") { 17 | context("Int", { 18 | it("Check adapt method") { 19 | let value: Int = 12.adaptInch() 20 | switch Screen.current { 21 | case .unknown: 22 | expect(value).to(equal(12)) 23 | case .i4: 24 | expect(value).to(equal(10)) 25 | case .iSE: 26 | expect(value).to(equal(10)) 27 | case .i8: 28 | expect(value).to(equal(12)) 29 | case .i8P: 30 | expect(value).to(equal(13)) 31 | case .iX: 32 | expect(value).to(equal(12)) 33 | case .iXR: 34 | expect(value).to(equal(13)) 35 | case .iXMAX: 36 | expect(value).to(equal(13)) 37 | case .p97: 38 | expect(value).to(equal(24)) 39 | case .p105: 40 | expect(value).to(equal(26)) 41 | case .p11: 42 | expect(value).to(equal(26)) 43 | case .p129: 44 | expect(value).to(equal(32)) 45 | } 46 | } 47 | 48 | it("Check ~ method") { 49 | let value: Int = 12~ 50 | switch Screen.current { 51 | case .unknown: 52 | expect(value).to(equal(12)) 53 | case .i4: 54 | expect(value).to(equal(10)) 55 | case .iSE: 56 | expect(value).to(equal(10)) 57 | case .i8: 58 | expect(value).to(equal(12)) 59 | case .i8P: 60 | expect(value).to(equal(13)) 61 | case .iX: 62 | expect(value).to(equal(12)) 63 | case .iXR: 64 | expect(value).to(equal(13)) 65 | case .iXMAX: 66 | expect(value).to(equal(13)) 67 | case .p97: 68 | expect(value).to(equal(24)) 69 | case .p105: 70 | expect(value).to(equal(26)) 71 | case .p11: 72 | expect(value).to(equal(26)) 73 | case .p129: 74 | expect(value).to(equal(32)) 75 | } 76 | } 77 | }) 78 | 79 | context("Double", { 80 | it("Check adapt method") { 81 | let value = 12.0≈ 82 | switch Screen.current { 83 | case .unknown: 84 | expect(value).to(equal(12)) 85 | case .i4: 86 | expect(value).to(beCloseTo(10.24, within: 0.01)) 87 | case .iSE: 88 | expect(value).to(beCloseTo(10.24, within: 0.01)) 89 | case .i8: 90 | expect(value).to(equal(12)) 91 | case .i8P: 92 | expect(value).to(beCloseTo(13.248, within: 0.001)) 93 | case .iX: 94 | expect(value).to(equal(12)) 95 | case .iXR: 96 | expect(value).to(beCloseTo(13.248, within: 0.001)) 97 | case .iXMAX: 98 | expect(value).to(beCloseTo(13.248, within: 0.001)) 99 | case .p97: 100 | expect(value).to(beCloseTo(24.576, within: 0.001)) 101 | case .p105: 102 | expect(value).to(beCloseTo(26.688, within: 0.001)) 103 | case .p11: 104 | expect(value).to(beCloseTo(26.688, within: 0.001)) 105 | case .p129: 106 | expect(value).to(beCloseTo(32.768, within: 0.001)) 107 | } 108 | } 109 | }) 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/ScreenMatchableSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScreenMatchableSpec.swift 3 | // AdaptationKit_Tests 4 | // 5 | // Created by CatchZeng on 2019/1/4. 6 | // Copyright © 2019 CocoaPods. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import Quick 11 | import Nimble 12 | import AdaptationKit 13 | 14 | class ScreenMatchableSpec: QuickSpec { 15 | override func spec() { 16 | describe("ScreenMatchable") { 17 | context("Int", { 18 | it("Check phone & pad methods") { 19 | let value = 0.phone(1).pad(2) 20 | if UI_USER_INTERFACE_IDIOM() == .phone { 21 | expect(value == 1).toEventually(beTruthy()) 22 | } else { 23 | expect(value == 2).toEventually(beTruthy()) 24 | } 25 | } 26 | 27 | it("Check iPhones methods") { 28 | let value = 0.i4(1).i8(2).i8P(3).iX(4).iXMAX(5).iXR(6) 29 | if Screen.current == .i4 { 30 | expect(value == 1).toEventually(beTruthy()) 31 | } else if Screen.current == .i8 { 32 | expect(value == 2).toEventually(beTruthy()) 33 | } else if Screen.current == .i8P { 34 | expect(value == 3).toEventually(beTruthy()) 35 | } else if Screen.current == .iX { 36 | expect(value == 4).toEventually(beTruthy()) 37 | } else if Screen.current == .iXMAX { 38 | expect(value == 5).toEventually(beTruthy()) 39 | } else if Screen.current == .iXR { 40 | expect(value == 6).toEventually(beTruthy()) 41 | } 42 | } 43 | 44 | it("Check iPads methods") { 45 | let value = 0.p97(1).p105(2).p11(3).p129(4) 46 | if Screen.current == .p97 { 47 | expect(value == 1).toEventually(beTruthy()) 48 | } else if Screen.current == .p105 { 49 | expect(value == 2).toEventually(beTruthy()) 50 | } else if Screen.current == .p11 { 51 | expect(value == 3).toEventually(beTruthy()) 52 | } else if Screen.current == .p129 { 53 | expect(value == 4).toEventually(beTruthy()) 54 | } 55 | } 56 | 57 | it("Check macth screens method") { 58 | let value = 0.match([.p97, .iX], 1) 59 | if Screen.current == .p97 || Screen.current == .iX { 60 | expect(value == 1).toEventually(beTruthy()) 61 | } else { 62 | expect(value == 0).toEventually(beTruthy()) 63 | } 64 | } 65 | }) 66 | 67 | 68 | context("String", { 69 | it("Check phone & pad methods") { 70 | let value = "0".phone("1").pad("2") 71 | if UI_USER_INTERFACE_IDIOM() == .phone { 72 | expect(value == "1").toEventually(beTruthy()) 73 | } else { 74 | expect(value == "2").toEventually(beTruthy()) 75 | } 76 | } 77 | 78 | it("Check iPhones methods") { 79 | let value = "0".i4("1").i8("2").i8P("3").iX("4").iXMAX("5").iXR("6") 80 | if Screen.current == .i4 { 81 | expect(value == "1").toEventually(beTruthy()) 82 | } else if Screen.current == .i8 { 83 | expect(value == "2").toEventually(beTruthy()) 84 | } else if Screen.current == .i8P { 85 | expect(value == "3").toEventually(beTruthy()) 86 | } else if Screen.current == .iX { 87 | expect(value == "4").toEventually(beTruthy()) 88 | } else if Screen.current == .iXMAX { 89 | expect(value == "5").toEventually(beTruthy()) 90 | } else if Screen.current == .iXR { 91 | expect(value == "6").toEventually(beTruthy()) 92 | } 93 | } 94 | 95 | it("Check iPads methods") { 96 | let value = "0".p97("1").p105("2").p11("3").p129("4") 97 | if Screen.current == .p97 { 98 | expect(value == "1").toEventually(beTruthy()) 99 | } else if Screen.current == .p105 { 100 | expect(value == "2").toEventually(beTruthy()) 101 | } else if Screen.current == .p11 { 102 | expect(value == "3").toEventually(beTruthy()) 103 | } else if Screen.current == .p129 { 104 | expect(value == "4").toEventually(beTruthy()) 105 | } 106 | } 107 | 108 | it("Check macth screens method") { 109 | let value = "0".match([.p97, .iX], "1") 110 | if Screen.current == .p97 || Screen.current == .iX { 111 | expect(value == "1").toEventually(beTruthy()) 112 | } else { 113 | expect(value == "0").toEventually(beTruthy()) 114 | } 115 | } 116 | }) 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | // https://github.com/Quick/Quick 2 | 3 | import Quick 4 | import Nimble 5 | import AdaptationKit 6 | 7 | class TableOfContentsSpec: QuickSpec { 8 | override func spec() { 9 | describe("these will fail") { 10 | context("these will pass") { 11 | 12 | it("can do maths") { 13 | expect(23) == 23 14 | } 15 | 16 | it("can read") { 17 | expect("🐮") == "🐮" 18 | } 19 | 20 | it("will eventually pass") { 21 | var time = "passing" 22 | 23 | DispatchQueue.main.async { 24 | time = "done" 25 | } 26 | 27 | waitUntil { done in 28 | Thread.sleep(forTimeInterval: 0.5) 29 | expect(time) == "done" 30 | 31 | done() 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Catch Zeng 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AdaptationKit 2 | 3 | ![Swift](https://img.shields.io/badge/Swift-5.0-green.svg) 4 | [![Version](https://img.shields.io/cocoapods/v/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 5 | [![License](https://img.shields.io/cocoapods/l/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 6 | [![Platform](https://img.shields.io/cocoapods/p/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 7 | 8 | 📱 screen auto adaptation solution. 9 | 10 | [中文请戳](https://github.com/CatchZeng/AdaptationKit/blob/master/README_CN.md) 11 | 12 | ## Features 13 | 14 | - [x] Quickly adapt to various screens. 15 | - [x] Calculate inch & font automatically. 16 | - [x] Support operator. 17 | - [x] Support IBInspectable. 18 | - [x] Customize adaptation rules. 19 | 20 | ## Usage 21 | 22 | Import the framework firstly. 23 | 24 | ```swift 25 | import AdaptationKit 26 | ``` 27 | 28 | ### ScreenMatchable 29 | 30 | Quickly adapt to various screens. Support Int,Float,Double,String,CGRect,CGSize,CGFloat,CGPoint,UIEdgeInsets. 31 | 32 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/inch.jpg) 33 | 34 | ```swift 35 | label.text = "I am " + 36 | "unkown screen" 37 | .i4("iPhone 4 like screen.") 38 | .i8("iPhone 8 like screen.") 39 | .i8P("iPhone 8Plus like screen.") 40 | .iX("iPhone X like screen.") 41 | .iXR("iPhone XR like screen.") 42 | .iXMAX("iPhone XS MAX like screen.") 43 | .p97("iPad 9.7 like screen.") 44 | .p105("iPad 10.5 like screen.") 45 | .p11("iPad 11 like screen.") 46 | .p129("iPad 12.9 like screen.") 47 | 48 | /* 49 | * default numberOfLines = 0 50 | * iPad numberOfLines = 1 51 | * iPhone(In addition to iPhone XS Max) numberOfLines = 2 52 | * iPhone XS Max numberOfLines = 3 53 | */ 54 | label.numberOfLines = 0.pad(1).phone(2).iXMAX(3) 55 | 56 | /* 57 | * default value = "0" 58 | * iPad 9.7 & iPhone X value = "1" 59 | */ 60 | let value = "0".match([.p97, .iX], "1") 61 | ``` 62 | 63 | Extend other types you need. 64 | 65 | ```swift 66 | extension YouType: ScreenMatchable {} 67 | ``` 68 | 69 | ### Adaptable 70 | 71 | Calculate inch & font automatically. 72 | 73 | ```swift 74 | /* 75 | * default(iPhone 8) width = 12.0 76 | * iPhone 4 width = 10.24 77 | * iPhone X MAX width = 13.248 78 | * ... 79 | */ 80 | testView.snp.makeConstraints { (make) in 81 | make.width.equalTo(12.adaptInch()) 82 | } 83 | 84 | /* 85 | * default(iPhone 8) size = 12.0 86 | * iPhone 4 size = 10.24 87 | * iPhone X MAX size = 13.248 88 | * ... 89 | */ 90 | label.font = UIFont(name: label.font.fontName, size: 12.0.adaptFont()) 91 | 92 | 93 | // operator 94 | // ~ means adaptInch() 95 | // ≈ means adaptFont() 96 | 97 | testView.snp.makeConstraints { (make) in 98 | make.width.equalTo(12~) 99 | } 100 | 101 | label.font = UIFont(name: label.font.fontName, size: 12.0≈)  102 | ``` 103 | 104 | ### UI 105 | 106 | #### adaptFont 107 | 108 | Support UILabel,UITextView,UITextField. 109 | 110 | ```swift 111 | label.adaptFont = true // equal to label.font = UIFont(name: label.font.fontName, size: font.pointSize.adaptFont()) 112 | ``` 113 | 114 | ![IBInspectable](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptFont.jpg) 115 | 116 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptFontEffect.jpg) 117 | 118 | #### adaptConstant 119 | 120 | Calculate NSLayoutConstraint's constant automatically. 121 | 122 | ```swift 123 | constraint.adaptConstant = true 124 | ``` 125 | 126 | ![IBInspectable](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptConstant.jpg) 127 | 128 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptConstantEffect.jpg) 129 | 130 | ### AdaptationRule 131 | 132 | All of the above automatic calculations are based on the default rules(AdaptationRule.default). 133 | 134 | If you want to customize the rules of the calculation, you can call the set method. 135 | 136 | ```swift 137 | let inchRule = AdaptationRule(baseScreen: .i8) 138 | inchRule.set(screen: .i4, ratio: 0.5) 139 | inchRule.set(screen: .iXMAX, ratio: 1.3) 140 | AdaptationKit.set(inchRule: inchRule) 141 | 142 | let fontRule = AdaptationRule(baseScreen: .i8) 143 | fontRule.set(screen: .i4, ratio: 0.6) 144 | fontRule.set(screen: .iXMAX, ratio: 1.5) 145 | AdaptationKit.set(fontRule: fontRule) 146 | ``` 147 | 148 | ## Example 149 | 150 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 151 | 152 | ## Installation 153 | 154 | AdaptationKit is available through [CocoaPods](https://cocoapods.org). To install 155 | it, simply add the following line to your Podfile: 156 | 157 | ```ruby 158 | pod 'AdaptationKit' 159 | ``` 160 | 161 | ## Author 162 | 163 | catchzeng, 891793848@qq.com 164 | 165 | ## License 166 | 167 | AdaptationKit is available under the MIT license. See the LICENSE file for more info. 168 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # AdaptationKit 2 | 3 | ![Swift](https://img.shields.io/badge/Swift-5.0-green.svg) 4 | [![Version](https://img.shields.io/cocoapods/v/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 5 | [![License](https://img.shields.io/cocoapods/l/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 6 | [![Platform](https://img.shields.io/cocoapods/p/AdaptationKit.svg?style=flat)](https://cocoapods.org/pods/AdaptationKit) 7 | 8 | 📱 屏幕自动适配方案。 9 | 10 | ## 特性 11 | 12 | - [x] 快速适配各种不同尺寸屏幕 13 | - [x] 自动计算尺寸和字体大小 14 | - [x] 支持便捷操作符(~ ,≈) 15 | - [x] 支持 IBInspectable 16 | - [x] 自定义适配规则 17 | 18 | ## 使用方法 19 | 20 | 使用前先导入 AdaptationKit。 21 | 22 | ```swift 23 | import AdaptationKit 24 | ``` 25 | 26 | ### ScreenMatchable 27 | 28 | 快速适配各种不同尺寸屏幕。支持 Int,Float,Double,String,CGRect,CGSize,CGFloat,CGPoint,UIEdgeInsets。 29 | 30 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/inch.jpg) 31 | 32 | ```swift 33 | label.text = "I am " + 34 | "unkown screen" 35 | .i4("iPhone 4 like screen.") 36 | .i8("iPhone 8 like screen.") 37 | .i8P("iPhone 8Plus like screen.") 38 | .iX("iPhone X like screen.") 39 | .iXR("iPhone XR like screen.") 40 | .iXMAX("iPhone XS MAX like screen.") 41 | .p97("iPad 9.7 like screen.") 42 | .p105("iPad 10.5 like screen.") 43 | .p11("iPad 11 like screen.") 44 | .p129("iPad 12.9 like screen.") 45 | 46 | /* 47 | * 默认 numberOfLines = 0 48 | * iPad numberOfLines = 1 49 | * iPhone(除了 iPhone XS Max 以外) numberOfLines = 2 50 | * iPhone XS Max numberOfLines = 3 51 | */ 52 | label.numberOfLines = 0.pad(1).phone(2).iXMAX(3) 53 | 54 | /* 55 | * 默认 value = "0" 56 | * iPad 9.7 & iPhone X value = "1" 57 | */ 58 | let value = "0".match([.p97, .iX], "1") 59 | ``` 60 | 61 | 你可以扩展自己需要的类型。 62 | 63 | ```swift 64 | extension YouType: ScreenMatchable {} 65 | ``` 66 | 67 | ### Adaptable 68 | 69 | 自动计算尺寸和字体大小。 70 | 71 | ```swift 72 | /* 73 | * 默认(iPhone 8) width = 12.0 74 | * iPhone 4 width = 10.24 75 | * iPhone X MAX width = 13.248 76 | * ... 77 | */ 78 | testView.snp.makeConstraints { (make) in 79 | make.width.equalTo(12.adaptInch()) 80 | } 81 | 82 | /* 83 | * 默认(iPhone 8) size = 12.0 84 | * iPhone 4 size = 10.24 85 | * iPhone X MAX size = 13.248 86 | * ... 87 | */ 88 | label.font = UIFont(name: label.font.fontName, size: 12.0.adaptFont()) 89 | 90 | 91 | // 便捷操作符 92 | // ~ 相当于 adaptInch() 93 | // ≈ 相当于 adaptFont() 94 | 95 | testView.snp.makeConstraints { (make) in 96 | make.width.equalTo(12~) 97 | } 98 | 99 | label.font = UIFont(name: label.font.fontName, size: 12.0≈)  100 | ``` 101 | 102 | ### UI 103 | 104 | #### adaptFont 105 | 106 | 支持 UILabel,UITextView,UITextField。 107 | 108 | ```swift 109 | label.adaptFont = true // 相当于 label.font = UIFont(name: label.font.fontName, size: font.pointSize.adaptFont()) 110 | ``` 111 | 112 | ![IBInspectable](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptFont.jpg) 113 | 114 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptFontEffect.jpg) 115 | 116 | #### adaptConstant 117 | 118 | 自动计算 NSLayoutConstraint 的 constant 值。 119 | 120 | ```swift 121 | constraint.adaptConstant = true 122 | ``` 123 | 124 | ![IBInspectable](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptConstant.jpg) 125 | 126 | ![Effect](https://raw.githubusercontent.com/CatchZeng/AdaptationKit/master/images/adaptConstantEffect.jpg) 127 | 128 | ### AdaptationRule 129 | 130 | 以上所有的自动计算都是基于默认的规则(AdaptationRule.default)。 131 | 132 | 如果默认的规则不满足需求,你可以自定义规则。 133 | 134 | ```swift 135 | let inchRule = AdaptationRule(baseScreen: .i8) 136 | inchRule.set(screen: .i4, ratio: 0.5) 137 | inchRule.set(screen: .iXMAX, ratio: 1.3) 138 | AdaptationKit.set(inchRule: inchRule) 139 | 140 | let fontRule = AdaptationRule(baseScreen: .i8) 141 | fontRule.set(screen: .i4, ratio: 0.6) 142 | fontRule.set(screen: .iXMAX, ratio: 1.5) 143 | AdaptationKit.set(fontRule: fontRule) 144 | ``` 145 | 146 | ## 实例 147 | 148 | Clone 本项目, 在 Example 项目中执行 `pod install`,然后 run 项目即可。 149 | 150 | ## 安装 151 | 152 | AdaptationKit 可通过 [CocoaPods](https://cocoapods.org) 安装。 153 | 154 | ```ruby 155 | pod 'AdaptationKit' 156 | ``` 157 | 158 | ## 作者 159 | 160 | catchzeng, 891793848@qq.com 161 | 162 | ## License 163 | 164 | AdaptationKit is available under the MIT license. See the LICENSE file for more info. 165 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /images/adaptConstant.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/images/adaptConstant.jpg -------------------------------------------------------------------------------- /images/adaptConstantEffect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/images/adaptConstantEffect.jpg -------------------------------------------------------------------------------- /images/adaptFont.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/images/adaptFont.jpg -------------------------------------------------------------------------------- /images/adaptFontEffect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/images/adaptFontEffect.jpg -------------------------------------------------------------------------------- /images/inch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatchZeng/AdaptationKit/c317959ed14632c2e0d33f0f9f748f289642f767/images/inch.jpg --------------------------------------------------------------------------------