2. How to add the library

2.1. Adding the library to project

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

Please download and confirm the newest SDK and Library from our Global Support Site.

2.1.1. Using CocoaPods

  1. Insert following code in Podfile.

    pod 'StarIO', 'StarIOVersion'
    pod 'StarIO_Extension', 'StarIOExtensionVersion'
    pod 'StarIODeviceSetting', 'StarIODeviceSettingVersion'
    

Note

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

  1. And then run

    pod install
    

2.1.2. Manually adding the link

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

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

  3. Add StarIODeviceSetting.xcframework to “Link Binary With Libraries” on the Build Phases tab.

  4. Add following frameworks to Project.

    • CoreBluetooth.framework
    • ExternalAccessory.framework

Note

If using a StarIODeviceSetting.xcframework, add also a StarIO.xcframework to “Link Binary With Libraries”.

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.2.3. Set Local Network Usage Description

When using Ethernet printer on iOS14 or later

  1. Click on the information property list file (default : “Info.plist”).
  2. Add the Privacy - Local Network Usage Description Key.
  3. Set the reason for using Local Network in Value (e.g. Use Local Network for communication with the printer or discovery the printers. )
  4. When communicating with the Ethernet printer on iOS14 or higher, an alert requesting permission to access Local Network is displayed. The string set in Value is displayed in the alert as the reason for using Local Network.
../_images/configure_application_local_network_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 StarIODeviceSetting.xcframework, you also need to write the following lines.
    #import <StarIODeviceSetting/StarIODeviceSetting.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.