├── .gitignore ├── .swift-version ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── CPF-CNPJ-Validator.podspec ├── CPF-CNPJ-Validator.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── CPF-CNPJ-Validator.xcscheme ├── CPF-CNPJ-Validator.xcworkspace └── contents.xcworkspacedata ├── LICENSE ├── README.md ├── Source ├── CPF-CNPJ-Validator.h ├── CPF-CNPJ-Validator.swift └── Info.plist ├── Tests ├── CPF-CNPJ-ValidatorTests.swift ├── CheckCocoaPodsQualityIndexes.rb └── Info.plist └── iOS Example ├── Source ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift └── iOS Example.xcodeproj ├── project.pbxproj └── project.xcworkspace └── contents.xcworkspacedata /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | CPF-CNPJ-Validator.framework.zip 66 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8 3 | env: 4 | global: 5 | - LC_CTYPE=en_US.UTF-8 6 | - LANG=en_US.UTF-8 7 | - WORKSPACE="CPF-CNPJ-Validator.xcworkspace" 8 | - IOS_FRAMEWORK_SCHEME="CPF-CNPJ-Validator" 9 | - IOS_SDK=iphonesimulator10.0 10 | - EXAMPLE_SCHEME="iOS Example" 11 | matrix: 12 | - DESTINATION="OS=10.0,name=iPhone 7 Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" POD_LINT="NO" 13 | script: 14 | - set -o pipefail 15 | - xcodebuild -version 16 | - xcodebuild -showsdks 17 | - xcodebuild -list 18 | - xcodebuild -workspace "$WORKSPACE" -list 19 | 20 | # Build and test Framework in Debug 21 | - xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty 22 | 23 | # Build Framework in ReleaseTest 24 | - xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration ReleaseTest ONLY_ACTIVE_ARCH=NO build | xcpretty 25 | 26 | # Run `pod lib lint` if specified 27 | - if [ $POD_LINT == "YES" ]; then 28 | pod lib lint; 29 | fi 30 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | `CPF-CNPJ-Validator` adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## [Master](https://github.com/fpg1503/CPF-CNPJ-Validator) 6 | ### Added 7 | 8 | ### Changed 9 | 10 | ### Removed 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | All contributors are welcome. Please use issues and pull requests to contribute to the project. And update [CHANGELOG.md](CHANGELOG.md) when committing. 4 | 5 | ## Making a Change 6 | 7 | When you commit a change, please add a note to [CHANGELOG.md](CHANGELOG.md). 8 | 9 | ## Release Process 10 | 11 | 1. Confirm the build is [passing in travis](https://travis-ci.org/fpg1503/CPF-CNPJ-Validator) 12 | 1. This automatically checks the Podfile is building 13 | 2. Push a release commit 14 | 1. Create a new Master section at the top 15 | 2. Rename the old Master section like: 16 | ## [1.0.5](https://github.com/fpg1503/CPF-CNPJ-Validator/releases/tag/1.0.5) 17 | Released on 2016-02-14. 18 | 3. Update the Podspec version number 19 | 3. Create a GitHub release 20 | 1. Tag the release (like `1.0.5`) 21 | 2. Paste notes from [CHANGELOG.md](CHANGELOG.md) 22 | 3. Push the Podspec to CocoaPods 23 | 1. `pod trunk push` 24 | 4. Create Carthage binaries 25 | 1. `carthage build --no-skip-current` 26 | 2. `carthage archive CPF-CNPJ-Validator` 27 | 3. Add to the GitHub release 28 | -------------------------------------------------------------------------------- /CPF-CNPJ-Validator.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'CPF-CNPJ-Validator' 3 | s.version = '1.0.2' 4 | s.license = { :type => 'MIT', :file => 'LICENSE' } 5 | s.summary = '✅ A Swifty CPF and CNPJ validator' 6 | 7 | s.description = <<-DESC 8 | A Swift library to validate CPF and CNPJ. Automatically strips formatting, 9 | covers valid numbers, wrong length, number sequences, and common fake numbers. 10 | Options can be passed to allow invalid number sequences, that's useful for 11 | testing. 12 | DESC 13 | 14 | s.homepage = 'https://github.com/fpg1503/CPF-CNPJ-Validator' 15 | s.authors = { 'Francesco Perrotti-Garcia' => 'fpg1503@gmail.com' } 16 | s.social_media_url = 'https://twitter.com/fpg1503' 17 | s.source = { :git => 'https://github.com/fpg1503/CPF-CNPJ-Validator.git', :tag => s.version } 18 | s.ios.deployment_target = '8.0' 19 | s.source_files = 'Source/*.swift' 20 | end 21 | -------------------------------------------------------------------------------- /CPF-CNPJ-Validator.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D95E1BE71D88D63400F94976 /* CPF_CNPJ_Validator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D95E1BDD1D88D63300F94976 /* CPF_CNPJ_Validator.framework */; }; 11 | D95E1BEC1D88D63400F94976 /* CPF-CNPJ-ValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95E1BEB1D88D63400F94976 /* CPF-CNPJ-ValidatorTests.swift */; }; 12 | D95E1BEE1D88D63400F94976 /* CPF-CNPJ-Validator.h in Headers */ = {isa = PBXBuildFile; fileRef = D95E1BE01D88D63300F94976 /* CPF-CNPJ-Validator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | D95E1BFB1D88E2D500F94976 /* CPF-CNPJ-Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95E1BFA1D88E2D500F94976 /* CPF-CNPJ-Validator.swift */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXContainerItemProxy section */ 17 | D95E1BE81D88D63400F94976 /* PBXContainerItemProxy */ = { 18 | isa = PBXContainerItemProxy; 19 | containerPortal = D95E1BD41D88D63200F94976 /* Project object */; 20 | proxyType = 1; 21 | remoteGlobalIDString = D95E1BDC1D88D63300F94976; 22 | remoteInfo = "CPF-CNPJ-Validator"; 23 | }; 24 | /* End PBXContainerItemProxy section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | D95E1BDD1D88D63300F94976 /* CPF_CNPJ_Validator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CPF_CNPJ_Validator.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | D95E1BE01D88D63300F94976 /* CPF-CNPJ-Validator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CPF-CNPJ-Validator.h"; sourceTree = ""; }; 29 | D95E1BE11D88D63300F94976 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | D95E1BE61D88D63400F94976 /* CPF_CNPJ_ValidatorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CPF_CNPJ_ValidatorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | D95E1BEB1D88D63400F94976 /* CPF-CNPJ-ValidatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPF-CNPJ-ValidatorTests.swift"; sourceTree = ""; }; 32 | D95E1BED1D88D63400F94976 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | D95E1BFA1D88E2D500F94976 /* CPF-CNPJ-Validator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CPF-CNPJ-Validator.swift"; sourceTree = ""; }; 34 | /* End PBXFileReference section */ 35 | 36 | /* Begin PBXFrameworksBuildPhase section */ 37 | D95E1BD91D88D63300F94976 /* Frameworks */ = { 38 | isa = PBXFrameworksBuildPhase; 39 | buildActionMask = 2147483647; 40 | files = ( 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | D95E1BE31D88D63400F94976 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | D95E1BE71D88D63400F94976 /* CPF_CNPJ_Validator.framework in Frameworks */, 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | D95E1BD31D88D63200F94976 = { 56 | isa = PBXGroup; 57 | children = ( 58 | D95E1BDF1D88D63300F94976 /* Source */, 59 | D95E1BEA1D88D63400F94976 /* Tests */, 60 | D95E1BDE1D88D63300F94976 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | D95E1BDE1D88D63300F94976 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | D95E1BDD1D88D63300F94976 /* CPF_CNPJ_Validator.framework */, 68 | D95E1BE61D88D63400F94976 /* CPF_CNPJ_ValidatorTests.xctest */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | D95E1BDF1D88D63300F94976 /* Source */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | D95E1BFA1D88E2D500F94976 /* CPF-CNPJ-Validator.swift */, 77 | D95E1BE01D88D63300F94976 /* CPF-CNPJ-Validator.h */, 78 | D95E1BE11D88D63300F94976 /* Info.plist */, 79 | ); 80 | path = Source; 81 | sourceTree = ""; 82 | }; 83 | D95E1BEA1D88D63400F94976 /* Tests */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | D95E1BEB1D88D63400F94976 /* CPF-CNPJ-ValidatorTests.swift */, 87 | D95E1BED1D88D63400F94976 /* Info.plist */, 88 | ); 89 | path = Tests; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXHeadersBuildPhase section */ 95 | D95E1BDA1D88D63300F94976 /* Headers */ = { 96 | isa = PBXHeadersBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | D95E1BEE1D88D63400F94976 /* CPF-CNPJ-Validator.h in Headers */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXHeadersBuildPhase section */ 104 | 105 | /* Begin PBXNativeTarget section */ 106 | D95E1BDC1D88D63300F94976 /* CPF-CNPJ-Validator */ = { 107 | isa = PBXNativeTarget; 108 | buildConfigurationList = D95E1BF11D88D63400F94976 /* Build configuration list for PBXNativeTarget "CPF-CNPJ-Validator" */; 109 | buildPhases = ( 110 | D95E1BD81D88D63300F94976 /* Sources */, 111 | D95E1BD91D88D63300F94976 /* Frameworks */, 112 | D95E1BDA1D88D63300F94976 /* Headers */, 113 | D95E1BDB1D88D63300F94976 /* Resources */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = "CPF-CNPJ-Validator"; 120 | productName = "CPF-CNPJ-Validator"; 121 | productReference = D95E1BDD1D88D63300F94976 /* CPF_CNPJ_Validator.framework */; 122 | productType = "com.apple.product-type.framework"; 123 | }; 124 | D95E1BE51D88D63400F94976 /* CPF-CNPJ-ValidatorTests */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = D95E1BF41D88D63400F94976 /* Build configuration list for PBXNativeTarget "CPF-CNPJ-ValidatorTests" */; 127 | buildPhases = ( 128 | D95E1BE21D88D63400F94976 /* Sources */, 129 | D95E1BE31D88D63400F94976 /* Frameworks */, 130 | D95E1BE41D88D63400F94976 /* Resources */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | D95E1BE91D88D63400F94976 /* PBXTargetDependency */, 136 | ); 137 | name = "CPF-CNPJ-ValidatorTests"; 138 | productName = "CPF-CNPJ-ValidatorTests"; 139 | productReference = D95E1BE61D88D63400F94976 /* CPF_CNPJ_ValidatorTests.xctest */; 140 | productType = "com.apple.product-type.bundle.unit-test"; 141 | }; 142 | /* End PBXNativeTarget section */ 143 | 144 | /* Begin PBXProject section */ 145 | D95E1BD41D88D63200F94976 /* Project object */ = { 146 | isa = PBXProject; 147 | attributes = { 148 | LastSwiftUpdateCheck = 0800; 149 | LastUpgradeCheck = 0900; 150 | ORGANIZATIONNAME = "Francesco Perrotti-Garcia"; 151 | TargetAttributes = { 152 | D95E1BDC1D88D63300F94976 = { 153 | CreatedOnToolsVersion = 8.0; 154 | LastSwiftMigration = 0900; 155 | ProvisioningStyle = Automatic; 156 | }; 157 | D95E1BE51D88D63400F94976 = { 158 | CreatedOnToolsVersion = 8.0; 159 | LastSwiftMigration = 0900; 160 | ProvisioningStyle = Automatic; 161 | }; 162 | }; 163 | }; 164 | buildConfigurationList = D95E1BD71D88D63300F94976 /* Build configuration list for PBXProject "CPF-CNPJ-Validator" */; 165 | compatibilityVersion = "Xcode 3.2"; 166 | developmentRegion = English; 167 | hasScannedForEncodings = 0; 168 | knownRegions = ( 169 | en, 170 | ); 171 | mainGroup = D95E1BD31D88D63200F94976; 172 | productRefGroup = D95E1BDE1D88D63300F94976 /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | D95E1BDC1D88D63300F94976 /* CPF-CNPJ-Validator */, 177 | D95E1BE51D88D63400F94976 /* CPF-CNPJ-ValidatorTests */, 178 | ); 179 | }; 180 | /* End PBXProject section */ 181 | 182 | /* Begin PBXResourcesBuildPhase section */ 183 | D95E1BDB1D88D63300F94976 /* Resources */ = { 184 | isa = PBXResourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | D95E1BE41D88D63400F94976 /* Resources */ = { 191 | isa = PBXResourcesBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | /* End PBXResourcesBuildPhase section */ 198 | 199 | /* Begin PBXSourcesBuildPhase section */ 200 | D95E1BD81D88D63300F94976 /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | D95E1BFB1D88E2D500F94976 /* CPF-CNPJ-Validator.swift in Sources */, 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | D95E1BE21D88D63400F94976 /* Sources */ = { 209 | isa = PBXSourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | D95E1BEC1D88D63400F94976 /* CPF-CNPJ-ValidatorTests.swift in Sources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXSourcesBuildPhase section */ 217 | 218 | /* Begin PBXTargetDependency section */ 219 | D95E1BE91D88D63400F94976 /* PBXTargetDependency */ = { 220 | isa = PBXTargetDependency; 221 | target = D95E1BDC1D88D63300F94976 /* CPF-CNPJ-Validator */; 222 | targetProxy = D95E1BE81D88D63400F94976 /* PBXContainerItemProxy */; 223 | }; 224 | /* End PBXTargetDependency section */ 225 | 226 | /* Begin XCBuildConfiguration section */ 227 | D95E1BEF1D88D63400F94976 /* Debug */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 233 | CLANG_CXX_LIBRARY = "libc++"; 234 | CLANG_ENABLE_MODULES = YES; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_COMMA = YES; 239 | CLANG_WARN_CONSTANT_CONVERSION = YES; 240 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 241 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 242 | CLANG_WARN_EMPTY_BODY = YES; 243 | CLANG_WARN_ENUM_CONVERSION = YES; 244 | CLANG_WARN_INFINITE_RECURSION = YES; 245 | CLANG_WARN_INT_CONVERSION = YES; 246 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 247 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 249 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 250 | CLANG_WARN_STRICT_PROTOTYPES = YES; 251 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 252 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 256 | COPY_PHASE_STRIP = NO; 257 | CURRENT_PROJECT_VERSION = 1; 258 | DEBUG_INFORMATION_FORMAT = dwarf; 259 | ENABLE_STRICT_OBJC_MSGSEND = YES; 260 | ENABLE_TESTABILITY = YES; 261 | GCC_C_LANGUAGE_STANDARD = gnu99; 262 | GCC_DYNAMIC_NO_PIC = NO; 263 | GCC_NO_COMMON_BLOCKS = YES; 264 | GCC_OPTIMIZATION_LEVEL = 0; 265 | GCC_PREPROCESSOR_DEFINITIONS = ( 266 | "DEBUG=1", 267 | "$(inherited)", 268 | ); 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 276 | MTL_ENABLE_DEBUG_INFO = YES; 277 | ONLY_ACTIVE_ARCH = YES; 278 | SDKROOT = iphoneos; 279 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 280 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 281 | TARGETED_DEVICE_FAMILY = "1,2"; 282 | VERSIONING_SYSTEM = "apple-generic"; 283 | VERSION_INFO_PREFIX = ""; 284 | }; 285 | name = Debug; 286 | }; 287 | D95E1BF01D88D63400F94976 /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ALWAYS_SEARCH_USER_PATHS = NO; 291 | CLANG_ANALYZER_NONNULL = YES; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 297 | CLANG_WARN_BOOL_CONVERSION = YES; 298 | CLANG_WARN_COMMA = YES; 299 | CLANG_WARN_CONSTANT_CONVERSION = YES; 300 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 301 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INFINITE_RECURSION = YES; 305 | CLANG_WARN_INT_CONVERSION = YES; 306 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 307 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 308 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 309 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 310 | CLANG_WARN_STRICT_PROTOTYPES = YES; 311 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 312 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 316 | COPY_PHASE_STRIP = NO; 317 | CURRENT_PROJECT_VERSION = 1; 318 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 319 | ENABLE_NS_ASSERTIONS = NO; 320 | ENABLE_STRICT_OBJC_MSGSEND = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_NO_COMMON_BLOCKS = YES; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 330 | MTL_ENABLE_DEBUG_INFO = NO; 331 | SDKROOT = iphoneos; 332 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 333 | TARGETED_DEVICE_FAMILY = "1,2"; 334 | VALIDATE_PRODUCT = YES; 335 | VERSIONING_SYSTEM = "apple-generic"; 336 | VERSION_INFO_PREFIX = ""; 337 | }; 338 | name = Release; 339 | }; 340 | D95E1BF21D88D63400F94976 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 344 | CLANG_ENABLE_MODULES = YES; 345 | CODE_SIGN_IDENTITY = ""; 346 | DEFINES_MODULE = YES; 347 | DYLIB_COMPATIBILITY_VERSION = 1; 348 | DYLIB_CURRENT_VERSION = 1; 349 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 350 | INFOPLIST_FILE = Source/Info.plist; 351 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 352 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 353 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.CPF-CNPJ-Validator"; 354 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 355 | SKIP_INSTALL = YES; 356 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 357 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 358 | SWIFT_VERSION = 4.0; 359 | }; 360 | name = Debug; 361 | }; 362 | D95E1BF31D88D63400F94976 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 366 | CLANG_ENABLE_MODULES = YES; 367 | CODE_SIGN_IDENTITY = ""; 368 | DEFINES_MODULE = YES; 369 | DYLIB_COMPATIBILITY_VERSION = 1; 370 | DYLIB_CURRENT_VERSION = 1; 371 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 372 | INFOPLIST_FILE = Source/Info.plist; 373 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 374 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 375 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.CPF-CNPJ-Validator"; 376 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 377 | SKIP_INSTALL = YES; 378 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 379 | SWIFT_VERSION = 4.0; 380 | }; 381 | name = Release; 382 | }; 383 | D95E1BF51D88D63400F94976 /* Debug */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 387 | INFOPLIST_FILE = Tests/Info.plist; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 389 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.CPF-CNPJ-ValidatorTests"; 390 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 391 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 392 | SWIFT_VERSION = 4.0; 393 | }; 394 | name = Debug; 395 | }; 396 | D95E1BF61D88D63400F94976 /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 400 | INFOPLIST_FILE = Tests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.CPF-CNPJ-ValidatorTests"; 403 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 404 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 405 | SWIFT_VERSION = 4.0; 406 | }; 407 | name = Release; 408 | }; 409 | /* End XCBuildConfiguration section */ 410 | 411 | /* Begin XCConfigurationList section */ 412 | D95E1BD71D88D63300F94976 /* Build configuration list for PBXProject "CPF-CNPJ-Validator" */ = { 413 | isa = XCConfigurationList; 414 | buildConfigurations = ( 415 | D95E1BEF1D88D63400F94976 /* Debug */, 416 | D95E1BF01D88D63400F94976 /* Release */, 417 | ); 418 | defaultConfigurationIsVisible = 0; 419 | defaultConfigurationName = Release; 420 | }; 421 | D95E1BF11D88D63400F94976 /* Build configuration list for PBXNativeTarget "CPF-CNPJ-Validator" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | D95E1BF21D88D63400F94976 /* Debug */, 425 | D95E1BF31D88D63400F94976 /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | D95E1BF41D88D63400F94976 /* Build configuration list for PBXNativeTarget "CPF-CNPJ-ValidatorTests" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | D95E1BF51D88D63400F94976 /* Debug */, 434 | D95E1BF61D88D63400F94976 /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | /* End XCConfigurationList section */ 440 | }; 441 | rootObject = D95E1BD41D88D63200F94976 /* Project object */; 442 | } 443 | -------------------------------------------------------------------------------- /CPF-CNPJ-Validator.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CPF-CNPJ-Validator.xcodeproj/xcshareddata/xcschemes/CPF-CNPJ-Validator.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /CPF-CNPJ-Validator.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Francesco Perrotti-Garcia 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CPF-CNPJ-Validator 2 | 3 | [![CI Status](http://img.shields.io/travis/fpg1503/CPF-CNPJ-Validator.svg?style=flat)](https://travis-ci.org/fpg1503/CPF-CNPJ-Validator) 4 | [![Version](https://img.shields.io/cocoapods/v/CPF-CNPJ-Validator.svg?style=flat)](https://cocoapods.org/pods/CPF-CNPJ-Validator) 5 | [![License](https://img.shields.io/cocoapods/l/CPF-CNPJ-Validator.svg?style=flat)](https://cocoapods.org/pods/CPF-CNPJ-Validator) 6 | [![Platform](https://img.shields.io/cocoapods/p/CPF-CNPJ-Validator.svg?style=flat)](https://cocoapods.org/pods/CPF-CNPJ-Validator) 7 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 8 | 9 | A Swift library to validate CPF and CNPJ. Automatically strips formatting, covers valid numbers, wrong length, number sequences, and common fake numbers. Options can be passed to allow invalid number sequences, that's useful for testing. 10 | 11 | ## Usage 12 | 13 | You can use two types of validators: `StatusValidator` (if you're interested in what's wrong) and `BooleanValidator` (if you only care if a given number is valid or not). 14 | 15 | ### `BooleanValidator` 16 | 17 | ```swift 18 | let success = BooleanValidator().validate(cpf: "12345678909") 19 | ``` 20 | 21 | ### `StatusValidator` 22 | 23 | ```swift 24 | let cpf = "1234567890912345678909" 25 | let status = validator.validate(cpf: cpf) 26 | //Status is .wrongLength 27 | ``` 28 | 29 | ### Validation Options 30 | 31 | You can also pass options to the validate method. The options available are: 32 | 33 | - Add Leading Zeros 34 | - Ignore Remaining Characters 35 | - Interpret Only Numbers 36 | - Allow Repeated Patterns 37 | - Allow Common Numbers 38 | 39 | By default no options are given 40 | 41 | ### Validation Statuses 42 | 43 | The possible validation statuses are: 44 | 45 | - Valid 46 | - Wrong Length (i.e. `111`) 47 | - Repeated Pattern (i.e. `111.111.111-11`) 48 | - Common Number (i.e. `123.456.789-09`) 49 | - Invalid (invalid verification digits) 50 | 51 | 52 | ## Example 53 | 54 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 55 | 56 | ## Installation 57 | 58 | For Swift 4.0+ use v1.0 59 | 60 | ### CocoaPods 61 | 62 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 63 | 64 | ```bash 65 | $ gem install cocoapods 66 | ``` 67 | 68 | To integrate CPF-CNPJ-Validator into your Xcode project using CocoaPods, specify it in your `Podfile`: 69 | 70 | ```ruby 71 | use_frameworks! 72 | 73 | pod 'CPF-CNPJ-Validator' 74 | ``` 75 | 76 | Then, run the following command: 77 | 78 | ```bash 79 | $ pod install 80 | ``` 81 | 82 | 83 | ### Carthage 84 | 85 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 86 | 87 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 88 | 89 | ```bash 90 | $ brew update 91 | $ brew install carthage 92 | ``` 93 | 94 | To integrate CPF-CNPJ-Validator into your Xcode project using Carthage, specify it in your `Cartfile`: 95 | 96 | ```ogdl 97 | github "fpg1503/CPF-CNPJ-Validator" ~> 1.0 98 | ``` 99 | 100 | Run `carthage update` to build the framework and drag the built `CPF-CNPJ-Validator.framework` into your Xcode project. 101 | 102 | 103 | ## Author 104 | 105 | Francesco Perrotti-Garcia ([@fpg1503](https://github.com/fpg1503)) 106 | 107 | ### Contributing 108 | 109 | All contributions are welcome. Feel free to open Issues and PRs. In case of doubts read our [CONTRIBUTING.md](https://github.com/fpg1503/CPF-CNPJ-Validator/blob/master/CONTRIBUTING.md), open an issue or tweet me [@fpg1503](https://twitter.com/fpg1503). 110 | 111 | ## License 112 | 113 | CPF-CNPJ-Validator is available under the MIT license. See the LICENSE file for more info. 114 | -------------------------------------------------------------------------------- /Source/CPF-CNPJ-Validator.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for CPF-CNPJ-Validator. 4 | FOUNDATION_EXPORT double CPF-CNPJ-ValidatorVersionNumber; 5 | 6 | //! Project version string for CPF-CNPJ-Validator. 7 | FOUNDATION_EXPORT const unsigned char CPF-CNPJ-ValidatorVersionString[]; 8 | 9 | // In this header, you should import all the public headers of your framework using statements like #import 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source/CPF-CNPJ-Validator.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum Status { 4 | case valid 5 | case wrongLength 6 | case repeatedPattern 7 | case commonNumber 8 | case invalid 9 | } 10 | 11 | public struct ValidationOptions: OptionSet { 12 | public let rawValue: Int 13 | 14 | public init(rawValue: Int) { 15 | self.rawValue = rawValue 16 | } 17 | 18 | public static let addLeadingZeros = ValidationOptions(rawValue: 1 << 0) 19 | public static let ignoreRemainingCharacters = ValidationOptions(rawValue: 1 << 1) 20 | public static let interpretOnlyNumbers = ValidationOptions(rawValue: 1 << 2) 21 | public static let allowRepeatedPatterns = ValidationOptions(rawValue: 1 << 3) 22 | public static let allowCommonNumbers = ValidationOptions(rawValue: 1 << 4) 23 | } 24 | 25 | public enum Kind { 26 | case CPF 27 | case CNPJ 28 | 29 | var length: Int { 30 | switch self { 31 | case .CPF: return 11 32 | case .CNPJ: return 14 33 | } 34 | } 35 | } 36 | 37 | public protocol Validator { 38 | associatedtype T 39 | 40 | func validate(cpf: String, options: ValidationOptions) -> T 41 | func validate(cnpj: String, options: ValidationOptions) -> T 42 | 43 | func validate(_ string: String, kind: Kind, options: ValidationOptions) -> T 44 | } 45 | 46 | extension Validator { 47 | public func validate(cpf: String, options: ValidationOptions = []) -> T { 48 | return validate(cpf, kind: .CPF, options: options) 49 | } 50 | 51 | public func validate(cnpj: String, options: ValidationOptions = []) -> T { 52 | return validate(cnpj, kind: .CNPJ, options: options) 53 | } 54 | } 55 | 56 | public struct StatusValidator: Validator { 57 | 58 | public init() { } 59 | 60 | public func validate(_ string: String, kind: Kind, options: ValidationOptions = []) -> Status { 61 | guard isValid(string, options: options) else { return .invalid } 62 | 63 | let desiredLength = kind.length 64 | let cleanString = clean(string, options: options, length: desiredLength) 65 | 66 | guard cleanString.count == desiredLength else { return .wrongLength } 67 | 68 | guard options.contains(.allowRepeatedPatterns) || 69 | !isRepeatedPattern(cleanString) else { 70 | return .repeatedPattern 71 | } 72 | 73 | guard options.contains(.allowCommonNumbers) || 74 | !isCommonNumber(cleanString) else { 75 | return .commonNumber 76 | } 77 | 78 | return validate(cleanString, kind: kind) ? .valid : .invalid 79 | } 80 | } 81 | 82 | public struct BooleanValidator: Validator { 83 | 84 | public init() { } 85 | 86 | let statusValidator = StatusValidator() 87 | public func validate(_ string: String, kind: Kind, options: ValidationOptions = []) -> Bool { 88 | let validationStatus = statusValidator.validate(string, kind: kind, options: options) 89 | 90 | return validationStatus == .valid 91 | } 92 | } 93 | 94 | fileprivate extension Validator { 95 | fileprivate func isValid(_ string: String, options: ValidationOptions) -> Bool { 96 | guard !options.contains(.interpretOnlyNumbers) else { return true } 97 | 98 | let characters = string.map { String($0) } 99 | let allowedCharacterSet = CharacterSet(charactersIn: "0123456789-./") 100 | let charactersRemovingAllowedCharacters = characters.filter { 101 | $0.rangeOfCharacter(from: allowedCharacterSet) == nil 102 | } 103 | 104 | return charactersRemovingAllowedCharacters.count == 0 105 | } 106 | 107 | 108 | fileprivate func clean(_ string: String, options: ValidationOptions, length: Int) -> [Int] { 109 | let characters = string.map { String($0) } 110 | let numbers = characters.map { Int($0) }.flatMap { $0 } 111 | 112 | let count = numbers.count 113 | 114 | if count > length && options.contains(.ignoreRemainingCharacters) { 115 | return Array(numbers[0.. Bool { 126 | return Set(numbers).count <= 1 127 | } 128 | 129 | fileprivate func isCommonNumber(_ numbers: [Int]) -> Bool { 130 | let number = numbers.map { String($0) }.reduce("", +) 131 | let commonNumbers = ["12345678909"] 132 | 133 | return commonNumbers.contains(number) 134 | } 135 | 136 | fileprivate func validate(_ numbers: [Int], kind: Kind) -> Bool { 137 | switch kind { 138 | case .CPF: 139 | guard numbers.count == 11 else { return false } 140 | let digits = Array(numbers[0..<9]) 141 | let firstDigit = checkDigit(for: digits, upperBound: 9, lowerBound: 0, mod: 11) 142 | let secondDigit = checkDigit(for: digits + [firstDigit], upperBound: 9, lowerBound: 0, mod: 11) 143 | 144 | return firstDigit == numbers[9] && secondDigit == numbers[10] 145 | case .CNPJ: 146 | guard numbers.count == 14 else { return false } 147 | let digits = Array(numbers[0..<12]) 148 | let firstDigit = checkDigit(for: digits, upperBound: 9, lowerBound: 2, mod: 11) 149 | let secondDigit = checkDigit(for: digits + [firstDigit], upperBound: 9, lowerBound: 2, mod: 11) 150 | 151 | return firstDigit == numbers[12] && secondDigit == numbers[13] 152 | } 153 | } 154 | 155 | private func checkDigit(for digits: [Int], upperBound: Int, lowerBound: Int, mod: Int, secondMod: Int = 10) -> Int { 156 | guard lowerBound < upperBound else { preconditionFailure("lower bound is greater than upper bound") } 157 | 158 | let factors = Array((lowerBound...upperBound).reversed()) 159 | 160 | let multiplied = digits.reversed().enumerated().map { 161 | return $0.element * factors[$0.offset % factors.count] 162 | } 163 | 164 | let sum = multiplied.reduce(0, +) 165 | 166 | return (sum % mod) % secondMod 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Source/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tests/CPF-CNPJ-ValidatorTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import CPF_CNPJ_Validator 3 | 4 | class CPF_CNPJ_ValidatorTests: XCTestCase { 5 | 6 | let validator = StatusValidator() 7 | 8 | func testEmptyCPF() { 9 | let cpf = "" 10 | let status = validator.validate(cpf: cpf) 11 | XCTAssertEqual(status, Status.wrongLength) 12 | } 13 | 14 | func testEmptyCPFAddingLeadingZeros() { 15 | let cpf = "" 16 | let status = validator.validate(cpf: cpf, options: [.addLeadingZeros]) 17 | XCTAssertEqual(status, Status.repeatedPattern) 18 | } 19 | 20 | func testEmptyCPFAddingLeadingAllowingRepeatedPatterns() { 21 | let cpf = "" 22 | let status = validator.validate(cpf: cpf, options: [.addLeadingZeros, .allowRepeatedPatterns]) 23 | XCTAssertEqual(status, Status.valid) 24 | } 25 | 26 | func testShortCPF() { 27 | let cpf = "123" 28 | let status = validator.validate(cpf: cpf) 29 | XCTAssertEqual(status, Status.wrongLength) 30 | } 31 | 32 | func testLongCPF() { 33 | let cpf = "1234567890912345678909" 34 | let status = validator.validate(cpf: cpf) 35 | XCTAssertEqual(status, Status.wrongLength) 36 | } 37 | 38 | func testLongCPFIgnoringRemainingCharacters() { 39 | let cpf = "1234567890912345678909" 40 | let status = validator.validate(cpf: cpf, options: [.ignoreRemainingCharacters]) 41 | XCTAssertEqual(status, Status.commonNumber) 42 | } 43 | 44 | func testLongCPFIgnoringRemainingCharactersAllowingCommonNumbers() { 45 | let cpf = "1234567890912345678909" 46 | let status = validator.validate(cpf: cpf, options: [.ignoreRemainingCharacters, .allowCommonNumbers]) 47 | XCTAssertEqual(status, Status.valid) 48 | } 49 | 50 | func testInvalidCPF() { 51 | let cpf = "01002003040" 52 | let status = validator.validate(cpf: cpf) 53 | XCTAssertEqual(status, Status.invalid) 54 | } 55 | 56 | func testValidCPF() { 57 | let cpf = "01002003032" 58 | let status = validator.validate(cpf: cpf) 59 | XCTAssertEqual(status, Status.valid) 60 | } 61 | 62 | func testValidCPFWithLettersMixed() { 63 | let cpf = "01002aaaa003032" 64 | let status = validator.validate(cpf: cpf) 65 | XCTAssertEqual(status, Status.invalid) 66 | } 67 | 68 | func testValidCPFWithLetterMixedInterpretingOnlyNumbers() { 69 | let cpf = "01002aaaa003032" 70 | let status = validator.validate(cpf: cpf, options: [.interpretOnlyNumbers]) 71 | XCTAssertEqual(status, Status.valid) 72 | } 73 | 74 | func testValidFormattedCPF() { 75 | let cpf = "010.020.030-32" 76 | let status = validator.validate(cpf: cpf) 77 | XCTAssertEqual(status, Status.valid) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Tests/CheckCocoaPodsQualityIndexes.rb: -------------------------------------------------------------------------------- 1 | #!/bin/ruby 2 | 3 | # 4 | # CheckCocoaPodsQualityIndexes.rb 5 | # by William Entriken, version 1.0.1 6 | # Part of https://github.com/fulldecent/swift3-module-template 7 | # 8 | # The validates that all controllable quality metrics receive maximum score 9 | # from CocoaPods's scoring quality algorithm 10 | # 11 | # Usage: ruby CheckCocoaPodsQualityIndexes.rb PODNAME 12 | # 13 | 14 | require "json" 15 | require "uri" 16 | require "net/http" 17 | 18 | pod_name = ARGV.shift 19 | 20 | puts "Reviewing CocoaPods's quality metrics for #{pod_name}" 21 | puts "Metrics documentation: https://guides.cocoapods.org/making/quality-indexes.html" 22 | puts "Modifiers from: https://cocoadocs-api-cocoapods-org.herokuapp.com/pods/#{pod_name}/stats" 23 | puts "Raw data from: http://metrics.cocoapods.org/api/v1/pods/#{pod_name}" 24 | puts "NOTE: You must pust a new version to CocoaPods to get new metrics!" 25 | puts "" 26 | 27 | uri = URI.parse('https://cocoadocs-api-cocoapods-org.herokuapp.com/pods/FDTake/stats') 28 | http = Net::HTTP.new(uri.host, uri.port) 29 | http.use_ssl = true if uri.scheme == 'https' 30 | request = Net::HTTP::Get.new uri 31 | response = http.request(request) 32 | 33 | if !response.is_a? Net::HTTPOK 34 | puts "HTTP fetching error!" 35 | exit 1 36 | end 37 | 38 | passing = true 39 | for metric in JSON.parse(response.body)['metrics'] 40 | if ['Verified Owner', 'Very Popular', 'Popular'].include? metric['title'] 41 | puts "SKIPPED\tYou cannot control: " + metric['title'] 42 | next 43 | end 44 | if metric['modifier'] >= 0 45 | if metric['applies_for_pod'] 46 | puts "GOOD\tEarned points for: " + metric['title'] 47 | else 48 | puts "BAD\tMissed points for: " + metric['title'] 49 | passing = false 50 | end 51 | else 52 | if metric['applies_for_pod'] 53 | puts "BAD\tLost points for: " + metric['title'] 54 | passing = false 55 | else 56 | puts "GOOD\tAvoided penalty for: " + metric['title'] 57 | end 58 | end 59 | end 60 | 61 | exit passing ? 0 : 1 62 | -------------------------------------------------------------------------------- /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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /iOS Example/Source/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | class AppDelegate: UIResponder, UIApplicationDelegate { 5 | var window: UIWindow? 6 | } 7 | -------------------------------------------------------------------------------- /iOS Example/Source/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /iOS Example/Source/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 | 27 | 28 | -------------------------------------------------------------------------------- /iOS Example/Source/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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /iOS Example/Source/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /iOS Example/Source/ViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import CPF_CNPJ_Validator 3 | 4 | class ViewController: UIViewController { 5 | @IBOutlet fileprivate var textField: UITextField? 6 | @IBOutlet fileprivate var label: UILabel? 7 | 8 | var text = "" { 9 | didSet { 10 | let success = BooleanValidator().validate(cpf: text) 11 | label?.text = success ? "CPF Válido" : "CPF Inválido" 12 | } 13 | } 14 | } 15 | 16 | extension ViewController { 17 | @IBAction func didChange() { 18 | text = textField?.text ?? "" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /iOS Example/iOS Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D95E1C451D88E71A00F94976 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95E1C441D88E71A00F94976 /* AppDelegate.swift */; }; 11 | D95E1C471D88E71A00F94976 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95E1C461D88E71A00F94976 /* ViewController.swift */; }; 12 | D95E1C4A1D88E71A00F94976 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D95E1C481D88E71A00F94976 /* Main.storyboard */; }; 13 | D95E1C4C1D88E71A00F94976 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D95E1C4B1D88E71A00F94976 /* Assets.xcassets */; }; 14 | D95E1C4F1D88E71A00F94976 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D95E1C4D1D88E71A00F94976 /* LaunchScreen.storyboard */; }; 15 | D95E1C8A1D88F39300F94976 /* CPF_CNPJ_Validator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D95E1C891D88F39300F94976 /* CPF_CNPJ_Validator.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | D95E1C411D88E71A00F94976 /* iOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | D95E1C441D88E71A00F94976 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | D95E1C461D88E71A00F94976 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | D95E1C491D88E71A00F94976 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | D95E1C4B1D88E71A00F94976 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | D95E1C4E1D88E71A00F94976 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | D95E1C501D88E71A00F94976 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | D95E1C891D88F39300F94976 /* CPF_CNPJ_Validator.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CPF_CNPJ_Validator.framework; path = "../build/Debug-iphoneos/CPF_CNPJ_Validator.framework"; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | D95E1C3E1D88E71A00F94976 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | D95E1C8A1D88F39300F94976 /* CPF_CNPJ_Validator.framework in Frameworks */, 35 | ); 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXFrameworksBuildPhase section */ 39 | 40 | /* Begin PBXGroup section */ 41 | D95E1C381D88E71A00F94976 = { 42 | isa = PBXGroup; 43 | children = ( 44 | D95E1C431D88E71A00F94976 /* Source */, 45 | D95E1C421D88E71A00F94976 /* Products */, 46 | D95E1C881D88F39300F94976 /* Frameworks */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | D95E1C421D88E71A00F94976 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | D95E1C411D88E71A00F94976 /* iOS Example.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | D95E1C431D88E71A00F94976 /* Source */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | D95E1C441D88E71A00F94976 /* AppDelegate.swift */, 62 | D95E1C461D88E71A00F94976 /* ViewController.swift */, 63 | D95E1C481D88E71A00F94976 /* Main.storyboard */, 64 | D95E1C4B1D88E71A00F94976 /* Assets.xcassets */, 65 | D95E1C4D1D88E71A00F94976 /* LaunchScreen.storyboard */, 66 | D95E1C501D88E71A00F94976 /* Info.plist */, 67 | ); 68 | path = Source; 69 | sourceTree = ""; 70 | }; 71 | D95E1C881D88F39300F94976 /* Frameworks */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | D95E1C891D88F39300F94976 /* CPF_CNPJ_Validator.framework */, 75 | ); 76 | name = Frameworks; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | D95E1C401D88E71A00F94976 /* iOS Example */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = D95E1C531D88E71A00F94976 /* Build configuration list for PBXNativeTarget "iOS Example" */; 85 | buildPhases = ( 86 | D95E1C3D1D88E71A00F94976 /* Sources */, 87 | D95E1C3E1D88E71A00F94976 /* Frameworks */, 88 | D95E1C3F1D88E71A00F94976 /* Resources */, 89 | ); 90 | buildRules = ( 91 | ); 92 | dependencies = ( 93 | ); 94 | name = "iOS Example"; 95 | productName = "iOS Example"; 96 | productReference = D95E1C411D88E71A00F94976 /* iOS Example.app */; 97 | productType = "com.apple.product-type.application"; 98 | }; 99 | /* End PBXNativeTarget section */ 100 | 101 | /* Begin PBXProject section */ 102 | D95E1C391D88E71A00F94976 /* Project object */ = { 103 | isa = PBXProject; 104 | attributes = { 105 | LastSwiftUpdateCheck = 0800; 106 | LastUpgradeCheck = 0900; 107 | ORGANIZATIONNAME = "Francesco Perrotti-Garcia"; 108 | TargetAttributes = { 109 | D95E1C401D88E71A00F94976 = { 110 | CreatedOnToolsVersion = 8.0; 111 | LastSwiftMigration = 0900; 112 | ProvisioningStyle = Automatic; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = D95E1C3C1D88E71A00F94976 /* Build configuration list for PBXProject "iOS Example" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = D95E1C381D88E71A00F94976; 125 | productRefGroup = D95E1C421D88E71A00F94976 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | D95E1C401D88E71A00F94976 /* iOS Example */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | D95E1C3F1D88E71A00F94976 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | D95E1C4F1D88E71A00F94976 /* LaunchScreen.storyboard in Resources */, 140 | D95E1C4C1D88E71A00F94976 /* Assets.xcassets in Resources */, 141 | D95E1C4A1D88E71A00F94976 /* Main.storyboard in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | D95E1C3D1D88E71A00F94976 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | D95E1C471D88E71A00F94976 /* ViewController.swift in Sources */, 153 | D95E1C451D88E71A00F94976 /* AppDelegate.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin PBXVariantGroup section */ 160 | D95E1C481D88E71A00F94976 /* Main.storyboard */ = { 161 | isa = PBXVariantGroup; 162 | children = ( 163 | D95E1C491D88E71A00F94976 /* Base */, 164 | ); 165 | name = Main.storyboard; 166 | sourceTree = ""; 167 | }; 168 | D95E1C4D1D88E71A00F94976 /* LaunchScreen.storyboard */ = { 169 | isa = PBXVariantGroup; 170 | children = ( 171 | D95E1C4E1D88E71A00F94976 /* Base */, 172 | ); 173 | name = LaunchScreen.storyboard; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXVariantGroup section */ 177 | 178 | /* Begin XCBuildConfiguration section */ 179 | D95E1C511D88E71A00F94976 /* Debug */ = { 180 | isa = XCBuildConfiguration; 181 | buildSettings = { 182 | ALWAYS_SEARCH_USER_PATHS = NO; 183 | CLANG_ANALYZER_NONNULL = YES; 184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 185 | CLANG_CXX_LIBRARY = "libc++"; 186 | CLANG_ENABLE_MODULES = YES; 187 | CLANG_ENABLE_OBJC_ARC = YES; 188 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_COMMA = YES; 191 | CLANG_WARN_CONSTANT_CONVERSION = YES; 192 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 193 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 202 | CLANG_WARN_STRICT_PROTOTYPES = YES; 203 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 204 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 205 | CLANG_WARN_UNREACHABLE_CODE = YES; 206 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 207 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 208 | COPY_PHASE_STRIP = NO; 209 | DEBUG_INFORMATION_FORMAT = dwarf; 210 | ENABLE_STRICT_OBJC_MSGSEND = YES; 211 | ENABLE_TESTABILITY = YES; 212 | GCC_C_LANGUAGE_STANDARD = gnu99; 213 | GCC_DYNAMIC_NO_PIC = NO; 214 | GCC_NO_COMMON_BLOCKS = YES; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 221 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 222 | GCC_WARN_UNDECLARED_SELECTOR = YES; 223 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 224 | GCC_WARN_UNUSED_FUNCTION = YES; 225 | GCC_WARN_UNUSED_VARIABLE = YES; 226 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 227 | MTL_ENABLE_DEBUG_INFO = YES; 228 | ONLY_ACTIVE_ARCH = YES; 229 | SDKROOT = iphoneos; 230 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 231 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 232 | TARGETED_DEVICE_FAMILY = "1,2"; 233 | }; 234 | name = Debug; 235 | }; 236 | D95E1C521D88E71A00F94976 /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_ANALYZER_NONNULL = YES; 241 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 242 | CLANG_CXX_LIBRARY = "libc++"; 243 | CLANG_ENABLE_MODULES = YES; 244 | CLANG_ENABLE_OBJC_ARC = YES; 245 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_COMMA = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 257 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 258 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 259 | CLANG_WARN_STRICT_PROTOTYPES = YES; 260 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 261 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 262 | CLANG_WARN_UNREACHABLE_CODE = YES; 263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 281 | TARGETED_DEVICE_FAMILY = "1,2"; 282 | VALIDATE_PRODUCT = YES; 283 | }; 284 | name = Release; 285 | }; 286 | D95E1C541D88E71A00F94976 /* Debug */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | INFOPLIST_FILE = Source/Info.plist; 291 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 292 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.iOS-Example"; 293 | PRODUCT_NAME = "$(TARGET_NAME)"; 294 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 295 | SWIFT_VERSION = 4.0; 296 | }; 297 | name = Debug; 298 | }; 299 | D95E1C551D88E71A00F94976 /* Release */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 303 | INFOPLIST_FILE = Source/Info.plist; 304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 305 | PRODUCT_BUNDLE_IDENTIFIER = "com.perrotti-garcia.iOS-Example"; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 308 | SWIFT_VERSION = 4.0; 309 | }; 310 | name = Release; 311 | }; 312 | /* End XCBuildConfiguration section */ 313 | 314 | /* Begin XCConfigurationList section */ 315 | D95E1C3C1D88E71A00F94976 /* Build configuration list for PBXProject "iOS Example" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | D95E1C511D88E71A00F94976 /* Debug */, 319 | D95E1C521D88E71A00F94976 /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | defaultConfigurationName = Release; 323 | }; 324 | D95E1C531D88E71A00F94976 /* Build configuration list for PBXNativeTarget "iOS Example" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | D95E1C541D88E71A00F94976 /* Debug */, 328 | D95E1C551D88E71A00F94976 /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | /* End XCConfigurationList section */ 334 | }; 335 | rootObject = D95E1C391D88E71A00F94976 /* Project object */; 336 | } 337 | -------------------------------------------------------------------------------- /iOS Example/iOS Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | --------------------------------------------------------------------------------