Cordova – Ionic Framework PhoneGap Build: Workflow

I am trying to use Phonegap Build to compile my Ionic application (I am using a Mac, so I cannot compile to iOS).

What is the most Good workflow?

Thank you

After playing this game all night and all morning, I came up with a hacked solution.
Hope it can help someone.

As for ionic v1.0, at least for my simple project, the biggest difference is< /p>

> config.xml
>All image resources are in ./resources

What I did:
config.xml changes:

> Created a new file in .www/config_phonegap.xml based on config.xml
>Change the namespace on the widget node to phonegap(xmlns:gap=”http://phonegap.com/ns/1.0″ )
>Use regular expression search and replace to change all icons and startup tags to the corresponding phonegap equivalents
>Manually create the necessary “gap:plugin” tags for any plugins

gulp Add:

>Created a gulp task, convert .www/ to ./phonegap folder
> gulp task also copy resources
> gulp task coipies over config_phonegap.xml and put it Rename to config.xml
> The gulp task compresses our new www folder. (There should be no top-level www in the zip file. That is, we only want to compress the content of www)

This means mine The build workflow (until I need to change something in config.xml) now looks like this:

> gulp phonegap
>upload phonegap.zip to https://build.phonegap .com

Obviously there are many areas for improvement, but I now need to use it to publish. Before creating static config_phonegap.xml, I explored some ideas, such as xml parsing in JS or making XSLT File. For effort, this seems to be a low return, so I didn’t stick to it.

This is the relevant code bit for reference.
Regular expression:

p>

### icon regex
# android



# ios




### splash regex
# android



#ios

Example phonegap compatible config.xml:



my app name

la di da desc
< /description>
w--





< preference name="UIWebViewBounce" value="false"/>

< br />






< icon src="resources/android/icon/drawable-xxhdpi-icon.png" gap:platform="android" gap:qualifier="xxhdpi"/>









< br />




















< br />






















Swallowing task:

// **** Build phonegap * ****/
var PHONEGAP_BUILD_FOLDER ='../phonegap',
PHONEGAP_RAW_FOLDER ='www',
IONIC_SOURCE_FOLDER ='./www',
IONIC_RESOURCE_FOLDER ='./ resources'
PHONEGAP_ZIP_FILE ='phonegap_build.zip';

gulp.task('phonegap', function(cb){
runSequence('clean_phonegap',
' copy_www',
'copy_resources',
'copy_phonegap_config_xml',
'copy_default_icon',
'copy_default_splash',
'zip_phonegap',
cb);
});

gulp.task('clean_phonegap', function(cb){
// clean our folder first
var phonegap_del_pattern = PHONEGAP_BUILD_FOLDER +'/* ';
del([phonegap_del_pattern], {force: true}, cb);
})

gulp.task('copy_www', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER
return gulp.src([IONIC_SOURCE_FOLDER +'/**'])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder))
})

gulp.task('copy_phonegap_config_xml', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER
return gulp.src(['config_phonegap .xml'])
.on('error', swallowError)
.pipe(rename('config.xml'))
.pipe(gulp.dest(target_phonegap_folder));< br />})

gulp.task('copy_resources', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER +'/resources',
exclude_pattern ='!' + IONIC_RESOURCE_FOLDER +'/_source_assets{,/**}'

// exclude pattern needs to go first. mother fucker.
return gulp.src([exclude_pattern, IONIC_RESOURCE_FOLDER +'/**'])
.on('error', swallowError)
.pipe(gulp.de st(target_phonegap_folder));
})

gulp.task('copy_default_icon', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER +'/ios/icon.png' ])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})

gulp.task('copy_default_splash', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER + '/splash.png' ])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})


gulp.task('zip_phonegap', function(){
var sourcephonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER
return gulp.src(sourcephonegap_folder +'/**')
.pipe(zip('phonegap.zip'))
.on('error', swallowError)
.pipe(gulp.dest(PHONEGAP_BUILD _FOLDER));
})

I am trying to compile my Ionic application using Phonegap Build (I am using a Mac, so I cannot compile to iOS) .

What is the best workflow?

Thank you

After playing this game all night and all morning, I came up with a hacking solution.
Hope it can help someone.

As for ionic v1.0, at least for my simple project, the biggest difference is

> config.xml
>All image resources are in ./resources

What I did:
config.xml changes:

>Based on config.xml in .www/config_phonegap.xml Created a new file in
>Change the namespace on the widget node to phonegap(xmlns:gap=”http://phonegap.com/ns/1.0″)
>Use regular expressions to search and replace All icons and startup tags are changed to the corresponding phonegap equivalents
>Manually create the necessary “gap:plugin” tags for any plugins

gulp add:

>created A gulp task, convert .www/ to ./phonegap folder
> gulp task also copy resources
> gulp task coipies over config_phonegap.xml and rename it to config.xml
> gulp task Compress our new www folder. (There should be no top-level www in the zip file. That is, we just want to compress the content of www)

This means my build workflow (until I need to in config.xml (Change some content) now looks like this:

> gulp phonegap
>upload phonegap.zip to https://build.phonegap.com

Obviously there is There are many areas for improvement, but I now need to use it to publish. Before creating static config_phonegap.xml, I explored some ideas, such as xml parsing in JS or making XSLT files. For effort, this seems to be a low return , So I didn’t stick to it.

This is the relevant code bit for reference
Regular expression:

### icon regex
# android



# ios




### splash regex
# android



#ios

Example phonegap compatible config.xml:



my app name

la di da desc

w- -






< br />
























































< br />





Swallowing task:

// * *** Build phonegap *****/
var PHONEGAP_BUILD_FOLDER ='../phonegap',
PHONEGAP_RAW_FOLDER ='www',
IONIC_SOURCE_FOLDER ='./www',
IONIC_RESOURCE_FOLDER ='./resources'
PHONEGAP_ZIP_FILE ='phonegap_build.zip';

gulp.task('phonegap', function(cb){
runSequence('clean_phonegap' ,
'copy_www',
'copy_resources',
'copy_phonegap_config_xml',
'copy_default_icon',
'copy_default_splash',
'zip_phonegap',< br /> cb);
});

gulp.task('clean_phonegap', function(cb){
// clean our folder first
var phonegap_del_pattern = PHONEGAP_BUILD_FOLDER +'/*';
del([phonegap_del_pattern], {force: true}, cb);
})

gulp.task('copy_www', function (){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER
return gulp.src([IONIC_SOURCE_FOLDER +'/* *'])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder))
})

gulp.task(' copy_phonegap_config_xml', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER
return gulp.src(['config_phonegap.xml'])
.on('error', swallowError )
.pipe(rename('config.xml'))
.pipe(gulp.dest(target_phonegap_folder));
})

gulp.task( 'copy_resources', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER +'/resources',
exclude_pattern ='!' + IONIC_RESOURCE_FOLDER +'/_source_assets{,/**

// exclude pattern needs to go first. mother fucker.
return gulp.src([exclude_pattern, IONIC_RESOURCE_FOLDER +'/**'])
.on('error ', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})

gulp.task('copy_default _icon', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER +'/ios/icon.png' ])
.on ('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})

gulp.task('copy_default_splash', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER +'/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER +'/splash.png' ])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})


gulp.task('zip_phonegap', function(){
var sourcephonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER
return gulp.src(sourcephonegap_folder +'/**')
.pipe(zip('phonegap.zip'))
.on('error', swallowError )
.pipe(gulp.dest(PHONEGAP_BUILD_FOLDER));
})

Leave a Comment

Your email address will not be published.