Azure Pipelines hates when Expo dates Firebase
Nikola Gorgiev
Software Developer | Flutter Enthusiast | React | React Native | Electron | JavaScript | TypeScript
The Problem
I am not even sure how to start on this article, but I would say that Azure hates when Expo start dating Firebase. What do I mean by this. Few days ago i have written an article about implementing Firebase Push Notifications in Expo app, and that all went fine, until I have tried building the app with the Azure Pipelines, and 55 builds later, and 3 days with no sleep, here I am writing this article so you won't have to go to the same hell as me.
The thing is that once you install react-native-firebase/app or react-native-firebase/messaging and try to build the app on azure, it will start giving you the error code:65, which basically means, there is some issue with signing the app, and no matter what you try, nothing will work, at least I didn't find a way to make the xCode@5 task work, manual signing, no sign, auto, export, every possible combination with the parameters, it just throws the error code:65 in less then 60 seconds after the task has started, but with the same configuration locally everything works fine (talking about iOS, Android is fine)
I went that far that I have literally replicated the entire Azure machine on my local machine, installed the same version of macOS, xCode, cocoapods, node, removed all the certificates from keychain and just install the p12 I am providing to Azure via the Secret Files, even publishing the entire repo after the task fails, and trying to build it locally, still nothing.
The Solution
After 3 days of trouble, and not entire understanding of the problem, I got the pipelines work again. The problem as I understood, because of how the xCode@5 task works behind the hood, it causes come issue when you "try to sign the firebase part of the code", and to solve it, you have to build the app with the good old scripts, and use the "xcodebuild".
When you build the app, you need to build it with "CODE_SIGNING_ALLOWED=NO", and archive the build, which will produce an xcarchive file, and with another script you will export IPA from that file, and for the export of the IPA you will need to create ExportOptions.plist file in the root of your repo, where you will configure the signing of the app.
Lets first start with the ExportOptions.plist, and it should looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>development</string>
<key>provisioningProfiles</key>
<dict>
<key>BUNDLE_ID</key>
<string>PROVISION_PROFILE_NAME</string>
</dict>
<key>signingStyle</key>
<string>manual</string>
<key>teamID</key>
<string>TEAM_ID</string>
<key>compileBitcode</key>
<false/>
</dict>
</plist>
where:
领英推è
BUNDLE_ID - the bundle ID of your app (Ex. com.myapp.app)
PROVISION_PROFILE_NAME - the name of the Provision Profile, you can fine it on the Apple Developer website, open the Provision Profile, and there is Name field.
TEAM_ID - your Apple Developer Team ID, which you can also fine in the Membership Details inside the Apple Developer website.
Next lest see the first new script about building the App:
- script: |
xcodebuild -workspace ios/WORKSPACE_NAME \
-scheme SCHEME_NAME \
-sdk iphoneos \
-configuration Release \
-archivePath output/XCARCHIVE_FILE \
CODE_SIGN_IDENTITY="iPhone Developer" \
PROVISIONING_PROFILE_SPECIFIER="PROVISION_PROFILE_NAME" \
CODE_SIGNING_ALLOWED=NO \
clean archive
displayName: "Build iOS App with Xcode"
where:
WORKSPACE_NAME - is the workspace file inside the ios folder (ex. myApp.workspace)
SCHEME_NAME - the name of the schema of the ios project
XCARCHIVE_FILE - the name of the xcarchive file that this script will output (ex. myApp.xcarchive)
PROVISION_PROFILE_NAME - the name of the Provision Profile, you can fine it on the Apple Developer website, open the Provision Profile, and there is Name field.
The next one is Exporting the IPA:
- script: |
ARCHIVE_PATH=output/XCARCHIVE_FILE
EXPORT_PATH=output
EXPORT_OPTIONS_PLIST=EXPORT_OPTIONS_PLIST
# Export IPA from .xcarchive
xcodebuild -exportArchive \
-archivePath $ARCHIVE_PATH \
-exportPath $EXPORT_PATH \
-exportOptionsPlist $EXPORT_OPTIONS_PLIST
displayName: "Export IPA from Archive"
Where:
XCARCHIVE_FILE - the name of the xcarchive file that this script will output (ex. myApp.xcarchive)
EXPORT_OPTIONS_PLIST - the name of the export options plist we have created (ex. ExportOptions.plist)
to play it safe, before i run the first script, i am cleaning and reinstalling the cocoa pods, I am not sure if this is needed, but from all the things i have tried, this was one of them, it didn't help to get rid of the error code:65, but it didn't cause any harm, so I have forgot to remove it, and not when i have everything working, i don't want to wait 1 more hours for another build to see if removing this will break the pipelines, so here it is (it takes 60 seconds to run, so its not a big deal for me):
- script: |
pod deintegrate
pod clean
pod install
workingDirectory: 'ios'
displayName: 'Clean and Reinstall Pods'
JUST BE AWARE, AFTER FIXING THE BUILD, THE PUSH NOTIFICATIONS WONT WORK, AND TO MAKE THEM WORK YOU NEED TO BUILD THE APP LOCALLY, SO THIS IS JUST TO BE STILL ABLE TO USE AZURE PIPELINES.
Student at Dalia institute
4 个月Hello , I am laravel developer and I have 3 years of experience . Have any vacancy in php - laravel developer? My contacts/ whatsapp is 9879185478.