xcodebuild resolves dependency, but can't import the package - xcode

I have a simple command line application, written in swift 5.3, which uses the ArgumentParser package from Apple.
It builds and runs just fine from within Xcode (12.4). However, if I run xcodebuild, as such:
xcodebuild -target mailfilter
It gives this error:
/Users/hacksaw/Documents/src/mailfilter/mailfilter/main.swift:10:8: error: no such module 'ArgumentParser'
import ArgumentParser
^
The relevant project info:
% xcodebuild -list
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list
Resolve Package Graph
Resolved source packages:
swift-argument-parser: https://github.com/apple/swift-argument-parser # 0.3.2
Information about project "mailfilter":
Targets:
mailfilter
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
mailfilter
% xcodebuild -version
Xcode 12.4
Build version 12D4e
So, what command line ought I run for it to build correctly?

So the (still unsatisfying) answer to this is indeed that -scheme needs to be included, so this works:
xcodebuild -scheme mailfilter -target mailfilter
An article I read somewhere said something about xcodebuild having a "legacy" mode which is invoked if you don't include a -scheme argument, but didn't go into detail.
I'd love a more complete answer to this, but for now, I'm leaving it.

Related

What is the message when it is building on Golang?

When I build source on Golang, I saw the warning message, but I couldn't find answer about it.
$ go build --mod=mod -o main main.go
# command-line-arguments
ld: warning: -no_pie is deprecated when targeting new OS versions
specs
version : go version go1.18 darwin/amd64
os : Monterey 12.6
build command : go build --mod=mod -o [binary name] main.go
From GitHub: link
There are a few options:
- wait for the next Go 1.19.x and 1.18.x releases, probably early next month
- build Go from the master branch
- pass -buildmode=pie flag to go build and go test for a workaround
- use older version of the system linker
This seems to be a known issue. See Github for more information.
As a workaround you can pass the -buildmode=pie flag to your go build command.

Github Actions workflow throwing this error 'Could not resolve package dependencies Package.swift manifest for version 1.4.2'

I have a github-action configuration setup for an iOS App, with the following declaration in my CI.yml file:
name: BuildAndTestCI
on:
pull_request:
branches: [master]
jobs:
build-and-test:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_11.3.app
- name: Build and Test
run: xcodebuild clean build test -project sample/sample.xcodeproj -scheme "sample" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation)" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO
But the workflow run and stop with the following error:
xcodebuild: error: Could not resolve package dependencies:
https://github.com/Juanpe/SkeletonView.git has no Package.swift manifest for version 1.4.2
The possible solutions that I've tried are:
Reset package caches
Upgrade the affected packages 'SkeletonView'
Perform a global search where 1.4.2 appears (no-where)
Build and Clean the project multiple times
Also my concerns are:
There is no package that has the version number 1.4.2 and yet the Github-Action Workflow still throws the said error every time a build process is triggered via commit.
There is absolutely no way to do a proper debugging, and I feel like I'm stuck
Below is the full logs of the Github-Action Workflow:
**Set up a job**
Current runner version: '2.284.0'
Operating System
Virtual Environment
Virtual Environment Provisioner
GITHUB_TOKEN Permissions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout#v2' (SHA:ec3a7ce113134d7a93b817d10a8272cb61118579)
**Run actions/checkout#v2**
Run actions/checkout#v2
Syncing repository: repository/sample-ios
Getting Git version info
Deleting the contents of '/Users/runner/work/sample-ios/sample-ios'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
/usr/local/bin/git log -1 --format='%H'
'9ebab3de7d5294064240e266cb4070a52e08c672'
**Select Xcode**
Run sudo xcode-select -switch /Applications/Xcode_11.3.app
**Build and test**
Run xcodebuild clean build test -project sample/sample.xcodeproj -scheme "sample" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation)" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO
Build settings from command line:
CODE_SIGNING_REQUIRED = NO
ONLY_ACTIVE_ARCH = NO
SDKROOT = iphonesimulator13.2
Resolve Package Graph
Fetching https://github.com/Juanpe/SkeletonView.git
Fetching https://github.com/apollographql/apollo-ios.git
Fetching https://github.com/firebase/firebase-ios-sdk.git
Fetching https://github.com/getsentry/sentry-cocoa
Fetching https://github.com/intercom/intercom-ios
xcodebuild: error: Could not resolve package dependencies:
https://github.com/Juanpe/SkeletonView.git has no Package.swift manifest for version 1.4.2
Error: Process completed with exit code 74.

Setting up CI for Catalyst with `pod gen` and `xcodebuild build test`

I'd like to add Catalyst testing to our CI for testing libraries described by podspec's, but running into signing issues:
git clone git#github.com:firebase/firebase-ios-sdk.git
pod gen FirebaseCore.podspec --local-sources=./ --platforms=ios
xcodebuild build test -configuration release -workspace /Users/paulbeusterien/gh8/firebase-ios-sdk/gen/FirebaseCore/FirebaseCore.xcworkspace -scheme FirebaseCore-Unit-unit ARCHS=x86_64h VALID_ARCHS=x86_64h ONLY_ACTIVE_ARCH=NO SUPPORTS_MACCATALYST=YES -sdk macosx CODE_SIGN_IDENTITY=-
After compiling and linking, it fails with
Testing failed:
FirebaseCore-Unit-unit:
AppHost-FirebaseCore-Unit-Tests.app (88189) encountered an error (Failed to load the test bundle. (Underlying error: The bundle “FirebaseCore-Unit-unit” couldn’t be loaded because it is damaged or missing necessary resources. The bundle is damaged or missing necessary resources. dlopen_preflight(/Users/paulbeusterien/Library/Developer/Xcode/DerivedData/FirebaseCore-eyanoskvkatavqdrdwdwryhqqdsc/Build/Products/Release-maccatalyst/AppHost-FirebaseCore-Unit-Tests.app/Contents/PlugIns/FirebaseCore-Unit-unit.xctest/Contents/MacOS/FirebaseCore-Unit-unit): no suitable image found. Did find:
/Users/paulbeusterien/Library/Developer/Xcode/DerivedData/FirebaseCore-eyanoskvkatavqdrdwdwryhqqdsc/Build/Products/Release-maccatalyst/AppHost-FirebaseCore-Unit-Tests.app/Contents/PlugIns/FirebaseCore-Unit-unit.xctest/Contents/MacOS/FirebaseCore-Unit-unit: code signature in (/Users/paulbeusterien/Library/Developer/Xcode/DerivedData/FirebaseCore-eyanoskvkatavqdrdwdwryhqqdsc/Build/Products/Release-maccatalyst/AppHost-FirebaseCore-Unit-Tests.app/Contents/PlugIns/FirebaseCore-Unit-unit.xctest/Contents/MacOS/FirebaseCore-Unit-unit) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)))
Any suggestions?
I needed to add CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO.
The following command builds and runs the tests successfully:
xcodebuild test -configuration Debug -workspace /Users/paulbeusterien/gh8/firebase-ios-sdk/gen/FirebaseCore/FirebaseCore.xcworkspace -scheme FirebaseCore-Unit-unit ARCHS=x86_64h VALID_ARCHS=x86_64h ONLY_ACTIVE_ARCH=NO SUPPORTS_MACCATALYST=YES -sdk macosx CODE_SIGN_IDENTITY=- SUPPORTS_UIKITFORMAC=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
This solution worked for me locally, but only partially on GitHub Actions. With GitHub Actions testspecs that include requires_app_host still failed to run tests. Details in this PR.

Segmentation fault: 11 running Xcode unit tests using xctool

I'm trying to use xctool to run my Xcode unit tests from a Jenkins server for CI purposes. When I run my tests via:
xctool -project MyApp.xcodeproj -scheme MyApp test -sdk iphonesimulator
I get the following error:
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyApp-fxgsgucvulucjcbkdjllermhnvah/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyAppTests.build/Script-FA92AE8E162C5E1900A410A1.sh: line 3: 10301 Segmentation fault: 11 "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
Command /bin/sh failed with exit code 139
If I remove the default Run Script that has:
# Run the unit tests in this test bundle.
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
from my Test target, the call to xctool works fine -- and I can still run my unit tests directly in Xcode via Cmd+U.
I've waded through a lot of searches trying to find the "correct" solution to this but haven't had any luck. Is simply removing that default post build step that calls RunUnitTests acceptable? What does that even do?

xcodebuild cause fatal error but in Xcode, compilation is OK

I have a weird thing when I try to compile with xcodebuild.
If I open the project on the mac with XCode, the code compile without any warning.
If I use the following command line :
xcodebuild -configuration Debug -target myApp PROVISIONING_PROFILE=B5AD0E27-B224-4962-B0DC-XXXXXXXX
I have some compilation error :
/Users/myUser/.jenkins/jobs/myApp/workspace/prj/Controllers/DeclarerEtape1Adresse.m:75:6: error: receiver type 'DeclarerEtape1Adresse' for instance message does not declare a method with selector 'rechercheAdresse' [4]
[self rechercheAdresse];
^
1 error generated.
This errors can appear in external code (taken from github). It seems that the compilator is much strict in command line mode than with Xcode.
Is there any specific configuration in command line ?
Thank you for your feedback.
James, you're the boss :p I tried xcodebuild -version on both environment and the ci server used an old SDK 4.2.X. So I used the sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer and it fixes the issue

Resources