Search code examples
xcodecocoapodsxcodebuildgithub-actionsmac-catalyst

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 [email protected]: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?


Solution

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