Jeremy
Jeremy

Reputation: 11

Cordova Build not updating index.html in ios platform directory

I am using:

Cordova 5.3.3

Xcode 6.2

Working on the Cordova Tutorial: https://ccoenraets.github.io/cordova-tutorial/

modifying the the index.html running cordova build ios the www directory was not updated in the ios platform directory.

cordova prepare and cordova prepare ios are also not updating the www dir for ios when I update files in the root directory.

I searched and found this solution:

22231767

which references

Find the file called copy-www-build-step.sh. Mine was in [project_folder]/platforms/ios/cordova/lib/copy-www-build-step.sh

However, in my installation I have a javascript file, not a shell script - version perhaps

[project_folder]/platforms/ios/cordova/lib/copy-www-build-step.js

and in that file:

var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR,
    FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME,
    COPY_HIDDEN = process.env.COPY_HIDDEN,
    PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;

var path = require('path'),
    fs = require('fs'),
    shell = require('shelljs'),
    glob = require('glob'),
    srcDir = 'www',
    dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME),
    dstWwwDir = path.join(dstDir, 'www');

if(!BUILT_PRODUCTS_DIR) {
    console.error('The script is meant to be run as an Xcode build step and relies on env variables set by Xcode.');
    process.exit(1);
}

try {
    fs.statSync(srcDir);
} catch (e) {
    console.error('Path does not exist: ' + srcDir);
    process.exit(1);
}

// Code signing files must be removed or else there are
// resource signing errors.
shell.rm('-rf', dstWwwDir);
shell.rm('-rf', path.join(dstDir, '_CodeSignature'));
shell.rm('-rf', path.join(dstDir, 'PkgInfo'));
shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));

// Copy www dir recursively
if(!!COPY_HIDDEN) {
    shell.mkdir('-p', dstWwwDir);
    shell.cp('-r', glob.sync(srcDir + '/**', { dot: true }), dstWwwDir);
} else {
    shell.cp('-r', srcDir, dstDir);
}

// Copy the config.xml file.
shell.cp('-f', path.join(path.dirname(PROJECT_FILE_PATH), path.basename(PROJECT_FILE_PATH, '.xcodeproj'), 'config.xml'),
    dstDir);

So it looks like shell.cp('-r', srcDir, dstDir); should be doing the copy work here. However the copy is not working in my instance.

Upvotes: 0

Views: 1630

Answers (2)

Jeremy
Jeremy

Reputation: 11

as jcesarmobile stated there were issues with Cordova 5.3.3 and Node 5.0.0.

as I installed node with homebrew my fix was

brew tap homebrew/versions
brew unlink node
brew uninstall node
brew search node (gives the list of available version)
brew install homebrew/versions/node4-lts

At this point the ios build was successful, but also as jcesarmobile pointed out Cordova 5.4.0 has been released addressing this issue.

Upvotes: 0

JohnHanks
JohnHanks

Reputation: 143

You know what...not the answer you are hoping for, but I have noticed the same thing with the phonegap build service. Sometimes I just have to run the build command more than once.

Maybe you have a file that the current build user is not allowed to write because perhaps an admin owns it. Best of luck to you

Upvotes: 0

Related Questions