Working with Azure Devops and iOS is a first to me.
I am trying to create a Build Pipeline in Azure devops for an iOS App that has several private cocoapods repository (PodXSource
) and a private spec repository(projectPodSpecsRepository
).
I can't seem to manage to execute the Azure Cocoapod task. I've tried several ways but none are working. Am I missing something?
here is a part of my yaml pipeline:
- 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
The $(gitUser)
and $(gitPat)
are both pipeline secrets for credentials purposes.
The Podfile:
# 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
Here is the log from the CocoaPods
task:
##[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://docs.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
I followed this link to get there but nothing does the trick.
I can't seem to find a way to make that work. Thanks for your time.
EDIT: using gem install cocoapods
to the yaml file just deletes the [!] 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.
warning but doesn't fix the problem.
EDIT2: Using pod repo add azure-happydump-projectcore-_git-projectpodspecsrepository https://$(gitUser):$(gitPat)@dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository
doesn't help either. Tha error message from the CocoaPods task will just change to ... [!] Unable to add a source with url https://dev.azure.com/happydump/projectCore/_git/projectPodSpec named azure-happydump-projectcore-_git-projectpodspecsrepository-1. ...
Podfile. lock is used to make sure that every members of the team has the same versions of pods installed on the project. This file is generated after you run the command: pod install. It gets updated when you run pod install or pod update.
The problem was due to an a url formatting difference within the Podfile.lock file:
Podfile:
https://dev.azure.com/happydump/projectCore/_git/projectPodSpecsRepository
Podfile.lock https://[email protected]/DefaulCollection/projectCore/_git/projectPodSpecsRepository
reverting the url from the Podfile.lock did the trick!
Here are the final files:
Pipeline: Note that I am zipping the cocoapods repo in order not to clone them for each build.
pool:
vmImage: 'macos-latest'
variables:
FILEEXISTS: false
steps:
- task: CmdLine@2
inputs:
script: 'sudo gem install cocoapods'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Write-Host "##vso[task.setvariable variable=CP_HOME_DIR;]$(System.DefaultWorkingDirectory)/Cache"'
- task: CacheBeta@0
inputs:
key: PodReposTestZip | $(Agent.OS) | $(System.DefaultWorkingDirectory)/Konectom/Podfile.lock
path: $(System.DefaultWorkingDirectory)/Cache/tmp/
displayName: Cache Podfiles packages
- bash: |
if [ -d $(System.DefaultWorkingDirectory)/Cache/tmp ]; then
echo "##vso[task.setVariable variable=FILEEXISTS]true"
fi
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(System.DefaultWorkingDirectory)/Cache/tmp/cocoapods.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/Cache/repos'
cleanDestinationFolder: true
condition: eq(variables.FILEEXISTS, 'true')
- task: CmdLine@2
inputs:
script: 'pod repo add azure-company-project-_git-specrepository-ios https://$(gitUser):$(gitPat)@dev.azure.com/company/project/_git/repo'
- task: CocoaPods@0
inputs:
forceRepoUpdate: false
workingDirectory: 'AppDir'
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'Certificats.p12'
certPwd: '$(certifPwd)'
keychain: 'temp'
- task: InstallAppleProvisioningProfile@1
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'ProvisionFile.mobileprovision'
- task: Xcode@5
inputs:
actions: 'build'
scheme: 'Konectom-dev'
sdk: "iphoneos13.0"
xcodeVersion: 'specifyPath'
xcodeDeveloperDir: '/Applications/Xcode_11.app'
configuration: 'Release'
xcWorkspacePath: 'Konectom/Konectom.xcworkspace'
packageApp: true
signingOption: manual
signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY)
provisioningProfileUuid: $(APPLE_PROV_PROFILE_UUID)
exportPath: $(build.artifactstagingdirectory)/pkgApp
- task: CmdLine@2
inputs:
script: 'ls -la $(build.artifactstagingdirectory)/pkgApp'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/Cache/repos/cocoapods'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(System.DefaultWorkingDirectory)/Cache/tmp/cocoapods.zip'
replaceExistingArchive: true
condition: eq(variables.FILEEXISTS, 'false')
- task: AppCenterDistribute@3
inputs:
serverEndpoint: 'AppCenterEndpoint'
appSlug: 'TestProject/TestApp'
appFile: $(build.artifactstagingdirectory)/pkgApp/App.ipa
releaseNotesOption: 'input'
releaseNotesInput: ''
destinationType: 'groups'
symbolsOption: Apple
PodFile :
workspace 'Project'
#
# Sources reposotiries
#
source 'https://dev.azure.com/company/project/_git/PodSpecsRepository'
source 'https://github.com/CocoaPods/Specs.git'
# Global project platform
platform :ios, '10.0'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
#
# Pods groups
#
def module0
pod 'po1', '~> 0.1.87'
pod 'pod2', '~> 0.1.29'
pod 'pod3', '~> 0.1.20'
pod 'pod4', '~> 0.1.13'
pod 'pod5', '~> 0.1.15'
pod 'pod6', '~> 0.1.15'
pod 'pod7', '~> 0.1.18'
pod 'pod8', '~> 0.1.10'
end
def Module1
pod 'pod1', '~> 0.1.20'
end
def module2
pod 'pod2', '~> 0.1.16'
end
def module3
pod 'pod3', '~> 0.1.6'
end
def module4
pod 'pod4', '~> 0.1.0'
end
def module5
pod 'pod5', '~> 0.1.8'
end
def module6
pod 'pod6'
end
#
# Main app target
#
target 'MainProject' do
project 'MainProject'
# Private Pods for Project
privateRepo1
privateRepo2
privateRepo3
privateRepo4
privateRepo5
privateRepo6
# Third party pods
pod 'SlideMenuControllerSwift', '~> 4.0'
pod 'SPPermissions/Camera'
pod 'SPPermissions/Location'
pod 'SPPermissions/Notification'
pod 'SPPermissions/Motion'
target 'TestsProject' do
inherit! :search_paths
# Pods for testing
end
target 'UiTestsProject' do
inherit! :search_paths
# Pods for testing
end
# Post install routine
post_install do |installer|
installer.pods_project.targets.each do |target|
# force swift version 4.0 for these pods
if target.name == ‘SlideMenuControllerSwift’
target.build_configurations.each do |config|
config.build_settings[‘SWIFT_VERSION’] = ‘4.0’
end
end
target.build_configurations.each do |config|
config.build_settings[‘EXPANDED_CODE_SIGN_IDENTITY’] = “”
config.build_settings[‘CODE_SIGNING_REQUIRED’] = “NO”
config.build_settings[‘CODE_SIGNING_ALLOWED’] = “NO”
end
end
end
end
Podfile.lock:
PODS:
- pod1(0.1.29):
- Kronos (~> 4.0.0)
- pod2(0.1.20)
- Alamofire (5.0.0-rc.3)
- pod3(0.1.32):
- pod2(~> 0.1.20)
- pod1(~> 0.1.29)
- lottie-ios (~> 2.5.0)
- Kronos (4.0.0)
- lottie-ios (2.5.3)
- SlideMenuControllerSwift (4.0.0)
- SPPermissions/Camera (4.1.4):
- SPPermissions/Core
- SPPermissions/Core (4.1.4)
- SPPermissions/Location (4.1.4):
- SPPermissions/Core
- SPPermissions/Motion (4.1.4):
- SPPermissions/Core
- SPPermissions/Notification (4.1.4):
- SPPermissions/Core
DEPENDENCIES:
- pod1(~> 0.1.20)
- pod2(~> 0.1.10)
- pod3(~> 0.1.15)
- pod4(~> 0.1.29)
- pod5(~> 0.1.0)
- SlideMenuControllerSwift (~> 4.0)
- SPPermissions/Camera
- SPPermissions/Location
- SPPermissions/Motion
- SPPermissions/Notification
SPEC REPOS:
https://dev.azure.com/company/project/_git/PodSpecsRepository:
- pod1
- pod2
- pod3
- pod4
- pod5
https://github.com/CocoaPods/Specs.git:
- Alamofire
- AppCenter
- GzipSwift
- KDCircularProgress
- Kronos
- lottie-ios
- SlideMenuControllerSwift
- SPPermissions
- SwiftKeychainWrapper
SPEC CHECKSUMS:
checksums
PODFILE CHECKSUM: checksum
COCOAPODS: 1.8.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With