You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I posted this topic on the Swift discussion forums a couple of weeks ago, but didn't get very far. I'm hoping that someone with deeper working knowledge of swift-argument-parser's internals could provide some guidance.
I'm having a terrible time figuring out how to compile a single .swift file using swiftc against a downloaded & locally-built copy of ArgumentParser, without using SPM for the executable.
For background on why I want to do this seemingly-strange thing:
I'm not a professional programmer, but rather an advanced AppleScript user, who's bumping his head against the ceiling of what is possible in ASObjC (namely: blocks, completion handlers).
For this, I have many small (1 - 20 line) compiled helper executables that I can run from AppleScript, which let me use the methods unavailable in ASObjC. I initially wrote these in Objective-C, but have transitioned to Swift. Right now, I am manually parsing the command-line arguments to these executables, but would really like to use swift-argument-parser.
These executables don't require any other 3rd-party packages, as they're only used to access macOS APIs. For several reasons, it's not currently feasible to have these executables be swift packages, nor is something like the excellent swift-sh the right solution.
I've done some extensive googling on the subject, but haven't found any workable solutions after many evenings spent on this. There's some mention of being able to bundle a SPM package into an XCFramework, but I wasn't able to get this to work either.
I've taken the following general steps:
Download & build the ArgumentParser module.
mkdir ~/Desktop/SPMDownload
cd~/Desktop/SPMDownload
git clone https://github.com/apple/swift-argument-parser
cd swift-argument-parser
swift build -c release
Import & use ArgumentParser in the desired source file, here ~/Desktop/example.swift:
import ArgumentParser
struct Greet: ParsableCommand {
@Argument(help: "The thing to greet.")
var name: String = "World"
mutating func run() throws {
print("Hello, \(name)!")
}
}
Greet.main()
Compile example.swift against ArgumentParser (not working):
What am I missing to be able to link example.swift against ArgumentParser?
It would be great for this feature to be documented somewhere (either here, or in the readme). It would also be great to know if this is supported vs. unsupported but possible vs. impossible. Thanks!
The text was updated successfully, but these errors were encountered:
I posted this topic on the Swift discussion forums a couple of weeks ago, but didn't get very far. I'm hoping that someone with deeper working knowledge of swift-argument-parser's internals could provide some guidance.
I'm having a terrible time figuring out how to compile a single
.swift
file usingswiftc
against a downloaded & locally-built copy of ArgumentParser, without using SPM for the executable.For background on why I want to do this seemingly-strange thing:
I'm not a professional programmer, but rather an advanced AppleScript user, who's bumping his head against the ceiling of what is possible in ASObjC (namely: blocks, completion handlers).
For this, I have many small (1 - 20 line) compiled helper executables that I can run from AppleScript, which let me use the methods unavailable in ASObjC. I initially wrote these in Objective-C, but have transitioned to Swift. Right now, I am manually parsing the command-line arguments to these executables, but would really like to use
swift-argument-parser
.These executables don't require any other 3rd-party packages, as they're only used to access macOS APIs. For several reasons, it's not currently feasible to have these executables be swift packages, nor is something like the excellent swift-sh the right solution.
I've done some extensive googling on the subject, but haven't found any workable solutions after many evenings spent on this. There's some mention of being able to bundle a SPM package into an XCFramework, but I wasn't able to get this to work either.
I've taken the following general steps:
Download & build the ArgumentParser module.
Import & use ArgumentParser in the desired source file, here
~/Desktop/example.swift
:Compile
example.swift
against ArgumentParser (not working):I've tried multiple command-line options here (both with & without trailing whitespace)...
-I
-L
-l
...with various paths in the built ArgumentParser
release
folder located at......with no success.
What am I missing to be able to link
example.swift
against ArgumentParser?It would be great for this feature to be documented somewhere (either here, or in the readme). It would also be great to know if this is supported vs. unsupported but possible vs. impossible. Thanks!
The text was updated successfully, but these errors were encountered: