Azure Devops: Add capability to xcode build for push notifications - xcode

I'm running an azure pipeline to build my .ipa file for iOS Deployment.
Everything is working fine except one detail.
When I'm uploading my app to testflight and run it I got the following message in OneSignal:
Other Apns 3000 Error
Error 3000 returned from
APNs. Ensure "Push Notifications" in Xcode under "Project Target" -> Capabilities are enabled.
Check the device log in Xcode for more details.
Unfortunately I have not found anything how to enable the capability for push notifications in the pipeline.
My provisioning profile has the capability for push notifications enabled. But this seems not to work. I also have background mode "Remote Notifications" enabled in my info.plist file. This is also not helping.
Here is a part of my pipeline:
steps:
- task: InstallAppleCertificate#2
displayName: 'Install an Apple certificate'
inputs:
certSecureFile: '*****.p12'
setUpPartitionIdACLForPrivateKey: false
steps:
- task: InstallAppleProvisioningProfile#1
displayName: 'Install an Apple provisioning profile'
inputs:
provisioningProfileLocation: sourceRepository
provProfileSourceRepository: 'path/path/Profile_*****.mobileprovision'
steps:
- task: Xcode#5
displayName: 'Xcode clean build'
inputs:
actions: 'clean build'
xcWorkspacePath: path/path/App.xcworkspace
scheme: App
packageApp: true
signingOption: manual
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
args: '-allowProvisioningUpdates'
workingDirectory: '$(System.DefaultWorkingDirectory)/ios'
Appended you can find some screenshots:
Provisioning Profile
OneSignal Error

Related

How to add ManualValidation task on Azure DevOps

I have tried to use ManualValidation task in my pipeline but it did not passed because it is not installed from the market place but, when I go on the page on the market place I can not find any extension for manual validation on pipeline. Can someone provide me with information about this?
My azure-pipeline.yml looks like this:
trigger:
main
jobs:
job: waitForValidation
displayName: Wait for external validation
pool: server
timeoutInMinutes: 4320
steps:
task: ManualValidation#0
timeoutInMinutes: 1440
inputs:
notifyUsers: |
myemail#name.com
instructions: 'Please validate the build configuration and resume'
onTimeout: 'resume'
A task is missing. The pipeline references a task called 'ManualValidation'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com.

App Center Test task: uitest (Xamarin UI Test) DevOps AppCenterTest#1

I try to test a Xamarin App, works on localhost, doesn't seems to work on Azure DevOps.
Error Android:
Preparing tests... failed.
Error: Failed to prepare UI Test artifacts using command "test-cloud.exe prepare" with error message:
There was an unknown error preparing test artifacts, please try again. If you can't work out how to fix this issue, please contact support.
- task: AppCenterTest#1
displayName: 'App Test Android'
inputs:
appFile: '$(System.DefaultWorkingDirectory)/app.apk'
artifactsDirectory: '$(Build.ArtifactStagingDirectory)'
uitestToolsDir: '$(System.DefaultWorkingDirectory)'
frameworkOption: uitest
serverEndpoint: 'androidEndPoint'
appSlug: 'MyOrg/Android'
uiTestBuildDirectory: '$(System.DefaultWorkingDirectory)'
debug: true
enablePrepare: true
devices: bc141325
userDefinedLocale: 'de_DE'
series: 'master'
Error iOs:
Response status code: 400
Body: {"message":"The .ipa file does not seem to be linked with Calabash framework."}
Starting test run... failed.
Error: The .ipa file does not seem to be linked with Calabash framework.
- task: AppCenterTest#1
displayName: 'App Test Mac'
inputs:
appFile: '$(System.DefaultWorkingDirectory)/iosapp.ipa'
artifactsDirectory: '$(Build.ArtifactStagingDirectory)/AppCenterTest'
frameworkOption: uitest
serverEndpoint: 'iosappEndPoint'
uitestToolsDir: '$(System.DefaultWorkingDirectory)'
appSlug: 'MyOrg/iosapp'
devices: 'MyOrg/test'
enablePrepare: true
userDefinedLocale: 'de_DE'
showDebugOutput: true
uiTestBuildDirectory: '$(System.DefaultWorkingDirectory)'
series: 'master'
Why Calabash?
I also installed this and running on a macOS-latest host:
- task: NodeTool#0
inputs:
versionSpec: '16.14.2'
- task: Bash#3
displayName: 'npm install -g appcenter-cli'
inputs:
targetType: 'inline'
script: |
npm i -D webpack#latest
npm install -g appcenter-cli
workingDirectory: '$(System.DefaultWorkingDirectory)'

Azure pipeline fails on building Kotlin Multiplatform shared framework usinig embedAndSignAppleFrameworkForXcode and fastlane

I'm working on a Kotlin Multiplatform project which is building fine locally but I can't get it to work on an Azure DevOps pipeline.
Some good things to know:
not using Cocoapods
using the embedAndSignAppleFrameworkForXcode gradlew command in Build Phases
all commands using fastlane work for multiple developers locally
we use custom configurations like: ProjectADebug/ProjectARelease but we defined KOTLIN_FRAMEWORK_BUILD_TYPE for all of them
I'm trying to get an Azure DevOps pipeline to build and upload to App Store Connect using fastlane. We are using match for signing, that works great. Archiving fails and it looks like it's failing on building the shared KMM framework.
Anybody with the same problems that could help me out? Or some tips how I can view those gym logs on the Azure VM because I assume there it says what actually went wrong instead of this general error.
▸ Running script 'Build Kotlin Common'
▸ Copying /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/BuildProductsPath/ProjectRelease-iphoneos/Airship_AirshipCore.bundle
▸ Copying /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/BuildProductsPath/Project Release-iphoneos/Airship_AirshipAutomation.bundle
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Build\ Kotlin\ Common /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/IntermediateBuildFilesPath/Project.build/ProjectRelease-iphoneos/Project.build/Script-2F4970EC27CD16A000E32F91.sh (in target 'Project' from project 'Project')
(1 failure)
ERROR [2022-05-10 13:04:32.36]: Exit status: 65
ERROR [2022-05-10 13:04:32.53]: ⬆️ Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
WARN [2022-05-10 13:04:32.53]: 📋 For the complete and more detailed error log, check the full log at:
WARN [2022-05-10 13:04:32.53]: 📋 /Users/runner/Library/Logs/gym/Project-Project.log
This is the the lane in Fastfile:
lane :azure_beta do |options|
label = options[:label].capitalize
git_url = "someURL"
match(
type: "appstore",
readonly: true,
git_url: git_url,
keychain_name: ENV["MATCH_KEYCHAIN_NAME"],
keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"],
verbose: true
)
build_app(
project: "../Project/Project.xcodeproj",
configuration: "#{label}Release",
scheme: label
)
# fails on the build_app step...
changelog = changelog_from_git_commits(
pretty: "- (%ae) %s",
date_format: "short",
merge_commit_filtering: "exclude_merges"
)
upload_to_testflight(
changelog: changelog,
app_identifier: label == "Project" ? idsProjectA : idsProjectB,
skip_waiting_for_build_processing: true
)
version_number = get_version_number(
xcodeproj: "../Project/Project.xcodeproj",
target: "Project", #Hardcoded because we have multiple targets, label is specificed in build_app configuration
configuration: "#{label}Release"
)
add_git_tag(
includes_lane: false,
prefix: "ios-#{label.downcase}-#{version_number}-",
build_number: number_of_commits
)
delete_keychain(name: ENV["MATCH_KEYCHAIN_NAME"])
end
And this is my pipeline YAML:
pool:
vmImage: 'macos-latest'
variables:
- group: fastlane
jobs:
- job: testflight
steps:
- task: Bash#3
displayName: fastlane update
inputs:
targetType: 'inline'
script: |
gem update fastlane
fastlane --version
- task: JavaToolInstaller#0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Bash#3
displayName: 'Update Dependencies'
inputs:
targetType: 'inline'
script: HOMEBREW_NO_AUTO_UPDATE=1 brew bundle
- task: Bash#3
displayName: "Set build properties"
inputs:
targetType: 'inline'
script: |
echo "sdk.dir=/Users/runner/Library/Android/sdk"
echo "INCLUDE_MOCKER=false" >> local.properties
echo "INCLUDE_ANDROID=false" >> local.properties
echo "INCLUDE_TESTER=false" >> local.properties
echo "APP_LABEL=$(APP_LABEL)" >> local.properties
env:
APP_LABEL: $(APP_LABEL)
- task: Gradle#2
displayName: 'Clean label common'
inputs:
workingDirectory: ''
tasks: "common:cleanLabel"
env:
APP_LABEL: $(APP_LABEL)
- task: Bash#3
displayName: fastlane ios
env:
MATCH_PASSWORD: $(MATCH_PASSWORD)
FASTLANE_PASSWORD: $(FASTLANE_PASSWORD)
FASTLANE_SESSION: $(FASTLANE_SESSION)
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: $(FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD)
inputs:
targetType: 'inline'
script: |
sudo xcode-select -s /Applications/Xcode_13.2.app
cd ios/Project
fastlane azure_beta label:Project app_identifier:project.bundle.id itc_team_id:itc.team.id team_id:team.id git_match_branch:master username:me#myself.com
As it turned out there was an error in building the common KMM layer, I would have found it when doing a clean checkout probably but I found out by using a self-hosted agent on Azure Devops so I could navigate to the /Users/runner/Library/Logs/gym/Project-Project.log as Pylyp Dukhov suggested.

Pass "What went wrong" Gradle error message to another Job in Azure Pipelines

Context: performing Android instrumentation (UI) tests with Azure Pipelines.
There are 2 jobs: one does the testing (launches an emulator and runs the tests), and the other job reports an error, if the previous job fails for some reason.
I have the following simple setup in my Azure Pipelines:
jobs:
- job: SmokeTesting
displayName: Smoke testing
timeoutInMinutes: 60
pool:
vmImage: 'macOS-latest'
steps:
- script: meta/scripts.sh launch_avd
displayName: Launch AVD
workingDirectory: ''
- task: Gradle#2
displayName: Run smoke tests
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
publishJUnitResults: true
tasks: ':app:connectedAndroidTest'
- job: ReportFailure
displayName: Report failure
dependsOn:
- SmokeTesting
condition: or(failed(), canceled())
steps:
- script: meta/scripts.sh report_smoke_tests_error
workingDirectory: ''
env:
BUILD_ID: $(Build.BuildId)
It all works as expected: if there is an error, the second job is run. In this case, the log in Azure Pipelines Web contains very useful information, that I would like to have access to in the second job:
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No version of NDK matched the requested version 22.0.7026061. Versions available locally: 18.1.5063045, 21.3.6528147, 21.3.6528147
How do I get "What went wrong" message in my second job?
My idea is to use multi-stage variable to record the message in the first job, and then use it in the second one. Unfortunately, I haven't figured out how to get this message in the first place.
As a workaround, you can use the Build Timeline api to get detailed build information. The api response contains the property issues, you can check the results there if there is an errors.
https://dev.azure.com/{org}/{pro}/_apis/build/builds/3838/timeline/?api-version=6.0
If the issues does not contain the error message you want, you can retrieve the content related to Gradle#2 task in the response body. Obtain the log url according to the property log.
By calling this log url, you can get the log of Gradle#2 task, and then parse the log to get the desired message.

Azure CI pipeline build error while building Xcode project

I am trying to set up a CI pipeline using Azure DevOps and i am getting an error as follows while running the pipeline in the xcode section:
'FirebaseCore/FirebaseCore.h' file not found
#import <FirebaseCore/FirebaseCore.h>
'FirebaseCore/FirebaseCore.h' file not found
#import <FirebaseCore/FirebaseCore.h>
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
##[error]Error: /usr/bin/xcodebuild failed with return code: 65
Finishing: Xcode
A small part of my podfile is as follows:
#Firebase
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'FirebaseInstanceID', '~> 4.3'
And my azure-pipelines.yml file looks like this:
pool:
vmImage: 'macos-latest'
steps:
- task: CocoaPods#0
inputs:
forceRepoUpdate: true
projectDirectory: '$(system.defaultWorkingDirectory)'
displayName: 'pod install using the CocoaPods task with a forced repo update and a custom project directory'
- task: Xcode#5
inputs:
actions: 'build'
scheme: ''
sdk: 'iphoneos'
configuration: 'Release'
xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace'
xcodeVersion: 'default' # Options: 8, 9, 10, default, specifyPath
I was been trying to get it solved by trying many fixes, but nothing helped. And now i don't know what to do. I would be really satisfied if anyone helps me out in this.

Resources