didi / Hummer

一套移动端高性能高可用的动态化跨端开发框架
https://hummer.didi.cn/
Apache License 2.0
1.34k stars 179 forks source link

上架App Store或Testflight下载的app,会出现渲染失败;AdHoc或编译运行可以正常渲染 #392

Closed SoonKong closed 2 years ago

SoonKong commented 2 years ago

描述

项目采用的是swift,采用Pod接入Hummer后,上架App Store或Testflight下载的app,会出现渲染失败,报错:

Error Domain=HMJSContextErrorDomain Code=1000 "Hummer.render() function is not called" UserInfo={NSLocalizedDescription=Hummer.render() function is not called}

但导出AdHoc或编译运行是可以正常渲染;采用release编译运行也可以正常

Hummer version:

0.2.8

复现步骤

1、前端代码:通过 hummer init 创建 ts 项目 2、iOS项目代码:Xcode创建最简单的干净项目(采用Swift语言), 3、Pod 接入 hummer

pod 'Hummer', :git => 'https://github.com/didi/Hummer.git', :branch => 'master', :subspecs => ["Hermes", "OSSYoga"]

4、部署前端 hummer 服务 5、编译运行iOS项目,可以正常打开hummer页面 6、打包后上传(不需要提审) 7、缓存更新后,通过Testflight下载 8、运行app,打开Hummer的页面,出现渲染失败

SoonKong commented 2 years ago

花了3天时间,通过写日志,不断提包测试;发现问题在于采用动态库加载。

由于项目采用swift语言,其他引用到部分第三方库需要使用动态库,所以pod定义打包生成动态库

image


从而导致打包生成动态库,app store下载的应用和普通编译运行的包,在加载动态库可能存在策略上不同导致的

HM_EXPORT_CLASS_METHOD(render, render:)

应该是这个没有被真正export


如果你在提审打包时,发现打包的动态库中,有Hummer(如下:)

image


解决办法:强制Hummer生成静态库

$static_framework = ['Hummer', 'SocketRocket', 'Yoga']

  pre_install do |installer|
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
      installer.pod_targets.each do |pod|
          if $static_framework.include?(pod.name)
            def pod.build_type;
            Pod::BuildType.static_framework
            end
          end
        end
    end
SoonKong commented 2 years ago

问题自己解决了,关闭

bbssyyuui commented 2 years ago

收到,我们后续也看下这个