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

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?

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.

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 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.

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

Related

xcodebuild command fails due to syncfusion_flutter_pdfviewer library

Xcode build fails when executing:
xcodebuild -scheme "Runner" BUILD_DIR=".../_appcircle_temp/appcircle_build_ios_simulator/SimulatorBuildDir" -derivedDataPath ".../_appcircle_temp/appcircle_build_ios_simulator/SimulatorDerivedData" -configuration "Debug" COMPILER_INDEX_STORE_ENABLE=NO ONLY_ACTIVE_ARCH=NO -arch x86_64 -quiet -workspace ".../_appcircle_temp/Repository/ios/Runner.xcworkspace"
Error:
error: Build input file cannot be found: '....syncfusion_flutter_pdfviewer/syncfusion_flutter_pdfviewer.framework/syncfusion_flutter_pdfviewer'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? (in target 'syncfusion_flutter_pdfviewer' from project 'Pods')
I have tried adding syncfusion_flutter_pdfviewer to my POD file, but it stills failing (And documentation doesn't require to adding to pod file)
Any ideas how to solve this?

Error While creating Custom Framework and xcframework

I am creating a Framework where i am adding multiple Third Party Libraries manually. and creating a Fat framework SomeFrameworkName.framework using the script below
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Convenience step to open the project's directory in Finder
open "${PROJECT_DIR}"
After Archiving i am able to get the framework file but when i try to add that framework into the demo project it gives me multiple errors as follows:
dyld: Library not loaded: #rpath/TestIOS.framework/TestIOS
Referenced from: /private/var/containers/Bundle/Application/E76B5EA8-2E7C-44A4-BDCC-A8AB0B37E500/TestAshishDemo.app/TestDemo
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
or else any library names comes in the picture.
and whenever i try to create the xcframework file i get the following error
Failed to build module from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
i am on a crucial stage to solve this error. Anyone if facing the same issue or faced the same along the way they created framework Please Help me out
XCode Version - 12.5.1
In your target project, did you try to embed the Framework ?
(Old XCode screenshot of mine here)

Build Failed Task failed with exit code 65

I am working on a project that uses Carthage, it’s been a couple of months since the last time the project was opened. Now I am trying to move dependencies to .xcframeworks because with the old .framework, it wasn’t working. I encountered various errors and fixed them but there’s one dependency that I can’t fix, 

SwinjectStoryboard
.

I tried using this workaround and setting command line tools
I have also tried creating an empty project with only Swinject and SwinjectStoryboard dependency
but still, my build is failing with the following message
Build Failed Task failed with exit code 65: /usr/bin/xcrun
xcodebuild -project
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard/SwinjectStoryboard.xcodeproj
-scheme SwinjectStoryboard-iOS -configuration Release -derivedDataPath /Users/abu/Library/Caches/org.carthage.CarthageKit/DerivedData/12.5_12E262/SwinjectStoryboard/2.2.0
-sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO
-archivePath /var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/SwinjectStoryboard
SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO
CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO
FRAMEWORK_SEARCH_PATHS=$(inherited)
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcframework-HTlC
(launched in
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard)
This usually indicates that project itself failed to compile. Please
check the xcodebuild log for more details:
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcodebuild.Tafjce.log
I am running the following command to build the dependencies
carthage.sh update --use-xcframeworks --platform iOS
here's my contents of my Cartfile
github "Swinject/Swinject"
github "Swinject/SwinjectStoryboard"
I am stuck on this problem for a couple of days now and would appreciate any help

Framework project A build only device cannot be used to run this target

It's a Framework only project (SWIFT) that builds a library (.framework module) to be linked against projects along with unit tests and is ending up with following errors.
** BUILD SUCCEEDED **
xcodebuild: error: Failed to build project HelloWorld with scheme HelloWorld.
Reason: A build only device cannot be used to run this target.
The command "xcodebuild clean build test -project HelloWorld.xcodeproj -scheme HelloWorld CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO" exited with 70.
My travis yml file is
language: objective-c
branches:
only:
- master
xcode_project: HelloWorld.xcodeproj
xcode_scheme: HelloWorld
osx_image: xcode7.2
script:
- xcodebuild clean build test -project HelloWorld.xcodeproj -scheme HelloWorld CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO
For Xcode 7.2
Try adding -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0'
script:
- xcodebuild clean build test -project HelloWorld.xcodeproj -scheme HelloWorld CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0'

(iphone) build xcode4 project from command line

I've used to build my project with
xcodebuild -proj MyProject.xcodeproj -target MyTarget - configuration Debug -sdk iphonesimulator4.3
this works(it builds fine) but when I hit run in xcode, it recompiles.
(with xcode3, there was no need to rebuild once I build using command line)
I suspect xcode build use workspace/scheme rather than project/target.
How do I find out the workspace name that my current xcode project is using?
Thank you
edit
Chetan's links gave me directions what to look for.
xcode4 stores build output in ~/Library/...
whereas xcodebuild -project .. saves build output in project's build directory.
(if you want the workspace capability, you can't use the build directory for build output)
I created a workspace containing my project and ran
xcodebuild -workspace myWorkSpace -scheme myScheme
this saves build output in ~/Library/...../Debug-iphoneos
whereas xcode4 run button from the same workspace and same scheme saves output in
~/Library/..../Debug-iphonesimulator
any guess on why xcodebuild command uses Debug-iphoneos? :(
edit2
xcodebuild -workspace myWorkSpace -scheme myScheme -sdk iphonesimulator4.3
specifying sdk solved it
I know it isn't strictly the answer to your question, but you can configure the output directory of your build using the CONFIGURATION_BUILD_DIR environment variable.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1