Context: I want to create a simple Swift command line tool using CryptoSwift I am relatively new to Xcode and Swift (and MacOS!).
Configuration:
- MacOS High Sierra 10.13.2
- Xcode: 9.2
Steps:
~/Documents
Fill my main.swift with:
import Foundation
import CryptoSwift
print("Hello, World!")
let bytes:Array<UInt8> = [0x01, 0x02, 0x03]
let digest = Digest.md5(bytes)
Open the shell and go into ~/Documents/cryptodemo
git submodule add https://github.com/krzyzanowskim/CryptoSwift.git
CryptoSwift.xcodeproj
file into my Xcode projectIn Xcode, I go into my project Build Phase
Then I build it. I have this error:
Check dependencies
Unable to run command 'PBXCp CryptoSwift.framework' - this target might include its own product.
Unable to run command 'CodeSign A' - this target might include its own product.
Here is the archive of the project cryptodemo.zip
The only way I managed to build a command line tool using a third-party Swift libraries is to use Swift Package Manager (SPM).
Example of Swift project using SPM (that could be generated using swift package init --type executable
):
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: “mytool”,
dependencies: [
.package(url: "https://github.com/myfreeweb/SwiftCBOR.git", .branch("master")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: “mytool”,
dependencies: [ "SwiftCBOR" ]),
]
)
A Xcode project could be generated from this SPM using: swift package generate-xcodeproj