Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

cordova 7.0.0 can't find module '../plugman/platforms/ios' #295

@abdohossam5

Description

@abdohossam5
Problem

after upgrading to cordova 7.0.0 building for ios fail giving this error
Error: can't find module '../plugman/platforms/ios'

Steps to reproduce
  1. npm install -g cordova
  2. cordova build ios
System info
  • Platform: iOS & Android
  • Platform version: android 6.1.0 / ios 4.4.0
  • Cordova version: 7.0.0
  • Node version: 6.6.0
Temporary solution

same issue was reported in another plugin and there was a solution proposed by @peterpeterparker. I applied it to '/plugins/cordova-hot-code-push-plugin/scripts/lib/iosWKWebViewEngineSupport.js' and it seems to be working now.

function loadProjectFile() {
  var platform_ios;
  var projectFile;

  try {
    // try pre-5.0 cordova structure
    platform_ios = context.requireCordovaModule('cordova-lib/src/plugman/platforms')['ios'];
    projectFile = platform_ios.parseProjectFile(iosPlatformPath);
  } catch (e) {
    try{
      // let's try cordova 5.0 structure
      platform_ios = context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios');
      projectFile = platform_ios.parseProjectFile(iosPlatformPath);
    } catch (e) {
      //try cordova 7.0
      var project_files = context.requireCordovaModule('glob').sync(path.join(iosPlatformPath, '*.xcodeproj', 'project.pbxproj'));

      if (project_files.length === 0) {
        throw new Error('does not appear to be an xcode project (no xcode project file)');
      }

      var pbxPath = project_files[0];

      var xcodeproj = context.requireCordovaModule('xcode').project(pbxPath);
      xcodeproj.parseSync();

      projectFile = {
        'xcode': xcodeproj,
        write: function () {
          var fs = context.requireCordovaModule('fs');

          var frameworks_file = path.join(iosPlatformPath, 'frameworks.json');
          var frameworks = {};
          try {
            frameworks = context.requireCordovaModule(frameworks_file);
          } catch (e) {
          }

          fs.writeFileSync(pbxPath, xcodeproj.writeSync());
          if (Object.keys(frameworks).length === 0) {
            // If there is no framework references remain in the project, just remove this file
            context.requireCordovaModule('shelljs').rm('-rf', frameworks_file);
            return;
          }
          fs.writeFileSync(frameworks_file, JSON.stringify(this.frameworks, null, 4));
        }
      };
    }

  }

  return projectFile;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions