UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: hackingwithmacos ArgumentParser Library not loaded

Forums > macOS

Hello!

I am on Ventura 13.0 Following the instructions of the 4th project in hackingwithmacos.

It builds successfully, but this error shows up:

Library not loaded: @rpath/ArgumentParser.framework/Versions/A/ArgumentParser Referenced from: <E739D89A-A284-3F24-B6E0-0AFAAA9DA076> /Users/eldarsadykov/Library/Developer/Xcode/DerivedData/TextParser-dnxyhkkdpuisukavhgstgcvfpkwl/Build/Products/Debug/TextParser Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@rpath/ArgumentParser.framework/Versions/A/ArgumentParser' (no such file), '/Library/Frameworks/ArgumentParser.framework/Versions/A/ArgumentParser' (no such file), '/System/Library/Frameworks/ArgumentParser.framework/Versions/A/ArgumentParser' (no such file, not in dyld cache) zsh: abort ./TextParser Designed by Steve Jobs in New York

My code:

import ArgumentParser
import Foundation
import NaturalLanguage

@main
struct App: ParsableCommand {
    @Argument(help: "The text you want to analyze")
    var input: [String]
    mutating func run() {
        let text = input.joined(separator: " ")
        let language = NLLanguageRecognizer.dominantLanguage(for: text) ?? .undetermined
        print()
        print("Detected language: \(language.rawValue)")

        print(text)
        print()
        let sentiment = sentiment(for: text)
        print("Sentiment analysis: \(sentiment)")
        print()
        let lemma = lemmatize(string: text)
        print()
        print("Found the following alternatives:")
        for word in lemma {
            let embeddings = embeddings(for: word)
            print("\t\(word): ", embeddings.formatted(.list(type: .and)))
        }
        let entities = entities(for: text)
        print()
        print("Found the following entities:")
        for entity in entities {
            print("\t", entity)
        }
    }

    func sentiment(for string: String) -> Double {
        let tagger = NLTagger(tagSchemes: [.sentimentScore])
        tagger.string = string
        let (sentiment, _) = tagger.tag(at: string.startIndex, unit: .paragraph, scheme: .sentimentScore)
        return Double(sentiment?.rawValue ?? "0") ?? 0
    }

    func embeddings(for word: String) -> [String] {
        var results = [String]()
        if let embedding = NLEmbedding.wordEmbedding(for: .english) {
            let similarWords = embedding.neighbors(for: word, maximumCount: 10)
            for word in similarWords {
                results.append("\(word.0) has a distance of \(word.1)")
            }
        }
        return results
    }

    func lemmatize(string: String) -> [String] {
        let tagger = NLTagger(tagSchemes: [.lemma])
        tagger.string = string
        var results = [String]()
        tagger.enumerateTags(in: string.startIndex ..< string.endIndex,
                             unit: .word, scheme: .lemma) { tag, range in
            let stemForm = tag?.rawValue ??
                String(string[range]).trimmingCharacters(in: .whitespaces)
            if stemForm.isEmpty == false {
                results.append(stemForm)
            }
            return true
        }
        return results
    }

    func entities(for string: String) -> [String] {
        let tagger = NLTagger(tagSchemes: [.nameType])
        tagger.string = string
        var results = [String]()
        tagger.enumerateTags(in: string.startIndex ..< string.endIndex,
                             unit: .word,
                             scheme: .nameType,
                             options: .joinNames) { tag, range in
            guard let tag = tag else { return true }
            let match = String(string[range])
            switch tag {
            case .organizationName:
                results.append("Organization: \(match)")
            case .personalName:
                results.append("Person: \(match)")
            case .placeName:
                results.append("Place: \(match)")
            default:
                break
            }
            return true
        }
        return results
    }
}

3      

Solved: package reinstall helped

3      

@matt  

I was having the same issue. My problem was I had both the checkboxes, Library and Executable selected, but I only needed the Library.

4      

I just tried adding it again with only the Library checked and it hasn't fixed it. I'll try a full reboot.

3      

Rebooting hasn't worked. If anyone has any suggestions or ideas I'd really appreciate it. I might try rebuilding from a new project and see what happens.

3      

Rebuilding it in a new project with a new name has worked. Without knowing what the problem was I don't think it can really be called solved, but at least there's forward motion again :-)

4      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.