0

I am stuck at some point using gulp!

I know gulp is used for concatenating files, minifying scripts, compiling scss files but I am looking for some task through which I can create build of my application and .ipa file of application.

How we can achieve it using gulp task?

Mr. Noddy
  • 1,530
  • 2
  • 16
  • 45

2 Answers2

1

I have done some workaround and found nice solution for creating .ipa using gulp...

First Step :

Reference : How can I deploy (create .ipa) iphone app using 'cordova build ios --release'?

If you are using cordova ios 3.9.0 or newer, you can use this command to create the .ipa directly from the CLI with no extra commands:

cordova build ios --device --release You'll need a build.json file on the root of your project

{
     "ios": {
         "debug": {
             "codeSignIdentitiy": "iPhone Developer",
             "provisioningProfile": "your-dev-provisioning-profile-UUID-here"
         },
         "release": {
             "codeSignIdentitiy": "iPhone Distribution",
             "provisioningProfile": "your-distribution-provisioning-profile-UUID-here"

         }
     }
 }

To get the UUID I open the .mobileprovision file on a text editor and search for 'UUID', not sure if there is an easier way of finding it.

Second Step:

Reference : How to execute shell command using gulp

Write a gulp task to execute shell command

var IOS_BUILD_COMMAND = 'ionic build ios';
var IOS_IPA_COMMAND = 'cordova build ios --device --release';

gulp.task('ios_build', function (cb) {
  exec(IOS_BUILD_COMMAND, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    cb(err);
  });
});

gulp.task('ios_ipa', function (cb) {
  exec(IOS_IPA_COMMAND, 
    {
        cwd : './',
        maxBuffer: 500 * 1024
    },
    function (err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        cb(err);
    });
}); 

Third Step :

Execute gulp -r from command line.

And Yo... its done..!!

Community
  • 1
  • 1
Mr. Noddy
  • 1,530
  • 2
  • 16
  • 45
0

I'm not very familiar with ionic in particular, but as far as I know, it uses Cordova underneath.

You can use a build.json file to manage the app signing configurations. (docs)

For example:

{
     "ios": {
         "debug": {
             "codeSignIdentity": "iPhone Development",
             "provisioningProfile": "926c2bd6-8de9-4c2f-8407-1016d2d12954",
         },
         "release": {
             "codeSignIdentity": "iPhone Distribution"
             "provisioningProfile": "70f699ad-faf1-4adE-8fea-9d84738fb306",
         }
     }
 }

You can even take it a step further and use Fastlane tools to handle the certificates.

Sigh can be used in a Cordova before_build hook to make sure a new certificate is used.

#!/usr/bin/env node
'use strict';

var path = require('path');


module.exports = function(context) {
  if (context.opts.platforms.indexOf('ios') === -1) {
    return;
  }
  var ConfigParser = context.requireCordovaModule('cordova-common').ConfigParser;
  var superspawn = context.requireCordovaModule('cordova-common').superspawn;

  var config = new ConfigParser(path.resolve(context.opts.projectRoot, 'config.xml'));

  var id = config.ios_CFBundleIdentifier() || config.packageName();
  var sighArgs = ['--app_identifier', id, '--username', '<your apple id here>'];
  return superspawn.spawn('sigh', sighArgs, {stdio: 'inherit'});
};

Taking it a step further, Deliver can be used to automate uploading the ipa to the App Store.

Of course these tools can be run from a gulp task instead of a Cordova hook as well if you prefer.

Remco Haszing
  • 7,178
  • 4
  • 40
  • 83