Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`swift build` on Terminal throw `error: root manifest not found`

I wanna run my swift programing on Terminal, so I cd the root folder of my project, and run $ swift build, but there is a error occurred. $ error: root manifest not found Any help?

like image 928
Scyano Avatar asked Jun 08 '18 06:06

Scyano


3 Answers

In case anyone else stumble upon the same problem, the solution for me was to cd to the Sources folder of my scripts, not the root folder.

like image 146
CyberDandy Avatar answered Oct 20 '22 15:10

CyberDandy


I had this error happen to me when I was building a CLI tool on Xcode. First off, when Xcode talks about root manifest, it means package.swift. You don't have one in your directory or parent directories. I discovered 2 options:

Instead of swift build, use Xcode's UI or xcodebuild CLI and get the build files in finder/ terminal

  • For debug, build the build normally, and you can right click the file generated in the Project Navigator like below:

Xcode screenshot

  • For release build, run Archive in Xcode instead and you can get the build files: Project Name 25-03-2021, 11.30.xcarchive/Products/usr/local/bin/executable in my case the executable is called Image Labeling

or, add a package.swift

Instead of creating the project through Xcode (CLI tool template) use the swift cli tool instead: swift package init --type executable . In this case, swift build works everywhere in the project, not just in Sources because package.swift was added to the root of the project.

like image 4
Ben Butterworth Avatar answered Oct 20 '22 15:10

Ben Butterworth


When you call the

-Swift build

command you must use it from Swift Package Manager and you should have 2 folders in the directory:

Source
Test

you should use the following command for project:

 - name: Build
      run: |
          xcodebuild clean test -project "yourproject.xcproject" -scheme "yourproject" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO

and you should use the following commands for workspace:

- name: Build
     run: |
           xcodebuild clean build -workspace "yourproject.xcworkspace" -scheme "yourtarget" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
     
- name: Test
     run: |
           xcodebuild clean test -workspace "yourproject.xcworkspace" -scheme "yourtargetTests" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
like image 2
Maziar Saadatfar Avatar answered Oct 20 '22 16:10

Maziar Saadatfar