美文网首页
2019-03-07 开发sdk坑持续汇总 和命令行汇总

2019-03-07 开发sdk坑持续汇总 和命令行汇总

作者: 惊蛰_e3ce | 来源:发表于2019-03-07 14:40 被阅读0次

    命令行:

    1:file 查看文件类型
    2 :lipo -info 查看文件支持架构 (如果报对应架构的符号表不存在可以用该命令查看是否支持)
    3:ar -x .../xx.a 导出符号表 (先cd到某个文件夹 在执行该命令 将符号表导到指定文件夹)
    4:nm WXLogUtil >WXLogUtil.m 将符号表转为.m 可以看到方法(nm命令参考https://blog.csdn.net/farmwang/article/details/72778026
    5:lipo libWeiboSDK.a -thin armv7 -output armv7.a 导出.a中的armv7架构
    6:nm -x 查看动态库中的信息
    7: pod lib lint QNJSDK.podspec -allow warnings --verbose 验证允许警告 显示详细log
    8:You can use the --no-clean option to inspect any issue.
    9:iosm:QNJSDK xjk$ pod lib lint QNJSDK.podspec --allow-warnings --verbose --no-clean 验证sdk是否通过 (允许警告 显示详情 生成工程)
    (QNJSDK did not pass validation, due to 20 errors. 可根据最后生成的这个定位错误位置)
    10:open ~/.cocoapods打repo在本地目录

    本地repo
    11:rm -rf .git 清理当前文件夹git信息
    12:cd existing_folder //进入到工程文件夹
    13:rm -rf .git //先清除.git文件
    14:git init //再重置
    15:git remote add origin xxxxxxxxx //链接到远程分支xxxxxxxxx(git上面的仓库地址)
    16:git add . //暂存所有文件
    17:commit之前设置下名字和邮箱 global为全局 local为本次
    18:git config --global user.name "瓜皮"
    19:git config --global user.email "guapi@yaomaitong.cn"
    20:git commit 需要输入注释说明
    21:git commit -m 'description'
    22:git push -u origin xxxx //最后push到xxxx分支
    pod 'xxx', :git => 'xxxx'

    使用仓库的其他分支:

    pod 'xxxx', :git => 'xxxxx' :branch => 'release'

    使用仓库的某个tag:

    pod 'xxx', :git => 'xxxxx', :tag => '0.0.1'

    或者指定一个提交记录:

    pod 'xxxxx', :git => 'xxxx', :commit => '554b292570bd8f0'

    23:pod 'QNJSDK',:subspecs => ['Face++ForQNJ', 'MoXieSDKForQNJ'],:git => 'https://gitee.com/heyuefengyun/QNJPodVersion.git', :tag => '1.2.0'
    指明要安装的subspecs git地址 版本号
    24:pod repo update更新
    pod cache clean --all
    rm -rf ~/Library/Caches/CocoaPods 清除缓存更新索引

    25:.gitignore只能忽略原来没有被跟踪的文件,因此跟踪过的文件是无法被忽略的。因此在网页上可以看到target等目录的存在。
    解决方法就是先把本地缓存删除(改变成未track状态),然后再提交: shift + command + . 可以快速隐藏显示隐藏文件

    git rm -r --cached .
    git add .
    git commit -m ‘update .gitignore’
    

    26:Failed to install the requested application(The application's CFBundleVersion is invalid.)

    27:MacBook-Pro:源码研究 $ xcrun -sdk iphoneos clang -arch arm64 -rewrite-objc -fobjc-arc -fobjc-runtime=ios-8.0.0 /Users/xxx/Desktop/objc-runtime-master/debug-objc/main.m -o main-arm64.cpp 输出支持arm64架构的main-arm64.cpp
    文件 支持arc ios系统号8.0.0

    28:xcrun dwarfdump --uuid /Users/miaoliujie/Library/Developer/Xcode/Archives/2020-06-12/JTZUser\ 2020-6-12,\ 11.16\ PM.xcarchive/dSYMs/酒兔子.app.dSYM
    查看dSYM的uuid
    29:find /Applications/Xcode.app -name symbolicatecrash -type f
    找到对应的symbolicatecrash
    ./symbolicatecrash ./.crash ./.app.dSYM > symbol.crash crash符号表
    如果报
    Error: "DEVELOPER_DIR" is not defined at /Users/miaoliujie/Desktop/未命名文件夹/symbolicatecrash line 69.
    export DEVELOPER_DIR=/Applications/XCode.app/Contents/Developer

    这种debug方式 表现不如预期 不能识别的方法显示不出来方法名 行号也没看出来 可能操作不对(UUID对上了)
    30: cd/open ~/.ssh vim podfile i编辑 esc退出编辑 wq保存退出 ctrl+c取消执行

    转自修复ios模拟器

    1.如果可以重置模拟器 首先试试重置模拟器

    2.如果不能重置,可以选择使用如下命令杀死模拟器服务:

    killall -9 com.apple.CoreSimulator.CoreSimulatorService  //杀死模拟器服务

    3.使用如下命令删除模拟器目录下是所有文件

    rm -rf ~/Library/Developer/CoreSimulator/Devices  //删除模拟器目录下是所有文件

    坑:

    1:podfile中的use_frameworks!和#use_frameworks!(也就是注释掉)
    use_frameworks!搜索了解了一下是把代码打包成动态库
    #use_frameworks! 注释掉是打包成静态库即.a文件
    文件类型不同
    以魔蝎SDK举例


    动态库.png
    静态库.png

    file命令行和lipo -info命令行输出结果

    首先是静态库:
    iosm:test xjk$ file  .../libMoxieSDK-iOS.a 
        ...libMoxieSDK-iOS.a: current ar archive random library
    iosm:test xjk$ lipo -info .../libMoxieSDK-iOS.a 
    Non-fat file: .../libMoxieSDK-iOS.a is architecture: x86_64
    ![静态库导出的符号表](https://img.haomeiwen.com/i6708463/0c9a3471a4b0ec99.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    ![静态库.m中的信息](https://img.haomeiwen.com/i6708463/a082f8fa1687d42d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    
    
    动态库
    iosm:test xjk$ lipo -info .../MoxieSDK_iOS.framework/MoxieSDK_iOS 
    Non-fat file: .../MoxieSDK_iOS.framework/MoxieSDK_iOS is architecture: x86_64
    iosm:test xjk$ file .../MoxieSDK_iOS.framework/MoxieSDK_iOS 
    .../MoxieSDK_iOS.framework/MoxieSDK_iOS: Mach-O 64-bit dynamically linked shared library x86_64
    动态库 ar -x 会报错
    ar -x .../MoxieSDK_iOS.framework/MoxieSDK_iOS 
    ar: .../MoxieSDK_iOS.framework/MoxieSDK_iOS: **Inappropriate file type or format**
    nm -x 
    ![nm命令导出的东西](https://img.haomeiwen.com/i6708463/923af293e22771ea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    
    
    
    两版魔蝎共存但是运行的时候不好说走的那一版

    重点是原版moxieSDK和pod中的sdk可以共存

    &#35第三方.a
      s.ios.vendored_libraries =
      #魔蝎
      'QNJSDK/Classes/ThirdPartySDK/MoxieSDK1.3.5/MoxieSDK/libMoxieSDK.a'
    

    pod中的魔蝎SDK是私仓中带的
    上面的.a是魔蝎原版SDK

    #
    # Be sure to run `pod lib lint QNJSDK.podspec' to ensure this is a
    # valid spec before submitting.
    #
    # Any lines starting with a # are optional, but their use is encouraged
    # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
    #
    
    Pod::Spec.new do |s|
      s.name             = 'QNJSDK'
      s.version          = '1.1.11'
      s.summary          = '去哪借sdk'
    
    # This description is used to generate tags and improve search results.
    #   * Think: What does it do? Why did you write it? What is the focus?
    #   * Try to keep it short, snappy and to the point.
    #   * Write the description between the DESC delimiters below.
    #   * Finally, don't worry about the indent, CocoaPods strips it!
    
      s.description      = <<-DESC
    测试sdk方法分类  和工程同名
    DESC
    
      s.homepage         = 'http://git.koudaikj.com/miaoliujie/QNJSDKAddress'
      # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
      s.license          = { :type => 'MIT', :file => 'LICENSE' }
      s.author           = { 'miaoliujie@xianjincard.com' => 'miaoliujie@xianjincard.com' }
      #s.source           = { :git => 'git@192.168.39.26:miaoliujie/QNJSDKAddress.git', :tag => s.version.to_s }
      #这样子方便本地package测试
      s.source           = { :git => 'git@192.168.39.26:miaoliujie/QNJSDKAddress.git', :tag => s.version.to_s }
    
      # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
    
      s.ios.deployment_target = '8.3'
    
    s.source_files = 'QNJSDK/Classes/**/*.{h,m,mm}'
      #系统的framework'
      s.frameworks = 'UIKit', 'MapKit','SystemConfiguration','Security','CoreTelephony','CFNetwork','CoreMotion','Foundation','CoreGraphics','CoreText','QuartzCore','Contacts','ContactsUI','AudioToolbox','CoreMedia','AVFoundation','MobileCoreServices','AdSupport','UserNotifications','JavaScriptCore','AssetsLibrary','EventKit','MessageUI'
      #系统的lib库 省略lib
      s.libraries = 'z','c++','sqlite3.0','iconv','resolv','icucore','resolv.9','sqlite3','xml2'
      
      #s.public_header_files = 'Pod/Classes/**/*.h'
      s.static_framework = true
      
      s.resource_bundles = {
          'QNJSDK' => [
          'QNJSDK/Assets/*.png',
          'QNJSDK/Assets/resources/*.png',
          'QNJSDK/Classes/Bundles/MGIDCardResource.bundle',
          'QNJSDK/Classes/Bundles/MGLivenessDetectionResource.bundle',
          ]
      }
    
      #资源包
      #数组形式添加第三方frameworks
      s.ios.vendored_frameworks = [
      #face++
      'QNJSDK/Classes/ThirdPartySDK/Face++/MGBaseKit.framework',
      'QNJSDK/Classes/ThirdPartySDK/Face++/MGIDCard.framework',
      'QNJSDK/Classes/ThirdPartySDK/Face++/MGLivenessDetection.framework',
      ]
      #第三方.a
      s.ios.vendored_libraries =
      #魔蝎
      'QNJSDK/Classes/ThirdPartySDK/MoxieSDK1.3.5/MoxieSDK/libMoxieSDK.a'
      
      # build setting的配置
      s.user_target_xcconfig =   {'OTHER_LDFLAGS' => [
          '-lObjC','-all_load','-ObjC'
          ],'ENABLE_BITCODE' => 'NO',
          'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES'
          
      }
      s.pod_target_xcconfig =   {'OTHER_LDFLAGS' => [
          '-lObjC','-all_load','-ObjC'
          ],'ENABLE_BITCODE' => 'NO'}
      #arc设置
      #s.requires_arc = true
      
      
      s.dependency 'AFNetworking', '~>3.1.0'
      s.dependency 'SDWebImage', '~> 3.8.2'
      s.dependency 'YYModel', '~> 1.0.4'
      s.dependency 'JRSwizzle'
      s.dependency 'ELCImagePickerController', '~> 0.2.0'
      s.dependency 'MBProgressHUD', '~> 1.1.0'
      s.dependency 'SpinKit', '~> 1.1'
    end
    

    如果不通过cocopods怎么解决耦合性

    制作实体framework时(场景:制作sdk给外部用 隐藏源码) 分用pods和不用pods
    不用pods有以下几种情况
    1:全原生.h .m肯定包含全部
    2:部分原生.h .m 部分.a 打出来也是全部

    用pods有以下几种情况
    1:不是私有库 原生的制作Static Library方法 导入pods 打出来只包含原生部分 不包含pods部分
    Pods部分单独成库

    pods部分单独成库

    2:私有库形式 Development Pods部分会被打入库 在podfile部分引入的pods不会打入库(不属于Development Pods) 在Development Pods中的s.dependency会被打入库

    但是组件化需求一般 不打出实体framework 因为频繁打包替换实体包很耗时 内部使用一般是私仓 而且能保证依赖的第三方比如AFNetworking版本一致(不能保证一致pod install会报错)

    组件化需要抽出公共部分

    相关文章

      网友评论

          本文标题:2019-03-07 开发sdk坑持续汇总 和命令行汇总

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