Sunday, 12 April 2020

Build a flutter app for IOS using codemagic - Part 2


In this article we will see how to build a flutter app for IOS using codemagic if we had already generated a key using a mac. Except for the first step all other steps are similar to my previous article

Step 1: Get the certificates from mac

In your mac open Keychain Access. Locate the key that you had used to sign the app previously. Select that along with the private key and right click “Export” select file format as .p12 and save. Enter a password and verification for the file and click ok. Enter your mac password and click ok and save your file. Once you have the p12 file file you can use it from other computers with different os.

Step 2: Add the identifiers


On the apple developer page. Click on "Identifiers" and then click the Plus sign near the heading that says Identifiers, select “App IDs” and continue. Enter the name of your app in Description and your apps Bundle ID in the respective field. Click Continue. Make sure the bundle Id match with your apps bundle ID in "\ ios\ Runner.xcodeproj\ project.pbxproj".

Step 3: Add test Devices (optional) 


On the apple developer page. Click on "Devices" and then click the Plus sign near the heading that says Devices, Give a name to the device so that you can identify it. And enter the UDID of the device. Click Continue and register. Repeat for all devices you may want to distribute the app. 

Step 4: Add distribution profiles


On the apple developer page. Click on "Profiles" and then click the Plus sign near the heading that says Profiles, Since we generated the sign key for Distribution. Select an option under “Distribution”,  I will be using "Ad Hoc" so choose it and click continue.
  • Under App ID select the name you created for Step2 and click continue.
  • In the next step select the key you created previously in Step1 and click continue
  • In the Select Devices step select all the devices you want to install the app on. (Probably the ones created in Step3). Click continue
  • Enter a name for your profile under Provisioning Profile Name. Click Generate and Download the mobileprovision file


Note: You can generate multiple provisions for the same app. Maybe an 'App Store' provision in addition to the 'Ad Hoc' provision

 Step 5: Configuring codemagic


I have assumed that you have already linked your git repo with codemagic and the project you want to build is open
  • Expand Build, Set the necessary version for Flutter and Xcode. Under 'Build for platforms' uncheck the platforms you don’t need and change the Mode to release. Click save
  • Expand Publish,
  1. Under 'iOS code signing' choose Manual.
  2. Under 'Code signing certificate' click choose a file and browse and select the .p12 file we created in Step1
  3. Enter the password you had given to the file in the 'Certificate password' field
  4.  Under 'Provisioning profiles' upload the Profiles you generated in Step4. Save it
Click on 'Start new build'

Step 6: Distributing the app


Once the build finishes you will get an email with the .ipa file and a .app file. You can upload the .ipa file to sites like diawi and share the link with users whose mobile numbers are registered in the app.

Limitations

  • By moving away from mac. We lose the ability to use the Xcode simulator. So we can only test the app after a user/test-user installs it in a real device. A workaround can be found here
  • Since we are building on codemagic. We can't use custom edited packages. ie., in case we had manually edited a package in our local environment those changes can't be expected in the codemagic build since it will fetch from the original package repository. A workaround can be found here



No comments:

Post a Comment

Setting GitHub hooks in Jenkins

While setting up a Freestyle project in Jenkins we may need to set Github webhooks in Jenkins so that Jenkins will get notified each time th...