-
-
Notifications
You must be signed in to change notification settings - Fork 184
Installing ORSSerialPort
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.
This is the preferred way to include ORSSerialPort in your project.
- Open the Xcode project for your app.
- Select the project itself in the Files Navigator.
- Select the project (not the app target) in the Projects and Targets list.
- Select the Package Dependencies tab.
- Click the + button under the Packages list to add a new package dependency.
![Screenshot 2023-07-02 at 3 19 12 PM](https://private-user-images.githubusercontent.com/1057175/250401738-4511cc3e-0efa-4efd-8780-099c4d9369c1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5ODkzNjEsIm5iZiI6MTczODk4OTA2MSwicGF0aCI6Ii8xMDU3MTc1LzI1MDQwMTczOC00NTExY2MzZS0wZWZhLTRlZmQtODc4MC0wOTljNGQ5MzY5YzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMDQzMTAxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzBmYjhkZGFlN2QxNzE3NDRkYjNhMDBmNDNmYTZkNTNhMTgzODdmNDc3MDkyNTM2NDIwZTA0MDAzMjdlMTg5ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.fWudJwufTHlmwcU2Vy-XnhX9rqule5_0cBtzn_eZom8)
- In the Add Package sheet, enter the ORSSerialPort package URL,
https://github.com/armadsen/ORSSerialPort
, in the search field. - Click Add Package in the lower right corner.
![Screenshot 2023-07-02 at 3 20 19 PM](https://private-user-images.githubusercontent.com/1057175/250401741-19fba4c3-4b9b-493c-93a0-dfdcfdddfb17.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5ODkzNjEsIm5iZiI6MTczODk4OTA2MSwicGF0aCI6Ii8xMDU3MTc1LzI1MDQwMTc0MS0xOWZiYTRjMy00YjliLTQ5M2MtOTNhMC1kZmRjZmRkZGZiMTcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMDQzMTAxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTJkYjk4ZWQ2NmQ5ZDdlMzk0NmM3ODUyMjE1ZDZkZjgyNzc4OWQwYjUxZTVkNDY4ZDIwZDcyYzgwYjMzY2QwZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.IjxntR1ntRlwEP33BCpcgj7bjJ-lM0JLpGLdhiHNG3I)
- Import ORSSerialPort in any source files that use it using
import ORSSerial
.
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).
- Open your
Package.swift
file - 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"),
]
- In your project's target, add
"ORSSerial"
to the list of dependencies:
.target(
name: "MyTarget",
dependencies: [
.product(name: "ORSSerial", package: "ORSSerialPort")
]),
-
Import ORSSerialPort into your program's Swift file(s) using
import ORSSerial
. -
Run
swift build
.
Xcode sub-projects allow your project to use and build ORSSerialPort as an implicit dependency.
-
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"
-
Drag
Frameworks/ORSSerialPort/Framework Project/ORSSerialPort.xcodeproj
into your existing Xcode project -
Navigate to your project's settings, then select the target you wish to add ORSSerialPort to
-
Navigate to Build Phases and expand the Link Binary With Libraries section
-
Click the + and find ORSSerial.framework.
-
You should now be able to add
#import <ORSSerial/ORSSerial.h>
(Objective-C) orimport ORSSerial
(Swift) to any of your target's source files and begin using ORSSerialPort.
I've posted a video of this process.
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.
- Create a
Cartfile
for your project. - Add the following line to your Cartfile:
github "armadsen/ORSSerialPort"
- In your project directory, run
carthage update
- Find ORSSerial.framework in
Carthage.build/Mac
. - Navigate to your project's settings, then select the target you wish to add ORSSerialPort to.
- On the General tab, drag ORSSerial.framework from Finder into the "Embedded Binaries" section.
- You should now be able to add
#import <ORSSerial/ORSSerial.h>
(Objective-C) orimport ORSSerial
(Swift) to any of your target's source files and begin using ORSSerialPort.
You can use CocoaPods to add ORSSerialPort to your project. In order to use this method, you must have CocoaPods installed.
-
Add the following line to your
Podfile
:pod "ORSSerialPort"
-
In your project directory, run
pod update
-
You should now be able to add
#import <ORSSerialPort/ORSSerialPort.h>
, etc. to any of your target's source files and begin using ORSSerialPort.
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: