Nextstop 3 Release Build Process: iOs & Android

Dependencies

TODO: Add separate document / section for complete dev env setup and potential issues LTS version
Install Node.js https://nodejs.org/en/download/

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

 

Install Source Tree https://www.sourcetreeapp.com/

or

1 brew install tree

Install source tree either with the download link or terminal command.

TODO: screenshots for creating release version

 


Install XCode https://apps.apple.com/us/app/xcode/id497799835?mt=12

X Code is needed to add all the necessary build tools and sign the IPA file.

 

TODO: Add steps and screenshots for which of the build tools to install/sdk manager

Install Android Studio https://developer.android.com/studio/?gclsrc=aw.ds&gclid=CjwKCAjw4qCKBhAVEiwAkTYsPOTzxCB2kVcRqPCWmmW9nBlTXcy3UC9K59e0aTCGP4LzzOEbpL5muBoCgU4QAvD_BwE

or

Android studio is needed to add all the necessary build tools and sign the APK file. Make sure to add the path variable to your shell config. You will need to confirm that the android build tools that you have installed via Android Studio SDK tools, exist at the paths specified. Paths may change.

1 $ export ANDROID_SDK_ROOT=/Users/${USER}/Library/Android/sdk
1 $ export PATH=${PATH}:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools/32.0.0


Install Angular CLI https://angular.io/cli

or

1 npm install -g @angular/cli

The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from terminal.

 


Install Ionic CLI https://ionicframework.com/docs/cli

or

1 npm install -g @ionic/cli

The Ionic command-line interface (CLI) is the go-to tool for developing Ionic apps. Install framework globally with npm.



Install Cordova CLI https://cordova.apache.org/docs/en/10.x/guide/cli/

or

1 npm install -g cordova

The command line tool to build, deploy and manage Cordova-based applications. Apache Cordova allows for building native mobile applications.

TODO: Add commands to use when troubleshooting cordova platform issues


Setting Up Files

TODO: Add steps for SSH/ troubleshooting
Clone repo with SSH

1 git clone git@bitbucket.org:cxtsoftware/nxt.git


Navigate to the directory of the repo

1 cd ~/nxt


Install npm

1 npm install

 

TODO: Add the rest of the lines where version needs to be upgraded and screenshots

Test run android build

1 ionic cordova build platform android

It is good practice to make sure that the build will successfully compile first, also this will generate the debug.apk file that you will need to upload. Once the build is finished you can locate the apk file at the path that is specified in the terminal

~/nxt/platforms/android/app/build/outputs/apk/debug/app-debug.apk

Take the APK file and move it somewhere out of the directory where you can grab it later. I like to setup an automated rule using automator to move the file to a directory where it is easily accessible you can also like that directory to your google drive for convenience.

TODO: Optional add steps for automating xfer to QA

 

Start android release build

1 ionic-cordova-build --platform-android --release --prod

This will build the release APK, this will take longer to complete as the code is minified and other measures are taken to optimize the app.

~/nxt/platforms/android/app/build/outputs/bundle/release/

Again grab the APK file and move it to your collection. This is the Unsigned APK, you will need to sign this with Android Studio in order to submit it to the Google Play Store


TODO: Add screenshots for android studio
1. Open Android Studio and select the path to yours platforms folder:
~/nxt/platforms/android

2. Click on the path once it is added to the projects and launch the editor, if you notice in the bottom right there are some actions being taken, indexing, installing different dependencies. Allow this to finish before doing anything else. Also, when any prompts for dependencies ask for upgrading in Android Studio accepting the upgrades could cause potential issues in the build and with other plugins.

3. On the app menu click “Build” > “Generate Signed Bundle APK.

4. On the pop up tick the APK bubble > Next.

5. The “Keystore Path” can be located in the root of the nxt project.

6. For the key alias you can open the folder and chose the default alias. Key store password and the Key password are the same. See 1Password for the credentials.
7. On the next dialog select the “Release” option and click Finish

8. You can view the progress in the bottom right of the editor, when the build is finished you will see a pop up indicating that the APK was generated successfully. You can click the “Locate” link to navigate to the directory. Grab this file and put it in your collection.

Run the android release build for the unsigned.apk file

1 ionic-cordova-build --platform-android --release --prod

This will build the release APK once again this time we are going to grab the file from the path and add it to our collection.

~/nxt/platforms/android/app/build/outputs/bundle/release/

This file is requested by certain customers as they may use Mobile Device Managers for their drivers, product is instructed to provide the unsigned.apk to certain customers on each release.

 


Building the iOs Release
TODO: Screenshots

1 ionic-cordova-build --platform-ios

Again, good practice to make sure that the build will successfully compile first. The iOs build is notoriously finicky, due to Xcode. Sometimes it can fail for seemingly no reason. You may have to run the build a few times. See Google for any errors that are returned.

 

Common Troubleshooting Steps

Remove and Re add the iOs platform

1 ionic cordova platform remove ios
1 ionic cordova platform add ios"

 

2. Delete node_modules folder then npm install

3. List all cordova plugins and remove them and reinstall

1 cordova plugin -l | xargs cordova plugins rm

 

4. List all plugins and remove them one by one

1 cordova plugin ls
1 cordova plugin remove <PLUGIN_NAME>

 

5. Individually re add the plugins back to the list

1 cordova plugin add <PLUGIN_NAME>


Building IPA to be signed

1 ionic-cordova-build --release --prod

This will build the unsigned IPA file and generate it to the following path:

~/nxt/platforms/android/app/build/outputs/bundle/release/

Add this to your collection as well as some customers have requested the unsigned version.

  1. Open XCode, and again you might need to select the path to yours platforms folder:

~/nxt/platforms/ios

  1. It is good practice to let XCode finish its indexing and processes before taking any further steps. At the top of the XCode app you will see when the status is ready to build by the counter on the top right of the app.

  2. Navigate to Product > Archive.

  3. Locate the built app in the top of the archives window

  4. Click the “Validate app” button. This will validate the app to confirm that it is able to be uploaded to the app store. This part is important because if you don’t validate the app first, and then attempt to distribute the app and a failure were to occur, then you will be unable to submit the app with the same version number, Which means that you will have to rebuild the android app as well, bump the version number, create a new release ticket, etc.

  5. Leave the default options selected, Next.

  6. Select “Automatically Manage Signing”, Next.

  7. Once you get to the review screen click “Validate”.

  8. The app will be signed and verified this could take a few minutes, wait for this to complete.

  9. Once this is finished, click Done. You can now close Xcode.


TODO: iOs Release Build process & suggested troubleshooting and commands
TODO: Provide screenshots and link to 1pass along with any shell config/commands defaults needed for this

1 2 xcodebuild -workspace platforms/ios/Nextstop.xcworkspace -scheme Nextstop -sdk iphoneos -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO'

Note: This is a custom solution that was put in place to provide this file to customers, this isn’t supported by Xcode or Apple. If this doesn’t function at some point it may no longer be possible or a new solution might need to be found. You will also need to add the alias to your preferred shell config file.

This alias will run a sequence of commands that will generate an unsigned version of the IPA file. Once this has been generated you can add the file to your collection for upload. Path:

~/Library/Developer/Xcode/DerivedData/Nextstop/$(randomkey)/Build/Products/Release-iphoneos

  1. Once the file is generated there is one other step that you need to take to make the file format correct and readable.

  2. Create a new folder on your desktop or somewhere called “Payload”.

  3. Copy and paste the file into the folder.

  4. Compress the folder to a zip file.

  5. Rename the file “Unsignedios.ipa”.

  6. Add this file to your collection for upload.

 

Uploading to MediaFire

  1. Navigate to https://www.mediafire.com/.

  2. Log in with the credentials in 1Password.

  3. Navigate to the “Nextstop 3”.

  4. Create a new folder with the name of the release version.

  5. Upload your files to the directory:

TODO: Add file definitions and uses

1 app-debug.apk
1 app-release.aab
1 app-release.apk
1 unsignedios.ipa


6. Share the folder that you created in MediaFire, Copy and paste the share link and add it to the release ticket in XD.

7. Finally make sure that you commit and push the final changes on the release branch with the release version as the commit message.

8. Once you have pushed changes from your branch you will receive a warning in the terminal, run the command that it returns for your version. Example:
TODO: Screenshots

1 git push --set-upstream origin release/3.3.0

8. In Source tree you now need to finish the release

9. Navigate to Repository > Git Flow > Finish Release

10. Confirm that the correct version is selected in the top dropdown.

11. Check “Delete Branch” and “Push Changes to Remote”, click OK

12. You will see a newly created tag for the release version and all branches are up to date with the final changes.

13. The process of the apps being placed into the App stores for Google and iOS are handled by the Product Team. You are finished with the build process.