美文网首页
flutter-科大讯飞AIUI-iOS端集成

flutter-科大讯飞AIUI-iOS端集成

作者: 存在即是美 | 来源:发表于2021-01-15 17:38 被阅读0次

    科大讯飞https://doc.iflyos.cn/aiui/sdk/mobile_doc/quick_start.html#demo

    参考文档

    https://blog.csdn.net/lv_ruanruan/article/details/80798327
    https://www.liuandy.cn/pod/2018/03/14/2330.html#.YAFRyS-1HX-
    https://www.jianshu.com/p/6e9293fd0745

    需要具备知识

    flutter : 工程创建 , 插件与原生正逆向通道建立
    iOS : swift或者oc基础 , 私有库配置

    集成过程遇到的问题

    集成过程按照官方文档可以很轻松的崽iOS原生实现出来 , 但是如果想过度到flutter上就需要一些注意 , 我在下方记录下我自己遇到的问题 .

    1.第三方和系统自带的framework分别怎么添加到私有库中

    a . 首先在我标识的路径下创建出一个frameworks文件夹(名字可以自己定义 , 只要之后路径能保持一致就好) . 然后将iflyAIUI.framework放入frameworks文件夹 .


    截屏2021-01-15 下午4.42.38.png

    b.然后打开dt_aiui_plugin.podspec , 在里面添加
    s.vendored_frameworks = "**/iflyAIUI.framework"

    c.然后继续添加系统自带的 framework :
    s.frameworks = "CoreLocation","CoreTelephony","AVFoundation","AddressBook","AudioToolbox","Contacts","SystemConfiguration","QuartzCore","UIKit","Foundation","CoreGraphics"

    2.系统自带的lib怎么添加到私有库中

    就以我们应该添加的三个lib举例
    s.libraries = "c++", "icucore", "z"

    3.怎么添加资源文件 , 并加载出来

    分别讲述aiui.cfg和meta_vad_16k.jet , 两个问价加载方式不一样 , meta_vad_16k.jet的路径我们控制不了 , 所以比较坑

    3.1 aiui.cfg

    a.创建resource文件夹 , 放在与framework同级处
    b.将aiui.cfg文件放入resource中
    c.在dt_aiui_plugin.podspec中添加路径
    s.resources = "resource/*"
    d.在代码处修改bundle的加载方法
    NSString *cfgFilePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"aiui" ofType:@"cfg"];

    3.2 meta_vad_16k.jet

    a.直接将meta_vad_16k.jet拖入到主工程中 , 目前找不到科大讯飞在哪里加载meta_vad_16k.jet的 , 只能找到路径 , 我猜测是在封装方法的内部调用bundle的加载 , 这个导致一个问题 , 如果我像aiui.cfg一样去存放文件 , 会加载不到资源 , 所以只能每次引用这个插件都在主工程中放入一次 .

    最后我的podspec文件如下:

    # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
    # Run `pod lib lint dt_aiui_plugin.podspec' to validate before publishing.
    #
    Pod::Spec.new do |s|
      s.name             = 'dt_aiui_plugin'
      s.version          = '0.0.1'
      s.summary          = 'A new flutter plugin project.'
      s.description      = <<-DESC
    A new flutter plugin project.
                           DESC
      s.homepage         = 'http://example.com'
      s.license          = { :file => '../LICENSE' }
      s.author           = { 'Your Company' => 'email@example.com' }
      s.source           = { :path => '.' }
    
    #  s.vendored_frameworks = "frameworks/iflyAIUI.framework"
      s.vendored_frameworks = "**/iflyAIUI.framework"
    
      s.frameworks = "CoreLocation","CoreTelephony","AVFoundation","AddressBook","AudioToolbox","Contacts","SystemConfiguration","QuartzCore","UIKit","Foundation","CoreGraphics"
    
      s.source_files = 'Classes/**/*'
      s.dependency 'Flutter'
      s.library = "z"
      
      s.libraries = "c++", "icucore", "z"
    
      s.resources = "resource/*"
    
      s.platform = :ios, '9.0'
    
      # Flutter.framework does not contain a i386 slice.
      s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
    end``` 
    
    
    
    
    

    相关文章

      网友评论

          本文标题:flutter-科大讯飞AIUI-iOS端集成

          本文链接:https://www.haomeiwen.com/subject/wzlwaktx.html