Skip to content

Installing ORSSerialPort

Andrew Madsen edited this page Jul 2, 2023 · 12 revisions

There are several ways to add ORSSerialPort to your project. Choose whichever method you're most comfortable with below. The methods are listed roughly in order of my own preference.

Using Xcode

This is the preferred way to include ORSSerialPort in your project.

  1. Open the Xcode project for your app.
  2. Select the project itself in the Files Navigator.
  3. Select the project (not the app target) in the Projects and Targets list.
  4. Select the Package Dependencies tab.
  5. Click the + button under the Packages list to add a new package dependency.
Screenshot 2023-07-02 at 3 19 12 PM
  1. In the Add Package sheet, enter the ORSSerialPort package URL, https://github.com/armadsen/ORSSerialPort, in the search field.
  2. Click Add Package in the lower right corner.
Screenshot 2023-07-02 at 3 20 19 PM
  1. Import ORSSerialPort in any source files that use it using import ORSSerial.

Using Swift Package Manager

ORSSerialPort can be installed using the Swift Package Manager, which is useful if you're using ORSSerialPort in a project built using SPM itself (rather than Xcode).

  1. Open your Package.swift file
  2. Add ORSSerialPort to the list of package dependencies:
dependencies: [
    // Dependencies declare other packages that this package depends on.
    .package(url: "https://github.com/armadsen/ORSSerialPort.git", from: "2.1.0"),
]
  1. In your project's target, add "ORSSerial" to the list of dependencies:
.target(
    name: "MyTarget",
    dependencies: [
        .product(name: "ORSSerial", package: "ORSSerialPort")
    ]),
  1. Import ORSSerialPort into your program's Swift file(s) using import ORSSerial.

  2. Run swift build.

Using an Xcode subproject

Xcode sub-projects allow your project to use and build ORSSerialPort as an implicit dependency.

  1. Add ORSSerialPort to your project as a Git submodule:

    $ cd MyXcodeProjectFolder
    $ git submodule add https://github.com/armadsen/ORSSerialPort.git Frameworks/ORSSerialPort
    $ git commit -m "Added ORSSerialPort submodule"
    
  2. Drag Frameworks/ORSSerialPort/Framework Project/ORSSerialPort.xcodeproj into your existing Xcode project

  3. Navigate to your project's settings, then select the target you wish to add ORSSerialPort to

  4. Navigate to Build Phases and expand the Link Binary With Libraries section

  5. Click the + and find ORSSerial.framework.

  6. You should now be able to add #import <ORSSerial/ORSSerial.h> (Objective-C) or import ORSSerial (Swift) to any of your target's source files and begin using ORSSerialPort.

I've posted a video of this process.

Carthage

Using Carthage, you can easily add ORSSerialPort to your project as a pre-built framework. In order to use this method, you must have Carthage installed.

  1. Create a Cartfile for your project.
  2. Add the following line to your Cartfile:
github "armadsen/ORSSerialPort"
  1. In your project directory, run carthage update
  2. Find ORSSerial.framework in Carthage.build/Mac.
  3. Navigate to your project's settings, then select the target you wish to add ORSSerialPort to.
  4. On the General tab, drag ORSSerial.framework from Finder into the "Embedded Binaries" section.
  5. You should now be able to add #import <ORSSerial/ORSSerial.h> (Objective-C) or import ORSSerial (Swift) to any of your target's source files and begin using ORSSerialPort.

Using CocoaPods

You can use CocoaPods to add ORSSerialPort to your project. In order to use this method, you must have CocoaPods installed.

  1. Add the following line to your Podfile:

    pod "ORSSerialPort"
  2. In your project directory, run pod update

  3. You should now be able to add #import <ORSSerialPort/ORSSerialPort.h>, etc. to any of your target's source files and begin using ORSSerialPort.

Use in Sandboxed Applications

No matter which method you use to install ORSSerialPort, if you are using it in a sandboxed application, as required for apps submitted to the Mac App Store, you must add the com.apple.security.device.serial to your application project's sandbox entitlements file:

Sandbox entitlements screenshot