devops Pipelines 中的私人 Cocapods 存储库

Hap*_*ump 6 azure ios cocoapods azure-devops

使用 Azure DevOps 和 iOS 对我来说是第一次。我正在尝试在 Azure devops 中为一个 iOS 应用程序创建一个构建管道,该应用程序具有多个私有 cocoapods 存储库 ( PodXSource) 和一个私有规范存储库 ( projectPodSpecsRepository)。

我似乎无法执行 Azure Cocoapod 任务。我尝试了多种方法,但没有一个有效。我错过了什么吗?

这是我的 yaml 管道的一部分:

- script: 
          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository

          git config --global credential.helper store

          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectCore/_git/Pod1Source

          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectEvaluations/_git/Pod2Source

          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectEvaluations/_git/Pod3Source

          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectEvaluations/_git/Pod4Source

          git clone https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectEvaluations/_git/Pod5Source


- task: CocoaPods@0
  inputs:
    forceRepoUpdate: false
Run Code Online (Sandbox Code Playgroud)

$(gitUser)都是$(gitPat)用于凭证目的的管道机密。

Pod 文件:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

source 'https://dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository'
source 'https://github.com/CocoaPods/Specs.git'

target 'projectDemo' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for projectDemo
  pod 'Pod1'
  pod 'Pod2'
  pod 'Pod3'
  pod 'Pod4'
  pod 'Pod5'

end
Run Code Online (Sandbox Code Playgroud)

这是任务的日志CocoaPods

##[section]Starting: CocoaPods
==============================================================================
Task         : CocoaPods
Description  : Install CocoaPods dependencies for Swift and Objective-C Cocoa projects
Version      : 0.151.1
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/cocoapods
==============================================================================
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod --version
1.7.1
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod install
[!] The version of CocoaPods used to generate the lockfile (1.7.3) is higher than the version of the current executable (1.7.1). Incompatibility issues may arise.
Analyzing dependencies
Adding spec repo `azure-happydump-projectcore-_git-projectpodspecsrepository` with CDN `https://dev.azure.com/happydump/projectCore/_git/projectPodSpec`
[!] Unable to add a source with url `https://dev.azure.com/happydump/projectCore/_git/projectPodSpec` named `azure-happydump-projectcore-_git-projectpodspecsrepository`.
You can try adding it manually in `/Users/vsts/.cocoapods/repos` or via `pod repo add`.
##[error]The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[error]The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[section]Finishing: CocoaPods
Run Code Online (Sandbox Code Playgroud)

我按照链接到达那里,但没有任何效果。

我似乎无法找到一种方法来实现这一点。谢谢你的时间。

编辑:使用gem install cocoapodsyaml 文件只会删除[!] The version of CocoaPods used to generate the lockfile (1.7.3) is higher than the version of the current executable (1.7.1). Incompatibility issues may arise.警告,但不会解决问题。

EDIT2:使用pod repo add azure-happydump-projectcore-_git-projectpodspecsrepository https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository也没有帮助。来自 CocoaPods 任务的错误消息将更改为... [!] Unable to add a source with url https://dev.azure.com/happydump/projectCore/_git/projectPodSpec named azure-happydump-projectcore-_git-projectpodspecsrepository-1. ...

Hap*_*ump 4

该问题是由于 Podfile.lock 文件中的 url 格式差异造成的:

\n\n

Pod 文件:\nhttps://dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository

\n\n

Podfile.lockhttps://happydump@visualstudio.com/DefaulCollection/projectCore/_git/projectPodSpecsRepository

\n\n

从 Podfile.lock 恢复 url 就成功了!

\n\n

以下是最终文件:

\n\n

管道:请注意,我正在压缩 cocoapods 存储库,以免为每个构建克隆它们。

\n\n
pool:\n  vmImage: \'macos-latest\'\n\nvariables: \n  FILEEXISTS: false\n\nsteps:\n- task: CmdLine@2\n  inputs:\n    script: \'sudo gem install cocoapods\'\n\n\n- task: PowerShell@2\n  inputs:\n    targetType: \'inline\'\n    script: \'Write-Host "##vso[task.setvariable variable=CP_HOME_DIR;]$(System.DefaultWorkingDirectory)/Cache"\'\n\n- task: CacheBeta@0\n  inputs:\n    key: PodReposTestZip | $(Agent.OS) | $(System.DefaultWorkingDirectory)/Konectom/Podfile.lock\n    path: $(System.DefaultWorkingDirectory)/Cache/tmp/\n  displayName: Cache Podfiles packages\n\n\n- bash: |\n    if [ -d $(System.DefaultWorkingDirectory)/Cache/tmp ]; then\n      echo "##vso[task.setVariable variable=FILEEXISTS]true"\n    fi\n\n- task: ExtractFiles@1\n  inputs:\n    archiveFilePatterns: \'$(System.DefaultWorkingDirectory)/Cache/tmp/cocoapods.zip\'\n    destinationFolder: \'$(System.DefaultWorkingDirectory)/Cache/repos\'\n    cleanDestinationFolder: true\n  condition: eq(variables.FILEEXISTS, \'true\')\n\n- task: CmdLine@2\n  inputs:\n    script: \'pod repo add azure-company-project-_git-specrepository-ios https://$(gitUser):$(gitPat)@dev.azure.com/company/project/_git/repo\'\n\n- task: CocoaPods@0\n  inputs:\n    forceRepoUpdate: false\n    workingDirectory: \'AppDir\'\n\n- task: InstallAppleCertificate@2\n  inputs:\n    certSecureFile: \'Certificats.p12\'\n    certPwd: \'$(certifPwd)\'\n    keychain: \'temp\'\n\n- task: InstallAppleProvisioningProfile@1\n  inputs:\n    provisioningProfileLocation: \'secureFiles\'\n    provProfileSecureFile: \'ProvisionFile.mobileprovision\'\n\n- task: Xcode@5\n  inputs:\n    actions: \'build\'\n    scheme: \'Konectom-dev\'\n    sdk: "iphoneos13.0"\n    xcodeVersion: \'specifyPath\'\n    xcodeDeveloperDir: \'/Applications/Xcode_11.app\'\n    configuration: \'Release\'\n    xcWorkspacePath: \'Konectom/Konectom.xcworkspace\'\n    packageApp: true\n    signingOption: manual\n    signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY)\n    provisioningProfileUuid: $(APPLE_PROV_PROFILE_UUID)\n    exportPath: $(build.artifactstagingdirectory)/pkgApp\n\n- task: CmdLine@2\n  inputs:\n    script: \'ls -la $(build.artifactstagingdirectory)/pkgApp\'\n\n- task: ArchiveFiles@2\n  inputs:\n    rootFolderOrFile: \'$(System.DefaultWorkingDirectory)/Cache/repos/cocoapods\'\n    includeRootFolder: true\n    archiveType: \'zip\'\n    archiveFile: \'$(System.DefaultWorkingDirectory)/Cache/tmp/cocoapods.zip\'\n    replaceExistingArchive: true\n  condition: eq(variables.FILEEXISTS, \'false\')\n\n- task: AppCenterDistribute@3\n  inputs:\n    serverEndpoint: \'AppCenterEndpoint\'\n    appSlug: \'TestProject/TestApp\'\n    appFile: $(build.artifactstagingdirectory)/pkgApp/App.ipa\n    releaseNotesOption: \'input\'\n    releaseNotesInput: \'\'\n    destinationType: \'groups\'\n    symbolsOption: Apple\n
Run Code Online (Sandbox Code Playgroud)\n\n

Pod文件:

\n\n
workspace \'Project\'\n#\n# Sources reposotiries\n#\nsource \'https://dev.azure.com/company/project/_git/PodSpecsRepository\'\nsource \'https://github.com/CocoaPods/Specs.git\'\n\n# Global project platform\nplatform :ios, \'10.0\'\n\n# Comment the next line if you\'re not using Swift and don\'t want to use dynamic frameworks\nuse_frameworks!\n\n#\n# Pods groups\n#\ndef module0\n  pod \'po1\', \'~> 0.1.87\'\n  pod \'pod2\', \'~> 0.1.29\'\n  pod \'pod3\', \'~> 0.1.20\'\n  pod \'pod4\', \'~> 0.1.13\'\n  pod \'pod5\', \'~> 0.1.15\'\n  pod \'pod6\', \'~> 0.1.15\'\n  pod \'pod7\', \'~> 0.1.18\'\n  pod \'pod8\', \'~> 0.1.10\'\nend\n\ndef Module1\n  pod \'pod1\', \'~> 0.1.20\'\nend\n\ndef module2\n  pod \'pod2\', \'~> 0.1.16\'\nend\n\ndef module3\n  pod \'pod3\', \'~> 0.1.6\'\nend\n\ndef module4\n  pod \'pod4\', \'~> 0.1.0\'\nend\n\ndef module5\n  pod \'pod5\', \'~> 0.1.8\'\nend\n\ndef module6\n  pod \'pod6\'\nend\n\n#\n# Main app target\n#\ntarget \'MainProject\' do\n  project \'MainProject\'\n\n  # Private Pods for Project\n  privateRepo1\n  privateRepo2\n  privateRepo3\n  privateRepo4\n  privateRepo5\n  privateRepo6\n\n  # Third party pods\n  pod \'SlideMenuControllerSwift\', \'~> 4.0\'\n  pod \'SPPermissions/Camera\'\n  pod \'SPPermissions/Location\'\n  pod \'SPPermissions/Notification\'\n  pod \'SPPermissions/Motion\'\n\n  target \'TestsProject\' do\n    inherit! :search_paths\n    # Pods for testing\n  end\n\n  target \'UiTestsProject\' do\n    inherit! :search_paths\n    # Pods for testing\n  end\n\n  # Post install routine\n post_install do |installer|\n   installer.pods_project.targets.each do |target|\n     # force swift version 4.0 for these pods\n     if target.name == \xe2\x80\x98SlideMenuControllerSwift\xe2\x80\x99\n       target.build_configurations.each do |config|\n         config.build_settings[\xe2\x80\x98SWIFT_VERSION\xe2\x80\x99] = \xe2\x80\x984.0\xe2\x80\x99\n       end\n     end\n     target.build_configurations.each do |config|\n         config.build_settings[\xe2\x80\x98EXPANDED_CODE_SIGN_IDENTITY\xe2\x80\x99] = \xe2\x80\x9c\xe2\x80\x9d\n         config.build_settings[\xe2\x80\x98CODE_SIGNING_REQUIRED\xe2\x80\x99] = \xe2\x80\x9cNO\xe2\x80\x9d\n         config.build_settings[\xe2\x80\x98CODE_SIGNING_ALLOWED\xe2\x80\x99] = \xe2\x80\x9cNO\xe2\x80\x9d\n     end\n   end\n end\nend\n
Run Code Online (Sandbox Code Playgroud)\n\n

Podfile.lock:

\n\n
PODS:\n  - pod1(0.1.29):\n    - Kronos (~> 4.0.0)\n  - pod2(0.1.20)\n  - Alamofire (5.0.0-rc.3)\n  - pod3(0.1.32):\n    - pod2(~> 0.1.20)\n    - pod1(~> 0.1.29)\n    - lottie-ios (~> 2.5.0)\n  - Kronos (4.0.0)\n  - lottie-ios (2.5.3)\n  - SlideMenuControllerSwift (4.0.0)\n  - SPPermissions/Camera (4.1.4):\n    - SPPermissions/Core\n  - SPPermissions/Core (4.1.4)\n  - SPPermissions/Location (4.1.4):\n    - SPPermissions/Core\n  - SPPermissions/Motion (4.1.4):\n    - SPPermissions/Core\n  - SPPermissions/Notification (4.1.4):\n    - SPPermissions/Core\n\nDEPENDENCIES:\n  - pod1(~> 0.1.20)\n  - pod2(~> 0.1.10)\n  - pod3(~> 0.1.15)\n  - pod4(~> 0.1.29)\n  - pod5(~> 0.1.0)\n  - SlideMenuControllerSwift (~> 4.0)\n  - SPPermissions/Camera\n  - SPPermissions/Location\n  - SPPermissions/Motion\n  - SPPermissions/Notification\n\nSPEC REPOS:\n  https://dev.azure.com/company/project/_git/PodSpecsRepository:\n    - pod1\n    - pod2\n    - pod3\n    - pod4\n    - pod5\n  https://github.com/CocoaPods/Specs.git:\n    - Alamofire\n    - AppCenter\n    - GzipSwift\n    - KDCircularProgress\n    - Kronos\n    - lottie-ios\n    - SlideMenuControllerSwift\n    - SPPermissions\n    - SwiftKeychainWrapper\n\nSPEC CHECKSUMS:\n  checksums\n\nPODFILE CHECKSUM: checksum\nCOCOAPODS: 1.8.4\n
Run Code Online (Sandbox Code Playgroud)\n