ionic热更新插件问题与解决方案

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 16:41   11   0
cordova-hot-code-push-local-dev-addon插件有4个问题

一个是Generator类不能用,使用xcode自己的fix修复就可以了。

或者Update SocketIOClientConfiguration.swift 中的28行为

public typealias Generator = Array<SocketIOClientOption>.Iterator

二个是swift版本问题,在build setting里面修改swift language的版本为3.2

三个是将plugins目录中该插件的script/lib/swiftHelper.js中loadProjectFile函数改为

function loadProjectFile() {
  var platform_ios,
    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;
}

最后一个是unknown type name ‘SocketIOClient’ 问题

在Build Settins中查看Swift Compiler中生成的Objective-C Generated Interface Header Name 中的==MyApp-Swift.h==,把这个头文件的名字加到HCPLDPlugin.h中

#import <Cordova/CDVPlugin.h>
#import <Cordova/CDV.h>
#import "MyApp-Swift.h"

或者直接使用我的https://github.com/xiaoheng008/cordova-hot-code-push-local-dev-addon.git

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP