Import github packages without IDE

I have to audit a swift project, but I'm not an Apple user. After some problems with the swift package for Ubuntu I compiled swift for debian 9 and it works.

As a Linux user I work under the assumption that Linux is the IDE, hence I use simple text editors to write software.

Now I want to write a simple main(), but include a project from github. Unfortunately I can not find any reference how to import github projects properly. afaik, xcode and similar systems automate that but that is not an option in my case.

So I would like to know, what to do exactly. Thanks

Assuming you have a swift toolchain installed:

$ cd /tmp/example
$ swift package init --type executable --name mycommand

...and then edit Package.swift

1 Like

This is the domain of the Swift Package Manager. The documentation is here.

1 Like

I have osne that and I see the file that defines packages. But how do I update that file exactly (where is this documented)?

At that point the docs pointed to by Cory would be most helpful, especially this page.

1 Like

thanks for the fast reply...

Looks like this does not work in any case:

// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "xxxaudit",
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/xxx", from: "0.0.0"),
],
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: "xxxaudit",
dependencies: ),
.testTarget(
name: "xxxauditTests",
dependencies: ["xxxaudit"]),
]
)

https://github.com/xxx @ 0.0.5: error: https://github.com/xxx has no Package.swift manifest for version 0.0.5

Unfortunately I can not say which github project I'm referring too. Hope this makes sense anyways.

The Github repo that you are adding as a dependency has to also be a Swift Package. Is it? e.g. Does it have a Package.swift file in its root? (not that that in itself makes a package, but if it is a package it will have a file like that at its root.)

I assume that the GitHub repo is in the Swift language?

Its swift yes. But no it has no Package.swift. It has:

project.yml
cartfile
.podspec
gemfile

That looks like a Carthage package to me.

I'm not that familiar with Carthage, but I suspect it requires Xcode. The Carthage docs may help you....

Or, you could contact the authors of the package and see if they are willing/able to make it available as a Swift Package Manager package.

Ok so the question is how to import Carthage projects in general OS swift projects?

Looking at the docs (linked below), it seems that Carthage is designed to be used with Xcode projects only, so that would limit them to working on macOS.