`swift build` on Terminal throw `error: root manifest not found`
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:
- 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 calledImage 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.
When you use from
-Swift build
command you must use from Swift Package Manager and you should have 2 folder on the directory :
SourceTest
you should use the below 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 below command for workspcae:
- 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