codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
243 stars 42 forks source link

Swift package plugin can't find underlying command #334

Closed knellr closed 1 year ago

knellr commented 1 year ago

Hello, we're currently evaluating Codemagic. We have an iOS project using Swift Package Manager that builds a command-line tool for a build plugin. This all works fine in xcode and our current CI, but not Codemagic, I believe because of the -sdk parameter passed to xcodebuild.

xcode-project run-tests \
              --workspace "${XCODE_WORKSPACE?}" \
              --scheme "${XCODE_SCHEME?}" \
              --device "iPhone 12"

This then executes:

xcodebuild -workspace MoneySuperMarket.xcworkspace -scheme MoneySuperMarket -sdk iphonesimulator -enableCodeCoverage YES -destination id=AD61C77D-F937-4C64-A1A7-19DD1E3E0E3B test

Which results in the (macos) tool being build for iPhone Simulator, preventing it from being run:

sandbox-exec: execvp() of '~/Library/Developer/Xcode/DerivedData/MoneySuperMarket-gnvmgsqxfulongdoqffwuxhirebk/Build/Products/Debug/Command' failed: No such file or directory

This issue is mentioned here. https://developer.apple.com/forums/thread/650302

Is there any way to prevent xcodebuild from being run with the -sdk parameter?

priitlatt commented 1 year ago

Hey @knellr! It is possible to override the iphonesimulator default value by passing --sdk to xcode-project run-tests.

knellr commented 1 year ago

Thanks for the quick response! Unfortunately I require the app to be built for simulator, but the command line to be built for macos, so I'm looking for a way to not supply the parameter at all.

priitlatt commented 1 year ago

Ahaa, sorry for rushing with my initial answer. As of now it is not possible to omit this parameter, but I can look into it tomorrow and see what can be done about it. I'll keep you posted.

priitlatt commented 1 year ago

Hi again @knellr. I've made some changes to xcode-project run-tests in #335 and added optional --omit-sdk switch that will make it so that the underlying xcodebuild command will not be invoked with -sdk argument.

To try out those changes please update the tools to test version using

python -m pip install -i https://test.pypi.org/simple/ codemagic-cli-tools==0.42.0.41

and modify your test command to

xcode-project run-tests \
              --workspace "${XCODE_WORKSPACE?}" \
              --scheme "${XCODE_SCHEME?}" \
              --device "iPhone 12" \
              --omit-sdk

Please let me know how it goes and if all is well then we can move on with the release procedure.

knellr commented 1 year ago

Hi @priitlatt, I've confirmed that this is working for us, thank you.

priitlatt commented 1 year ago

@knellr That is some great news. I'll push the PR to review then and hopefully we can have a proper release sometime tomorrow. Until then please keep using the test release.

priitlatt commented 1 year ago

@knellr, --omit-sdk option is now available in version 0.42.0. All Codemagic VMs come equipped with this version already. If you need it somewhere else, then you can grab it from PyPI.