How to install Swift package via package manager?

后端 未结 4 737
清酒与你
清酒与你 2021-02-12 22:39

I am currently following the document from swift.org to play around with the new Swift Package Manager.

I cloned the demo project from Github and run the following comma

4条回答
  •  [愿得一人]
    2021-02-12 22:52

    I was facing the same issue and in my case, I recently updated my Xcode to 8.2.1 and swift 3.0 comes with it. I was getting this log.

    Ranvijay-Mac-mini:PerfectTemplate ranaranvijaysingh$ swift build
    error: unable to invoke subcommand: /Library/Developer/CommandLineTools/usr/bin/swift-build (No such file or directory)
    

    The path it was taking was incorrect. It was suppose to be:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    


    To change the path, run this command.

    export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH
    

    And DONE.
    Run : swift build again on your project and if you get this error.

    xcrun: error: unable to lookup item 'PlatformPath' from command line tools installation
    xcrun: error: unable to lookup item 'PlatformPath' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
    error: Invalid platform path
    

    then you need to change the SDK path as well.
    In my case, I had two .sdk at path

    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ 
    
    MacOSX.sdk  MacOSX10.12.sdk
    

    To know what is your SDK path, run this command.

    xcrun --sdk macosx --show-sdk-path
    

    My case i got this.

    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    

    To change it run this command.

    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
    

    and NOW DONE. Try running swift build now.

提交回复
热议问题