首页 > 解决方案 > 如何在离子电容器项目上安装插件 cordova-plugin-iosrtc

问题描述

我正在尝试使用 getUserMedia 来获取相机的流。据我了解,这是不可能的,因为此功能尚未在 ios 14.4 中实现或至少未授权。(不允许错误)

所以我看到获取流的唯一方法是使用下面的这个cordova插件: https ://github.com/cordova-rtc/cordova-plugin-iosrtc

我的问题是当我安装它时:npm i cordova-plugin-iosrtc

在 ios 上构建时出现错误:

如果有人设法安装它,那将是很好的帮助我。谢谢你。

⚠️ ld:找不到或使用自动链接框架“WebRTC”

❌ 架构 arm64 的未定义符号

符号:OBJC_CLASS $_RTCMediaConstraints 引用自:PluginRTCPeerConnectionConstraints.o 中的 objc-class-ref

❌ ld:未找到架构 arm64 的符号

如果有人成功安装它,我会很高兴帮助我。谢谢你。

标签: cordovaionic-frameworkcapacitorwebrtc-ios

解决方案


最后我找到了解决方案。iosrtc 插件在您的 podfile 中与电容器一起使用:

def disable_bitcode_for_target(target)
  target.build_configurations.each do |config|
    config.build_settings['ENABLE_BITCODE'] = 'NO'

    remove_cflags_matching(config.build_settings, ['-fembed-bitcode', '-fembed-bitcode-marker'])
  end
end

def remove_cflags_matching(build_settings, cflags)
  existing_cflags = build_settings['OTHER_CFLAGS']

  removed_cflags = []
  if !existing_cflags.nil?
    cflags.each do |cflag|
      existing_cflags.delete_if { |existing_cflag| existing_cflag == cflag && removed_cflags << cflag }
    end
  end

  if removed_cflags.length > 0
    build_settings['OTHER_CFLAGS'] = existing_cflags
  end
end



post_install do |installer|
  project_name = Dir.glob("*.xcodeproj").first
  project = Xcodeproj::Project.open(project_name)
  project.targets.each do |target|
    disable_bitcode_for_target(target)
  end
  project.save

  installer.pods_project.targets.each do |target|
    disable_bitcode_for_target(target)
  end

  installer.pods_project.save
end

如果这可以帮助某人:)


推荐阅读