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

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.

Related

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.

xcodebuild resolves dependency, but can't import the package

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.

pod lib lint fails with bitcode error

I have created custom control for tvOS (https://github.com/Ponf/FPScrollingBanner) and I'm trying to publish it in cocoapods repository. When I'm checking podspec using pod lib lint it fails with next log:
Integrating target `Pods` (`../../../../var/folders/9w/9v94b0_j4l1b_802_my5vlc00000gn/T/CocoaPods/Lint/App.xcodeproj` project)
Adding Build Phase 'Embed Pods Frameworks' to project.
Adding Build Phase 'Copy Pods Resources' to project.
Adding Build Phase 'Check Pods Manifest.lock' to project.
- Running post install hooks
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Building with xcodebuild.
xcodebuild clean build -workspace App.xcworkspace -scheme App -configuration Release CODE_SIGN_IDENTITY=- -sdk appletvsimulator
Build settings from command line:
CODE_SIGN_IDENTITY = -
SDKROOT = appletvsimulator9.1
=== CLEAN TARGET FPScrollingBanner OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
target 'FPScrollingBanner' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
=== BUILD TARGET FPScrollingBanner OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
target 'FPScrollingBanner' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
-> FPScrollingBanner (1.0.0)
- ERROR | [tvOS] xcodebuild: Returned an unsuccessful exit code.
Pods workspace available at `/var/folders/9w/9v94b0_j4l1b_802_my5vlc00000gn/T/CocoaPods/Lint/App.xcworkspace` for inspection.
[!] FPScrollingBanner did not pass validation, due to 1 error.
/Users/filipp/projects/CocoaPods/lib/cocoapods/command/lib.rb:181:in `block in run'
/Users/filipp/projects/CocoaPods/lib/cocoapods/command/lib.rb:153:in `each'
/Users/filipp/projects/CocoaPods/lib/cocoapods/command/lib.rb:153:in `run'
/Users/filipp/.rvm/gems/ruby-2.0.0-p643/bundler/gems/CLAide-4ded02e52c34/lib/claide/command.rb:312:in `run'
/Users/filipp/projects/CocoaPods/lib/cocoapods/command.rb:48:in `run'
/Users/filipp/projects/CocoaPods/bin/pod:44:in `<main>'
So as I can see, the problem is target 'FPScrollingBanner' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform. When I'm opening App.workspace with Xcode, it has no bitcode option at all.
Xcode version: 7.2
Cocoapods built from latest master branch with specifying latest CocoaPods Core.
I have fallback to cocoapods version 0.39.0 and bug doesn't reproduced anymore. It looks like something broken in current master branch.
Maybe you can set *.podspec file:
s.xcconfig = {
'ENABLE_BITCODE' => 'NO'
}
in my *.podspec ,add this will set the framework BITCODE disable.

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?

Building iOS app for iPhone works from xCode but not from command line (xcodebuild)

I am currently trying to streamline our build and release process with an automated build which runs on an OSX server machine , a MacMini running OSX 10.6.7 with xCode 4.0.1 and iOS SDK 4.3 installed (latest release from Apple).
I have followed Mike Nachbaur's excellent guide and it feels like I'm almost there but I still have one final obstacle to overcome.
So. We have our app which build fine on:
a) My laptop from within xCode
b) My laptop from command line with xcodebuild
c) the build machine from within xCode
BUT it does not work on
d) the build machine from the command line with xcodebuild.
Here is the end of the console output:
CreateUniversalBinary build/Distribution-iphoneos/CallControl.app/CallControl normal "armv6 armv7"
cd /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/Users/ainutveckling/Jenkins/tools/jdk6/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/lipo -create /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Callcontrol.build/Distribution-iphoneos/CallControl.build/Objects-normal/armv6/CallControl /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Callcontrol.build/Distribution-iphoneos/CallControl.build/Objects-normal/armv7/CallControl -output /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Distribution-iphoneos/CallControl.app/CallControl
GenerateDSYMFile build/Distribution-iphoneos/CallControl.app.dSYM build/Distribution-iphoneos/CallControl.app/CallControl
cd /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/Users/ainutveckling/Jenkins/tools/jdk6/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/dsymutil /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Distribution-iphoneos/CallControl.app/CallControl -o /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Distribution-iphoneos/CallControl.app.dSYM
ProcessProductPackaging "/Users/ainutveckling/Library/MobileDevice/Provisioning Profiles/F792F2E5-45DB-43C7-969C-6012C59BF778.mobileprovision" build/Distribution-iphoneos/CallControl.app/embedded.mobileprovision
cd /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/Users/ainutveckling/Jenkins/tools/jdk6/bin:/usr/bin:/bin:/usr/sbin:/sbin"
<com.apple.tools.product-pkg-utility> "/Users/ainutveckling/Library/MobileDevice/Provisioning Profiles/F792F2E5-45DB-43C7-969C-6012C59BF778.mobileprovision" -o /Users/ainutveckling/Jenkins/workspace/CallControl_iPhoneContiousBuild/Callcontrol/build/Distribution-iphoneos/CallControl.app/embedded.mobileprovision
** BUILD FAILED **
+ failed build
+ echo 'Failed: build'
Failed: build
+ exit 1
Notifying upstream projects of job completion
Finished: FAILURE
On my machine, it looks almost the same:
GenerateDSYMFile build/Distribution-iphoneos/CallControl.app.dSYM build/Distribution-iphoneos/CallControl.app/CallControl
cd /Users/anders/Utveckling/CallControl/iphone/totala_samtalslistan/Callcontrol
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/anders/Utveckling/android-sdk-mac_x86/tools:/Users/anders/Utveckling/android-sdk-mac_x86/platform-tools:"
/Developer/usr/bin/dsymutil /Users/anders/Utveckling/CallControl/iphone/totala_samtalslistan/Callcontrol/build/Distribution-iphoneos/CallControl.app/CallControl -o /Users/anders/Utveckling/CallControl/iphone/totala_samtalslistan/Callcontrol/build/Distribution-iphoneos/CallControl.app.dSYM
ProcessProductPackaging "/Users/anders/Library/MobileDevice/Provisioning Profiles/F792F2E5-45DB-43C7-969C-6012C59BF778.mobileprovision" build/Distribution-iphoneos/CallControl.app/embedded.mobileprovision
cd /Users/anders/Utveckling/CallControl/iphone/totala_samtalslistan/Callcontrol
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/anders/Utveckling/android-sdk-mac_x86/tools:/Users/anders/Utveckling/android-sdk-mac_x86/platform-tools:"
<com.apple.tools.product-pkg-utility> "/Users/anders/Library/MobileDevice/Provisioning Profiles/F792F2E5-45DB-43C7-969C-6012C59BF778.mobileprovision" -o /Users/anders/Utveckling/CallControl/iphone/totala_samtalslistan/Callcontrol/build/Distribution-iphoneos/CallControl.app/embedded.mobileprovision
** BUILD SUCCEEDED **
But success...
It does not matter if I start the build directly from the command line on the build machine or if it is started by Hudson, same result.
The certificate pointed out above seems to be in place.
I'm almost ready to give up on this, so I would very much appreciate any help to shed some light upon the matter!
Best regards,
Anders
I encountered the exact error that you showed above on my build machine after updating to a new distribution certificate and provisioning profile. After the ProcessProductPackaging step, it would just display the ** BUILD FAILED ** message.
However, when running the build manually on the build machine, I encountered the KeyChain permission dialog. Hitting "Allow Always" fixed the problem.
That in addition to unlocking in the build script:
security unlock -p $PASSWORD
Add this line of code to your script:
security list-keychains -s $KEYCHAINFILE
This has fixed the issue for me.

Resources