iOS Pre-main Time Metric

How

【Edit Scheme】 - 【Run】 - 【Environment Variables】 增加 DYLD_PRINT_STATISTICS 环境变量

运行后Console输出如下Log

Total pre-main time: 1.2 seconds (100.0%)
         dylib loading time: 513.98 milliseconds (40.8%)
        rebase/binding time: 130.35 milliseconds (10.3%)
            ObjC setup time:  31.21 milliseconds (2.4%)
           initializer time: 583.33 milliseconds (46.3%)
           slowest intializers :
             libSystem.B.dylib :   2.95 milliseconds (0.2%)
          libglInterpose.dylib : 337.52 milliseconds (26.8%)
                  AFNetworking :  28.08 milliseconds (2.2%)
                        XXX : 234.54 milliseconds (18.6%)
  • dylib loading time:动态加载程序查找并读取应用程序使用的依赖动态库
  • rebase/binding time:修正调整镜像内的指针(rebase)和设置指向图像外符号的指针(binding)
  • ObjC setup time: Objective-C运行时需要进行设置类、类别和选择器注册
  • initializer time: 运行初始化程序

To Improve

static_library_target = ['AFNetworking', 'AliyunOSSiOS'];

post_install do |installer|
  
      pods_frameworks_path = "Pods/Target Support Files/Pods-XXX/Pods-XXX-frameworks.sh"
      
      if(File.exist?(pods_frameworks_path))
        pods_frameworks_content = File.read(pods_frameworks_path)
      end

      if static_library_target.include?(target.name)
        config.build_settings['MACH_O_TYPE'] = "staticlib"
        
        lib_path = "\"${BUILT_PRODUCTS_DIR}/#{target.name}/"
        lib_path = "install_framework #{lib_path}#{target.name}.framework\""
        pods_frameworks_content = pods_frameworks_content.gsub("#{lib_path}", "")
      end

  File.write(pods_frameworks_path, pods_frameworks_content)

end

Why

  • 为什么Podfile中指定的三方库为 dynamic library
    use_frameworks! tells CocoaPods that you want to use Frameworks instead of Static Libraries. Since Swift does not support Static Libraries you have to use frameworks.

你可能感兴趣的:(iOS Pre-main Time Metric)