美文网首页阿里mpaas...
mPaaS接入实践-2020-12-31

mPaaS接入实践-2020-12-31

作者: 勇往直前888 | 来源:发表于2020-12-31 11:45 被阅读0次

    接手的是一个使用了mPaaSiOS项目;由于CocoaPods各种奇葩的问题,所以先剥离CocoaPods,当做没有这回事,先解决CocoaPods本身的问题。
    现在,时候加入mPaaS相关的内容了。阿里的文档做得还不错,有专门针对这种情况的介绍:
    基于已有工程且使用 CocoaPods 接入

    前置条件

    image.png image.png
    • 安装插件cocoapods-mPaaS,命令是:
      sh <(curl -s http://mpaas-ios.oss-cn-hangzhou.aliyuncs.com/cocoapods/installmPaaSCocoaPodsPlugin.sh)
      文档中有,说的很清楚。

    需要花点时间,不过很顺利,一次性成功。

    hello:~ zxs$ sh <(curl -s http://mpaas-ios.oss-cn-hangzhou.aliyuncs.com/cocoapods/installmPaaSCocoaPodsPlugin.sh)
    mPaaS installer
    ----------------------------------------
    * 欢迎使用 mPaaS Plugin for CocoaPods
    
    > 执行环境检测
    - 检查 CocoaPods
    - 检查 pod: 1.10.0
    > 开始下载
    最新版本为 0.9.5
    http://mpaas-ios.oss-cn-hangzhou.aliyuncs.com/cocoapods/mpaas-cocoapods-plugin-0.9.5.tgz
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   98k  100   98k    0     0  1080k      0 --:--:-- --:--:-- --:--:-- 1080k
    > 先卸载旧版本
    > sudo gem uninstall cocoapods-mPaaS -a
    
    Gem 'cocoapods-mPaaS' is not installed
    > 开始安装
    /Users/Shared/.mPaaSCocoaPodsPlugin/gems/cocoapods-mPaaS-0.9.5.gem
    > sudo gem install /Users/Shared/.mPaaSCocoaPodsPlugin/gems/cocoapods-mPaaS-0.9.
    Successfully installed cocoapods-mPaaS-0.9.5
    Parsing documentation for cocoapods-mPaaS-0.9.5
    Installing ri documentation for cocoapods-mPaaS-0.9.5
    Done installing documentation for cocoapods-mPaaS after 0 seconds
    1 gem installed
    > 安装结束
    - 清理临时文件..
    hello:~ zxs$ 
    

    接入

    • .config文件原来的工程中就有,这次不做修改;

    • 执行 pod mpaas init 命令,自动处理 Podfile文件,并添加plugin、source 以及 mPaaS_baseline配置。

    hello:mpaasapp_ios zxs$ pod mpaas init
    检查 config 文件是否存在 ...
    config file path : /Users/zxs/TempProject/mpaasapp_ios/meta.config
    检查处理 Podfile ...
    Podfile path: /Users/zxs/TempProject/mpaasapp_ios/Podfile
    Added "plugin in current Podfile, Done"
    plugin "cocoapods-mPaaS"
    Added "source in current Podfile, Done"
    source "https://code.aliyun.com/mpaas-public/podspecs.git"
    配置完成
    hello:mpaasapp_ios zxs$ 
    

    执行完之后Podfile被修改了:

    image.png
    • 指定基线,目前最新的是10.1.68

    • 添加mPaaS组件,也就是将原先注释掉的mPaaS_pod重新放开

    image.png
    • 执行pod install报错:
    image.png

    查看帮助网页,这两个mPaaS组件明明是有的,那怎么办呢?

    看到有升级基线的命令pod mpaas update 10.1.68,就执行了一下:

    hello:mpaasapp_ios zxs$ pod mpaas update 10.1.68
    1. update 10.1.68 baseline file ...
    updateTime : 2020-12-25 18:56:36 +0800
    MPBaseTest : new
    mPaaS_AMap : new
    mPaaS_APWebP : new
    mPaaS_ARTVC : new
    mPaaS_AliAccount : new
    mPaaS_AlipaySDK : new
    mPaaS_BadgeService : new
    mPaaS_CDP : new
    mPaaS_CommonUI : new
    mPaaS_Config : new
    mPaaS_DataCenter : new
    mPaaS_DevHelper : new
    mPaaS_Diagnosis : new
    mPaaS_Hotpatch : new
    mPaaS_LBS : new
    mPaaS_LocalLog : new
    mPaaS_Log : new
    mPaaS_Lottie : new
    mPaaS_MBProgressHud : new
    mPaaS_Masonry : new
    mPaaS_MobileFramework : new
    mPaaS_Multimedia : new
    mPaaS_Nebula : new
    mPaaS_NebulaDevHelper : new
    mPaaS_OCR : new
    mPaaS_OpenSSL : new
    mPaaS_Push : new
    mPaaS_RPC : new
    mPaaS_SDWebImage : new
    mPaaS_SafeKeyboard : new
    mPaaS_ScanCode : new
    mPaaS_Security : new
    mPaaS_Share : new
    mPaaS_Sync : new
    mPaaS_TTTAttributedLabel : new
    mPaaS_TinyApp : new
    mPaaS_TinyApp_Device : new
    mPaaS_TinyApp_Location : new
    mPaaS_TinyApp_Multimedia : new
    mPaaS_TinyApp_Scan : new
    mPaaS_UTDID : new
    mPaaS_UTDIDLib : new
    mPaaS_Upgrade : new
    mPaaS_dual : new
    mPaaS_dual_core : new
    The current verison is updated to 10.1.68.23
    Create directory '/Users/Shared/.mPaaSCocoaPodsPlugin/baseline/10.1.68'.
       update 10.1.68 baseline file Done
    
    2. update mPaaS repo ...
    Updating spec repo `mPaaS_iOS_specs`
      $ /usr/bin/git -C /Users/zxs/.cocoapods/repos/mPaaS_iOS_specs fetch origin
      --progress
      $ /usr/bin/git -C /Users/zxs/.cocoapods/repos/mPaaS_iOS_specs rev-parse
      --abbrev-ref HEAD
      master
      $ /usr/bin/git -C /Users/zxs/.cocoapods/repos/mPaaS_iOS_specs reset --hard
      origin/master
      HEAD is now at fafc841 PodSpec Update at 2020-12-28 18:36:23
       update mPaaS repo Done
    

    再执行一下pod install就成功了:

    hello:mpaasapp_ios zxs$ pod install
    --------------------------------mPaaS start--------------------------------------------
    检查 mPaaS repo 是否存在 ...
    repo name : mPaaS_iOS_specs
    --------------------------------mPaaS end----------------------------------------------
    Analyzing dependencies
    Downloading dependencies
    Generating Pods project
    Integrating client project
    --------------------------------mPaaS start--------------------------------------------
    plugin options : {}
    开始处理 industry
    meta.config file already exist in project, no need to add again
    yw_1222.jpg file already exist in project, no need to add again
    write info.plist ...
    write info.plist end (cost 0.181s)
    modules to pe process : ["APCommonUI", "MPPushSDK", "APMobileNetwork", "NebulamPaaSBiz", "NebulaAppManager", "AutoTracker", "NebulaSDK", "Nebula", "NebulaPoseidon", "MPNebulaAdapter", "NebulaLogging", "AMapFoundationKit", "APMobileLBS", "MPMasAdapter", "mPaas", "APMobileFramework", "APMap", "APConfig", "APLog", "MPMgsAdapter", "MPMssAdapter", "APRemoteLogging", "APLongLinkService", "TBScanSDK", "MAMapKit"]
    Add MPaaS framework headers to '/Users/zxs/TempProject/mpaasapp_ios/MPaaS/Targets/industry/industry-mPaaS-Headers.h'.
    Add category files if needed ...
    Add category files end (cost 0.045s)
    开始处理 industryTests
    industryTests has no mPaaS libs, no need to do add Category ..
    开始处理 industryUITests
    industryUITests has no mPaaS libs, no need to do add Category ..
    write 'mPaaS_version_code 23' in the Podfile
    The baseline 10.1.68.23 is the latest version ...
    (mPaaS cost 0.630s)
    --------------------------------mPaaS end----------------------------------------------
    Pod installation complete! There are 86 dependencies from the Podfile and 86 total pods installed.
    hello:mpaasapp_ios zxs$ 
    

    本地文件

    • 现在看Pods文件夹,多出了很多文件:
    image.png
    • 通过Xcode,也能看到多出了很多文件:
    image.png

    程序运行

    mPaaS和第三方库下载完成之后,工程就可以运行了:

    image.png

    小结

    整个过程还算比较顺利,mPaaS的内容还是很多的。期间遇到一个小问题,就是先要升级基线,才能执行pod install,不然的话mPaaS组件都是找不到的。

    相关文章

      网友评论

        本文标题:mPaaS接入实践-2020-12-31

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