runner-images icon indicating copy to clipboard operation
runner-images copied to clipboard

Have a problem on Azure pipelines with Xcode 13.4 on macOS 12

Open kvyatkovskys opened this issue 2 years ago β€’ 29 comments

Description

Pipeline freezes when resolving swift packages

Screen Shot 2022-05-20 at 5 03 24 PM Screen Shot 2022-05-20 at 5 09 51 PM

Virtual environments affected

  • [ ] Ubuntu 18.04
  • [ ] Ubuntu 20.04
  • [ ] Ubuntu 22.04
  • [ ] macOS 10.15
  • [ ] macOS 11
  • [X] macOS 12
  • [ ] Windows Server 2019
  • [ ] Windows Server 2022

Image version and build link

Environment: macOS 12 Version: 20220520.1

Is it regression?

no

Expected behavior

Pipeline should works correctly

Actual behavior

Pipeline freezes. Xcode 13.4 works fine on my MacBook.

Repro steps

  • select a iOS project with swift packages
  • run pipeline
  • select macOS 12
  • select Xcode 13.4

kvyatkovskys avatar May 20 '22 14:05 kvyatkovskys

Hi @kvyatkovskys! Could you prepare a workflow that can be used to reproduce the issue?

miketimofeev avatar May 20 '22 14:05 miketimofeev

Hi @kvyatkovskys! Could you prepare a workflow that can be used to reproduce the issue?

Hi @miketimofeev! You mean I need to provide more detailed steps πŸ€”

kvyatkovskys avatar May 20 '22 14:05 kvyatkovskys

@kvyatkovskys yes as we need to reproduce the issue to debug it further.

miketimofeev avatar May 20 '22 14:05 miketimofeev

@miketimofeev sure thing, will add later today πŸ™‚

kvyatkovskys avatar May 20 '22 14:05 kvyatkovskys

env:

  • macOS 12
  • iOS project with swift packages
  • fastlane (2.206.0) gym (to build project)

pipeline with settings below: Screen Shot 2022-05-20 at 9 40 46 PM

task Prepare environment:

  • sudo xcode-select -switch /Applications/Xcode_13.4.app
  • xcode-select --print-path
  • gem install bundler:1.16.1
  • bundle update --all

task Fastlane run dev:

  • bundle exec fastlane build

steps:

  • run pipeline
  • select branch
  • run

kvyatkovskys avatar May 20 '22 18:05 kvyatkovskys

any updates? πŸ™‚

kvyatkovskys avatar Jun 03 '22 08:06 kvyatkovskys

@miketimofeev any updates?πŸ™‚

kvyatkovskys avatar Jun 07 '22 07:06 kvyatkovskys

@panticmilos did you have a chance to take a look?

miketimofeev avatar Jun 07 '22 11:06 miketimofeev

Hi @kvyatkovskys,

Thank you for your patience, just to let you know I started investigating this issue in-depth today, so I will get back to you with some useful info as soon as possible.

Cheers

panticmilos avatar Jun 07 '22 13:06 panticmilos

Hi @kvyatkovskys,

Thank you for your patience, just to let you know I started investigating this issue in-depth today, so I will get back to you with some useful info as soon as possible.

Cheers

Thanks πŸ™‚

kvyatkovskys avatar Jun 07 '22 14:06 kvyatkovskys

Hi @kvyatkovskys,

Is there any chance you can provide us pipeline YAML file? I am aware of the screenshot you posted, but just to make sure I am not missing anything. Also if you could make public mock repo similar to yours that would be great(just to hold an app that I can use for the pipeline)

panticmilos avatar Jun 08 '22 08:06 panticmilos

Hi @panticmilos!

sure... pipeline works fine with Xcode 13.2.1

pool:
  name: Azure Pipelines
variables:
  XCODE_VERSION: '13.2.1'

steps:
- task: vs-publisher-473885.motz-mobile-buildtasks.ios-bundle-version.ios-bundle-version@1
  displayName: 'Bump iOS Versions in Example/Example-Info.plist'
  inputs:
    sourcePath: 'Example/Example-Info.plist'

- bash: |
   sudo xcode-select -switch /Applications/Xcode_$(XCODE_VERSION).app
   xcode-select --print-path
   gem install bundler:1.16.1
   bundle update --all
  displayName: 'Prepare environment '
  continueOnError: true
  env:
    GITHUB_ACCESS_TOKEN: $(GitHubAccessToken)

- script: 'bundle exec fastlane build'
  displayName: 'Fastlane run dev'
  env:
    GIT_AUTHORIZATION: $(GitHubPAT)
    SCHEME: Example
    CONFIGURATION: Debug
    MATCH_TYPE: adhoc
    EXPORT_METOD: ad-hoc
    APPLE_KEY_ID: $(APPLE_KEY_ID)
    APPLE_KEY_CONTENT: $(APPLE_KEY_CONTENT)
    APPLE_ISSUER_ID: $(APPLE_ISSUER_ID)
    OUTPUT_NAME: $(OUTPUT_NAME)
    EXPORT_OPTION: AdHoc
    IS_KEY_ENCODED: true
    DO_NOT_UPDATE_CERTIFICATES: true
    BUNDLE_ID: $(BUNDLE_ID)
    FORCE_UPDATE_PROFILES: false

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)/Dev/'
  inputs:
    SourceFolder: '$(build.sourcesdirectory)'
    Contents: '$(OUTPUT_NAME).ipa'
    TargetFolder: '$(build.artifactstagingdirectory)/Dev/'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

kvyatkovskys avatar Jun 08 '22 09:06 kvyatkovskys

hi @kvyatkovskys,

Just to check, is using this version, Xcode 13.2.1, a workaround you can use until we resolve this issue?

panticmilos avatar Jun 09 '22 11:06 panticmilos

Yes we can and we use Xcode 13.2.1. And we also plan to update Xcode

kvyatkovskys avatar Jun 09 '22 20:06 kvyatkovskys

Hi @panticmilos,

JFYI, the Xcode 13.4.1 also doesn't work too

kvyatkovskys avatar Jun 14 '22 10:06 kvyatkovskys

Hello, I have the same issue. I am trying to execute the following command xcodebuild -quiet build-for-testing -workspace MyApp.xcworkspace -scheme "MyAppScheme" -destination "name=iPhone 13 Pro" -derivedDataPath DerivedData in GitHub Actions.

Agent: macos-12 Xcode: 13.4.1

Everything works fine on Xcode 13.2

pavshr avatar Jun 15 '22 13:06 pavshr

Hi @panticmilos, any updates?

kvyatkovskys avatar Jun 27 '22 08:06 kvyatkovskys

still have problems

Screen Shot 2022-06-28 at 10 24 01 PM Screen Shot 2022-06-28 at 10 31 11 PM

kvyatkovskys avatar Jun 28 '22 19:06 kvyatkovskys

Hi @kvyatkovskys,

Is there any way you can provide me with a mock of the repository?

panticmilos avatar Jun 29 '22 07:06 panticmilos

Hi @kvyatkovskys,

Is there any way you can provide me with a mock of the repository?

hmm I don't know right now πŸ€” this's a private repository... I noticed that when I removed the Twilio package from the project, everything works fine

kvyatkovskys avatar Jun 29 '22 21:06 kvyatkovskys

@kvyatkovskys nice! Hope this will work for the others too. @pavshr, is removing the Twilio package applicable to your case as well?

panticmilos avatar Jun 30 '22 07:06 panticmilos

@kvyatkovskys nice! Hope this will work for the others too.

@pavshr, is removing the Twilio package applicable to your case as well?

Yeah πŸ˜€ but we use the Twilio package in our project. Still investigating the issue

kvyatkovskys avatar Jun 30 '22 08:06 kvyatkovskys

@kvyatkovskys nice! Hope this will work for the others too. @pavshr, is removing the Twilio package applicable to your case as well?

Yeah πŸ˜€ but we use the Twilio package in our project. Still investigating the issue

I had an issue with twilio and bitcode, apparently disabling bitcode fixes the issue (bitcode is apparently deprecated)

michaelmoneypenny avatar Jul 07 '22 08:07 michaelmoneypenny

@panticmilos No, we are not using Twilio, and bitcode is also disabled for our app.

pavshr avatar Jul 21 '22 13:07 pavshr

I fixed the issueπŸ™‚. I added the twilio package as a binary xcframework to the project.

package.swift example

let package = Package(
    name: "VideoVisit",
    platforms: [.iOS(.v14), .macOS(.v10_15)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "VideoVisit",
            targets: ["VideoVisit", "TwilioVideo"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/SnapKit/SnapKit", .upToNextMajor(from: "5.0.0")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .binaryTarget(
            name: "TwilioVideo",
            path: "TwilioVideo.xcframework"
        ),
        .target(
            name: "VideoVisit",
            dependencies: [
                "SnapKit",
                .target(name: "TwilioVideo"),
            ],
            path: "Sources",
            exclude: ["../VV-Example"],
            resources: [
                .process("../Sources/Media.xcassets")
            ]),
        .testTarget(
            name: "VideoVisitTests",
            dependencies: ["VideoVisit"]),
    ]
)

kvyatkovskys avatar Jul 23 '22 12:07 kvyatkovskys

I think, problem was due to a large file download. The twilio package is 60 mb in size.

cc @miketimofeev @panticmilos

import PackageDescription

let package = Package(
    name: "TwilioVideo",
    platforms: [
        .iOS("12.2")
    ],
    products: [
        .library(
            name: "TwilioVideo",
            targets: ["TwilioVideo"]),
    ],
    targets: [
        .binaryTarget(
            name: "TwilioVideo",
            url: "https://github.com/twilio/twilio-video-ios/releases/download/5.1.1/TwilioVideo.xcframework.zip",
            checksum: "125e944221600cbe98436d1cbc7bd8817c2795e6a9f36e3a63c01f0016f67d78"
        )
    ]
)

kvyatkovskys avatar Jul 23 '22 13:07 kvyatkovskys

We've hit this issue on our side and we can reproduce it easily on MacOS 12 and Xcode 13.4+. We believe that Xcode is trying to access the keychain interactively while cloning at least 10 repositories from Github with a PAT. But if you only use public repositories, you won't run into this. We've tried using the PAT in git credential helper or via URL re-write and both produce the same error depending on the number of repositories xcodebuild is trying to resolve. The issue does not happen on XCode 13.2.1, even on the MacOS 12 agent.

Reproduce:

  1. Use MacOS 12 and Xcode 13.4+.

  2. Add a URL rewrite to gitconfig: git config --global url.https://username:[email protected] https://github.com

  3. Run the pipeline and this will hang when cloning one of the repositories during xcodebuild.

Locally, we've tried to reproduce this error, and we can occasionally get a keychain prompt from XCode. See screenshot below on local dev machine.

E0A74EAB-8523-4AEA-BEFF-0886CB493D5E

@miketimofeev, any thoughts on how to resolve this?

jmprice18 avatar Aug 31 '22 12:08 jmprice18

@jmprice18 we will take a look at what can be done from our side but at first glance, it looks like Xcode security limitations.

miketimofeev avatar Aug 31 '22 13:08 miketimofeev

Hi @jmprice18, we were discussing how we could potentially overcome this issue, and for self-hosted runner, we could maybe run git config credential.helper cache after auth to avoid keychain prompts. In this case, we could avoid it. Of course, there is still a question to be resolved how we can avoid it for hosted runners.

panticmilos avatar Sep 01 '22 12:09 panticmilos

Hi everyone. Since this looks like the security limitation of the Xcode and given the recent inactivity on the issue I am going to close it for now.

Feel free to continue the conversation here or reopen the issue. Cheers

panticmilos avatar Oct 28 '22 10:10 panticmilos