Skip to content

Step 2: iOS Setup

Ioannis Kokkinidis edited this page Sep 26, 2018 · 3 revisions

iOS Setup

Prerequisites:

  • You are using Xcode 9.1+
  • You are using an iOS Base SDK of 11.1 or newer.
  • The deployment target for your app is iOS 11.0 or newer.

1) Download and configure the latest version of SquareReaderSDK.framework in your project root. The framework is installed in the current directory:

ruby <(curl https://connect.squareup.com/readersdk-installer) install
--app-id SQUARE_READER_SDK_APPLICATION_ID
--repo-password SQUARE_READER_SDK_REPOSITORY_PASSWORD

2) Add Reader SDK to your project:

  • Open the General tab for your app target in Xcode.
  • Drag the newly downloaded SquareReaderSDK.framework into the Embedded Binaries section and click "Finish" in the modal that appears.

Note that SQUARE_READER_SDK_APPLICATION_ID and SQUARE_READER_SDK_REPOSITORY_PASSWORD are the credentials you created in step 1.

3) Configure your iOS project for Reader SDK:

Add a Reader SDK build phase

  • Open the Xcode workspace or project for your application.
  • In the Build Phases tab for your application target, click the + button (at the top of the pane).
  • Select New Run Script Phase.
  • Paste the following into the editor panel of the new run script:
FRAMEWORKS="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"
"${FRAMEWORKS}/SquareReaderSDK.framework/setup"

p.s: To avoid "No such file or directory" build errors, make sure the Reader SDK Run Script phase is the last phase in the list.

Add a Reader SDK to your AppDelegate

  • Add the following line in your AppDelegate.m file inside the didFinishLaunchingWithOptions method:
  [SQRDReaderSDK initializeWithApplicationLaunchOptions:launchOptions];

Of course for this to work you'll need to import ReaderSDK in AppDelegate.m like so:

@import SquareReaderSDK;

p.s: If you ever run in a case where @import SquareReaderSDK; causes a Module Not Found error to pop up, that means XCode cannot find SquareReaderSDK.framework which should already be in your project root dir. In that case you'll have to manually add the framework path as a Framework Search Paths value in the project Build Settings (not the target).

4) Disable Bitcode

Reader SDK does not currently support bitcode. To disable Bitcode:

Open the Build Settings tab for your application target. In the top right search field, search for 'bitcode'. Change the value of Enable Bitcode to NO.

5) Add support for required interface orientations

In Xcode, open the General tab for your app target and make sure the Landscape Left and Landscape Right device orientations are supported:

Ios device orientation If your application runs on iPhone, it must support portrait and landscape interface orientations so that Reader SDK can display the signature screen during checkout.

If you want specific screens in your app to only support the portrait orientation, you can override the supportedInterfaceOrientations method in your UIViewController subclasses.

6) Update your Info.plist

Add or update the following key/value pairs in the Info tab for your application target to explain why your application requires these device permissions. Xcode may display human-readable labels (e.g., "Privacy - Microphone Usage Description") rather than the raw keys.

Key Value NSLocationWhenInUseUsageDescription: This app integrates with Square for card processing. To protect buyers and sellers, Square requires your location to process payments.

NSMicrophoneUsageDescription: This app integrates with Square for card processing. To swipe magnetic cards via the headphone jack, Square requires access to the microphone.

NSBluetoothPeripheralUsageDescription: This app integrates with Square for card processing. Square uses Bluetooth to connect your device to compatible hardware.

NSCameraUsageDescription: This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.

NSPhotoLibraryUsageDescription: This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.

p.s: Your application does not need to request Bluetooth, Camera, or Photo Library permissions to use Reader SDK. The usage descriptions are required due to the way Reader SDK is built.

That should get you going, but if you need more info click here