2. How to configuration StarPRNT Application

2.1. Add iOS StarPRNT SDK to project

StarPRNT SDK library supports CocoaPods and Framework.Please link library that suits your application configuration.

Important

SMCloudServices Library

You need to add when using Star Micronics Cloud (AllReceipts, etc.) in the application.

2.1.1. Using CocoaPods

  1. Insert following code in Podfile.

    pod 'StarIO', 'StarIOVersion'
    pod 'StarIO_Extension', 'StarIOExtensionVersion'
    pod 'SMCloudServices', 'SMCloudServicesVersion'
    

Note

Please refer to Podfile in SDK for the latest library version.

  1. And then run

    pod install
    

2.1.2. Using Framework

  1. Add StarIO.framework to “Link Binary With Libraries” on the Build Phases tab.

  2. Add StarIO_Extension.framework to “Link Binary With Libraries” on the Build Phases tab.

  3. Add SMCloudServices.framework to “Link Binary With Libraries” on the Build Phases tab.

  4. Add SMCloudServicesResources.bundle in the SMCloudServices.framework folder to “Copy Bundle Resources” on the Build Phases tab.

  5. Add following frameworks to Project.

    • CoreBluetooth.framework
    • ExternalAccessory.framework

2.2. Edit information property list.

2.2.1. Set Supported external accessory protocols

When using Bluetooth printer

Warning

Please do not apply this, if you are not using Bluetooth ineterface.

  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Supported external accessory protocols Key.
  3. Click the triangle of this key and set the value for the “Item 0” to jp.star-m.starpro .

2.2.2. Set Bluetooth Always Usage Description

When using Bluetooth Low Energy printer on iOS13 or later

  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Privacy Bluetooth Always Usage Description Key.
  3. Set the reason for using Bluetooth in Value (e.g. Use Bluetooth for communication with the printer. )
  4. When communicating with the Bluetooth Low Energy printer on iOS13 or higher, an alert requesting permission to access Bluetooth is displayed. The string set in Value is displayed in the alert as the reason for using Bluetooth.
../_images/configure_application_bluetooth_always_usage_description_ios.png

2.3. Add Objective-C Bridging Header

Development with Swift

Frameworks included in the iOS StarPRNT SDK are written in Objective-C. To use them in Swift, you need to add Objective-C Bridging-Header to your project.

  1. Select FileNewFile… from Xcode menu.

  2. Select the Header File , and then click Next .

  3. Enter a name and click Create to create an empty header file. In the example shown below, the header file name is “StarIO_Extension-Bridging-Header.h”.

  4. Write the following import lines in the header file created.

    #import <StarIO/SMPortSwift.h>
    
    #import <StarIO_Extension/StarIoExt.h>
    #import <StarIO_Extension/StarIoExtManager.h>
    #import <StarIO_Extension/SMBluetoothManagerFactory.h>
    #import <StarIO_Extension/SMSoundSetting.h>
    
    // To use SMCloudServices.framework, you also need to write the following lines.
    #import <SMCloudServices/SMCloudServices.h>
    #import <SMCloudServices/SMCSAllReceipts.h>
    
  5. Specify the path to the created header file at Objective-C Bridging Header of Build Settings.

../_images/configure_application_objective-c_bridging_header.png

Then, you can use frameworks in Swift.