Perfect Assistant - Error in Importing Existing Package - perfect

Version: Perfect Assistant v 3.0.5
Swift: 4.1.2
Target: x86_64-apple-darwin17.7.0
I cloned, built and ran the PerfectTemplate package. Everything runs perfectly (pun intended). I have not (yet) created the Xcode project for this package.
When I try and import this package into Perfect Assistant, it's telling me the package is not a valid SPM (see screen shot):
I'm not sure what's going on here and I'm stuck. I can attached the Package.swift file if needed, but I haven't changed anything from the clone and it builds and runs fine from the command line.
Can anyone share what I'm doing wrong? Thanks.
// Generated automatically by Perfect Assistant Application
// Date: 2017-09-20 19:30:47 +0000
import PackageDescription
let package = Package(
name: "PerfectTemplate",
targets: [],
dependencies: [
.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3),
]
)

Related

How to use Swift Packages in Visual Studio Code?

I'm new with Swift and all this tools.
I've tried to look for guides but they didn't help me. I wanna try to work with packages in VS code.So I decided to add a SwiftyJSON package. This is my Package.swift file:
import PackageDescription
let package = Package(
name: "SwiftyJSON",
dependencies: [
.package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"),
]
)
And I got an error
error: no such module 'PackageDescription' import PackageDescription
For VS Code I use an extension Swift and package dependencies.
It automatically detects a package but when I save my Package.swift file terminal gives me an error:
> Executing task: swift package resolve <
'swiftpackages': error: the manifest is missing a Swift tools version specification;
consider prepending to the manifest '// swift-tools-version: 5.6' to
specify the current Swift toolchain version as the lowest Swift version
supported by the project;
if such a specification already exists, consider moving it to the top
of the manifest, or prepending it with '//' to help Swift Package
Manager find it
The terminal process "/opt/homebrew/bin/zsh '-c', 'swift package
resolve'" failed to launch (exit code: 1).
How I can add packages in VS code?

Downloading Binary-only Swift Packages that require authentication

I am using the Swift Package Manager that is built into Xcode 13.1 (not the command line version that uses Package.swift).
One of my dependencies is a Binary-only package. Here is what the Package.swift of that package looks like:
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "MyLibrary",
products: [
.library(
name: "MyLibrary",
targets: ["MyLibrary"]),
],
dependencies: [],
targets: [
.binaryTarget(
name: "MyLibrary",
url: "https://gitlab.example.com/api/v4/projects/85/packages/generic/mylibrary/1.0.1/MyLibrary.xcframework.zip",
checksum: "..."
)
]
)
The binary is stored in GitLab's Generic Package Repository.
I have added the Git repository that hosts the package to my "Package Dependencies" in my project. I have generated a Personal Access Token that has API and Repository access and added it to my .netrc file:
machine gitlab.example.com
login gitlab-token
password MY_TOKEN_HERE
When I run xcodebuild -resolvePackageDependencies or use "File" -> "Packages" -> "Resolve Package Versions" in the Xcode GUI, the Git repository is cloned successfully but I get the following error message:
failed downloading 'https://gitlab.example.com/api/v4/projects/85/packages/generic/mylibrary/1.0.1/MyLibrary.xcframework.zip' which is required by binary target 'MyLibrary': badResponseStatusCode(401)
I have tried adding the same credentials to the macOS Keychain to see if Xcode can pick them up from there, but I still see the same error.
In the Swift Package Manager CLI source code, I can see that it handles crednetials for binary downloads too, but it seems that Xcode does not.
Unfortunately, I cannot switch from Xcode-integrated packaging to Package.swift packaging because other developers on the project will be confused by it.
Is it possible to get Xcode to use the .netrc credentials for downloading the file too?
Note: Cross-posted to Apple Developer Forum

Runtime error with Xcode-generated project from SPM (dyld: Library not loaded, incompatible library version)

I'm building a command line tool with the Swift Package Manager, using Ink as a dependency.
I'm following this article by John Sundell for reference, and I managed to get the tool to compile and run with swift build -c release.
I also generated a corresponding Xcode project with swift package generate-xcodeproj, so that I can use the debugger and work more effectively.
However, whenever I try to run my tool from Xcode, I get this error:
dyld: Library not loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
Referenced from: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
Reason: Incompatible library version: HIToolbox requires version 1.0.0 or later, but Ink provides version 0.0.0
Program ended with exit code: 9
For reference, here's my Package.swift:
import PackageDescription
let package = Package(
name: "SwiftSiteGen",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(
url: "https://github.com/johnsundell/files.git",
from: "4.0.0"
),
.package(
url: "https://github.com/johnsundell/Ink.git",
from: "0.1.3"
),
],
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: "SwiftSiteGen",
dependencies: ["SwiftSiteGenCore"]),
.target(name: "SwiftSiteGenCore",
dependencies: ["Files", "Ink"]),
.testTarget(
name: "SwiftSiteGenTests",
dependencies: ["SwiftSiteGen"]),
]
)
I'm running on Xcode 11.2.1, on macOS 10.14.4.
Since running swiftc build works, I feel that the problem is with Xcode trying to use dynamic frameworks rather than static libraries. Possibly related question here.
Are there some Xcode project settings I need to change to make this work?
Verified Solution
Do not run swift package generate-xcodeproj.
Instead, just open Package.swift directly in Xcode.
That way, all packages are statically linked.

Swift Package Manager - Speech dependency not loading

I'm encountering an issue creating a Swift Package for my project. I have CocoaPods and Travis CI running and both are working swimmingly, however I now intend to also offer the project through the Swift Package Manager. This is where I'm running into issues. My package file is looking like the following:
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Voxosonus",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Voxosonus",
targets: ["Voxosonus"]),
],
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: "Voxosonus",
path: "Voxosonus"),
.testTarget(
name: "VoxosonusTests",
dependencies: ["Voxosonus"],
path: "VoxosonusTests"),
]
)
However when I run swift build I encounter the following:
/Users/<hidden>/Documents/Projecten/Voxosonus/Voxosonus/SpeechRecognizer.swift:8:8: error: no such module 'Speech'
import Speech
My question is - why is it unable to find the 'Speech' module? This is core functionality from Apple themselves and so far the internet has made me none the wiser. Some details on the project:
Build target: iOS 12.x
macOS: 10.14
Swift Version: 4.2.1
As explained in the Swift Package Manager Github, you can't define the target platform of a Swift Package yet:
At this time there is no explicit support for depending on UIKit,
AppKit, etc, though importing these modules should work if they are
present in the proper system location. We will add explicit support
for system dependencies in the future. Note that at this time the
Package Manager has no support for iOS, watchOS, or tvOS platforms.
So when you are try to build the library with Xcode (or with the swift build command), the compiler can't find the Speech module because it is only available on iOS 10+.
You can check this github project (swift-package-manager-ios) which provides a ruby script that modify the xcodeproj generated by the Swift Package Manager by adding the necessary information in order to build for the iOS platform.

Swift Package Manager Not able to resolve Kitura version above 1.4

I am trying with a sample Swift on server (using Kitura) app and using swift package manager to resolve the dependencies.
Here is my sample Package.swift file.
import PackageDescription
let package = Package(
name: "Kitura_Swift_Server",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 4)
])
My problem is if I change the minor version of Kitura framework to anything above 4, I get the error error: unsatisfiable. Although 1.7.1 is the latest Kitura version but swift build is not resolving it.
Anyone have any idea why it could behave so?
I've seen this issue before when you've already run swift build and the .build directory is created, then you change something in your Package.swift. That said, I've had no issue using Kitura 1.7.x as my lone dependency.
I recommend you change your Kitura version to 1.7.x and run swift package update (in Swift 3.1.1) if you want your dependencies updated.
If that doesn't work, it doesn't hurt to start fresh and delete the .build directory, then run swift build.