# Swift SDK Verify users with Swift. The Sinch Verification iOS SDK is available for [Swift](https://developer.apple.com/). ## Example usage ```swift import SinchVerification; do { let input = "" // Get user's current region by carrier info let defaultRegion = DeviceRegion.currentCountryCode() let phoneNumber = try PhoneNumberUtil().parse(input, defaultRegion:defaultRegion) let phoneNumberE164 = PhoneNumberUtil().format(phoneNumber, format: PhoneNumberFormat.E164) let verification = SMSVerification(applicationKey:"", phoneNumber: phoneNumberInE164) verification.initiate { (result: InitiationResult, error: NSError?) -> Void in // handle outcome } let code = "" verification.verify(code, completion: { (success: Bool, error:NSError?) -> Void in // handle outcome }) } catch let error as PhoneNumberParseError { // Handle phone number parsing error, i.e. invalid user input. } ``` ## Importing the Sinch Verification Swift SDK ### Import as CocoaPod If you are using [CocoaPods](http://www.cocoapods.org), add the following to your Podfile: ```objectivec platform :ios, '8.0' target '' do use_frameworks! pod 'SinchVerification-Swift' end ``` Note: The directive `useframeworks!` is necessary to make cocoapods add the framework to '_Embedded Binaries'. #### Uploading to App Store / iTunes Connect If you integrate the Sinch SDK via *CocoaPods*, you **must not** check the option "Include bitcode" when uploading the application binary. The reason is because of a [bug in CocoaPods](https://github.com/CocoaPods/CocoaPods/issues/4624). In the upload dialog in Xcode Organizer it should look something like this: ![swift-dont-include-bitcode-upload.png](/assets/ebf587e-swift-dont-include-bitcode-upload.81131aaf08820040e146a9edb2e7ad96b866c1b57aeec37bc5ae58980dd05af7.a39eff33.png) ### Import SinchVerification.framework as *Embedded Binaries* 1. In the Sinch Verification SDK package (SinchVerification-iOS-{VERSION}.tar) there is a *SinchVerification.framework* bundle in the directory named `swift`: ![add-frameworks-package-structure.png](/assets/2cbde47-add-frameworks-package-structure.d055846467c383ff160e9f6cd0927e16890ea01577c1fabf0618522834af1d26.a39eff33.png) 2. Add it to the Xcode target build settings section *Embedded Binaries* (under *General*): ![add-frameworks-embedded-binaries.png](/assets/089382c-add-frameworks-embedded-binaries.6dc6a8eaa914a35f9cd7cffa897ea033eeb5822285a7bd742ace1a797ea2bfd1.a39eff33.png) 3. In the Xcode target build settings, verify that the setting *Runpath Search Paths* is set to `@executable_path/Frameworks`. ![add-frameworks-search-paths.png](/assets/e0bad42-add-frameworks-search-paths.d3d4d2696bed9320bef5d7b71cd68d5e32bc1f802d2fb4f14752f58b4c4283df.a39eff33.png) 4. Setup to run `strip-frameworks.sh` as a *"Run Script Phase"* Create a new *"Run Script Phase"* in your application target's *"Build Phases"* and paste the following snippet: ```shell bash ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/SinchVerification.framework/strip-frameworks.sh ``` ![swift-run-script-add.png](/assets/d73dab6-swift-run-script-add.d6e0880ff0c6a88c03138ca3d67ace7272c3fb47fca6ca2c3b02be268d7c4b1b.a39eff33.png) ![swift-run-script-contents.png](/assets/0f8e419-swift-run-script-contents.498b0178e24670b11cd35e091e524028456a96d1aecf7105217641e588017473.a39eff33.png) (This step is required to work around an App Store / iTunes Connect [bug](http://www.openradar.me/radar?id=6409498411401216)) Make sure that *libc++*, *libz* and *libicucore* are linked (See [here](/docs/verification/ios/ios-first-time-setup)) ![link-binary-with-libraries-xcode.png](/assets/9b2867b-link-binary-with-libraries-xcode.d7205e5e7f0b24f8ddc5a0b2378cc4943a397788edea9ba430a97afc03fdd4f6.a39eff33.png) **That's it!** Now the SDK can be imported as follows (from any of your .swift files) ```swift import SinchVerification ``` Note: This import method requires iOS Deployment Target iOS 8.0 or above. ```Objectivec "images/0f8e419-swift-run-script-contents.png", "swift-run-script-contents.png", 732, 151, "#cecece" ] } ] } ``` (This step is required to work around an App Store / iTunes Connect [bug](http://www.openradar.me/radar?id=6409498411401216)) Make sure that *libc++*, *libz* and *libicucore* are linked (See [here](/docs/verification/ios/ios-first-time-setup)) ![link-binary-with-libraries-xcode.png](/assets/9b2867b-link-binary-with-libraries-xcode.d7205e5e7f0b24f8ddc5a0b2378cc4943a397788edea9ba430a97afc03fdd4f6.a39eff33.png) **That's it!** Now the SDK can be imported as follows (from any of your .swift files). ```swift import SinchVerification ``` Note: This import method requires iOS Deployment Target iOS 8.0 or above.