Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added build options for .ipa generate #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var cordova = cordovaLib.raw;

module.exports = function (options) {
options = options || {};
var device = options.device || true;
var release = options.release || false;

return through.obj(function (file, enc, cb) {
// Change the working directory
Expand All @@ -20,7 +22,9 @@ module.exports = function (options) {

cb();
}, function (cb) {
var exists = fs.existsSync(path.join(cordovaLib.findProjectRoot(), 'platforms', 'ios'));
var self = this;
var iosPath = path.join(cordovaLib.findProjectRoot(), 'platforms', 'ios');
var exists = fs.existsSync(iosPath);

Promise.resolve()
.then(function () {
Expand All @@ -36,10 +40,38 @@ module.exports = function (options) {
}
})
.then(function () {
var options = [];

if (device) {
options.push('--device');
}
if (release) {
options.push('--release');
}

// Build the platform
return cordova.build({platforms: ['ios']});
return cordova.build({platforms: ['ios'], options: options});
})
.then(function () {
var base = path.join(iosPath, 'build/device');
var cwd = process.env.PWD;

// Iterate over the output directory
fs.readdirSync(base).forEach(function (file) {
// Check if the file ends with .apk
if (file.indexOf('.ipa') !== -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment talks about '.apk', not '.ipa'

FWIW: This comment seems redundant for anyone able to read the code :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment.

var filePath = path.join(base, file);

// Push the file to the result set
self.push(new gutil.File({
base: base,
cwd: cwd,
path: filePath,
contents: fs.readFileSync(path.join(base, file))
}));
}
});

cb();
})
.catch(function (err) {
Expand Down
37 changes: 35 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ gulp.task('build', () => {
.pipe(create())
.pipe(plugin('org.apache.cordova.dialogs'))
.pipe(plugin('org.apache.cordova.camera'))
.pipe(ios());
.pipe(ios())
.pipe('ios');
});
```

Expand All @@ -43,12 +44,44 @@ Default: `false`

If the value is `true`, this will cause the ios platform to be removed and re-added.

#### version
##### version

Type: `string`

iOS platform version.

##### device

Type: `boolean`<br>
Default: `true`

If the value is `true`, this will build .ipa file as result.

**You must provide build.json file in cordova project directory**

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this: /usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(security cms -D -i pathtofile.provision)

(See http://stackoverflow.com/questions/9264727/code-sign-identity-parameter-for-xcodebuild-xcode4#comment44411234_14967770)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added solution to readme.


##### release

Type: `boolean`<br>
Default: `false`

If the value is `true`, this will build .ipa and sign it with release certificates

## Related

Expand Down