Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic-Firebase app Error: Cannot find module '../plugman/platforms/ios'

Getting the above error in my ionic app build after following the instructions on the following Authenticate Using OAuth Providers with Cordova.

After some searching on the web, I ended up at the following repo ionic-plugin-deeplinks.

Seems like it no longer being maintained. Does anyone else have this problem? Any solutions?

ionic info cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.2
Node       : v8.9.1
npm        : 5.5.1
OS         : macOS Sierra
Xcode      : Xcode 9.2 Build version 9C40b
like image 450
alphapilgrim Avatar asked May 13 '26 06:05

alphapilgrim


1 Answers

I'm currently having the same issue.

This is a bug in cordova-universal-links-plugin.

cordova-universal-links-plugin relies on a deprecated feature that has been removed in the new Cordova version. There is already a PR with a fix but it hasn't been merged yet.

UPDATE 26/Jan

GOTO following directories

  • YOUR-PROJECT-PATH/plugins/cordova-universal-links-plugin/hooks/lib/ios/
  • YOUR-PROJECT-PATH/node_modules/cordova-universal-links-plugin/hooks/lib/ios/

Then you'll see xcodePreferences.js file in the directory.

Modify xcodePreferences.js like below.

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) {
          // Then 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;
} 

Build error will remove. Credit to David @peterpeterparker

This is a quick fix solution, temporary use only.

like image 105
JeffMinsungKim Avatar answered May 15 '26 04:05

JeffMinsungKim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!