iOS安装包瘦身总结
使用lipo工具拆分单架构
lipo "originalExecutable" -thin arm64 -output "arm64Executable"
使用assetutil工具拆分不同倍图的asset
xcrun --sdk iphoneos assetutil --scale 3 --output "$targetFolder/Assets3.car" "$sourceFolder/Assets.car"
// Pods-targetName-resource.sh
install_resource "${PODS_ROOT}/APodName/APodName.framework/APodName.bundle"
install_resource "${PODS_ROOT}/BPodName/BPodName.framework/BPodName.xcassets"
install_resource "${PODS_ROOT}/BPodName/BPodName.framework/xxx.png"
targetPicture=".imageset"
function searchOneDir(){
cd $1
path=`pwd`
for item in `ls`; do
if [[ -d "${path}/${item}" ]] && [[ ! "${filterList[@]}" =~ "${item}" ]]
then
if [[ "${item}" =~ "${targetPicture}" ]]
then
echo "${path}/${item}"
echo "内部:$item"
itemSub="${path}/${item}"
appContainPictureList+=(${itemSub})
else
if [[ -d ${item} ]]
then
searchOneDir "$item"
fi
fi
fi
done
cd ..
path=`pwd`
echo "path2: $path" return 0;
}
targetAssetDir=".xcassets"
targetPicture=".imageset" appContainPictureList=()
UnUsedPictureList=()
UsedPictureList=()
function checkMachOFile() {
res=`strings $1` for assertName in ${appContainPictureList[@]}; do
if [[ ! "$res" =~ "$assertName" ]]
echo "$assertName"
then
UnUsedPictureList[${#UnUsedPictureList[*]}]=$assertName
else
UsedPictureList[${#UsedPictureList[*]}]=$assertName
fi
done
}
主工程Release
Optimization Level :-Oz
Framework工程
Optimization Level :-Oz
主工程Release
Deployment Postprocessing :YES
Strip Linked Product :YES
Strip Style :All Symbols(剥离所有符号表和重定向信息) Framework工程
Deployment Postprocessing :YES
Strip Linked Product :YES
Strip Style :Non-Global Symbols(剥离包括调试信息等非全局的符号,保留外部符号)
主工程Release
Symbols Hidden by Default :Yes
Framework工程 静态库/动态库
Symbols Hidden by Default :NO
主工程
Dead Code Stripping :Yes
主工程
Asset Catalog Compiler->Optimization设置为space
动态库工程:
1设置当遇到未定义的函数时,动态查找APP主二进制符号表。
2 关闭bitcode
Other Linker Flags -> -undefined dynamic_lookup
Enable Bitcode -> No
3导出动态库需要调用的外部符号,写到一个文件exported_symbols内
nm -u xxx.framework/xxx > exported_symbols.txt
APP工程:
1配置需要导出exported_symbols文件内的所有符号,避免编译时动态库需要用到的符号被strip掉。
2关闭bitcode。
// exported_symbols.txt是需要被导出的符号文件路径
EXPORTED_SYMBOLS_FILE -> exported_symbols.txt
Enable Bitcode -> No
__attribute__((visibility("default"))) void MyFunction1() {}
__attribute__((visibility("default"))) void MyFunction2() {}
// objc-class.mm
Class class_initialize(Class cls, id inst) {
if (!cls->isInitialized()) {
initializeNonMetaClass (_class_getNonMetaClass(cls, inst));
}
return cls;
} // objc-runtime.h
#define RW_INITIALIZED (1<<29)
bool isInitialized() {
return getMeta()->data()->flags & RW_INITIALIZED;
}
otool -v -s __DATA __objc_classrefs xxxMainClient #读取__DATA Segment中section为__objc_classrefs的符号
otool -v -s __DATA __objc_classlist xxxMainClient #读取__DATA Segment中section为__objc_classlist的符号
nm -nm xxxMainClient
iOS安装包瘦身总结的更多相关文章
- iOS安装包瘦身的那些事儿
在我们提交安装包到App Store的时候,如果安装包过大,有可能会收到类似如下内容的一封邮件: 收到这封邮件的时候,意味着安装包在App Store上下载的时候,有的设备下载的安装包大小会超过100 ...
- iOS 安装包瘦身(下篇)
本文来自网易云社区 作者:饶梦云 2.4. 清理无用代码 2.4.1. Dead Code Stripping Activating this setting causes the -dead_str ...
- iOS 安装包瘦身 (上篇)
本文来自网易云社区 作者:饶梦云 1. 安装包组成 谈到 App 瘦身,最直接的想法莫过于分析一个安装包内部结构,了解其每一部分的来源.解压一个 ipa 包,拿到其 payload 中 app 文件的 ...
- Android APK安装包瘦身[转]
很显然,APK安装包越小越好.下面从代码,资源文件,使用策略几个方面简要介绍下: 代码 保持良好的编程习惯,不要重复或者不用的代码,谨慎添加libs,移除使用不到的libs. 使用proguard混淆 ...
- Android App安装包瘦身计划
Android App安装包瘦身计划 Android App安装包体积优化: 理由, 指标和可以采用的方法. 本文内容归纳如下图: 为什么要安装包瘦身 安装包需要瘦身吗? 不需要吗? 安装包要瘦身的主 ...
- iOS ipa包瘦身,iOS8及以下text段超60MB
前沿 很早之前写过一篇相关文章,不过博客主机上跑路了之后数据没了,凭着记忆补了下相关资料 ipa安装包瘦身 清理无用图片,图片压缩(PNG换WebP和JPG),处于某种不可抗拒的原因,导致有部分3X图 ...
- iOS开发——程序员必备&iOS安装包的三种格式 deb、ipa 和 pxl的解释和说明
iOS安装包的三种格式 deb.ipa 和 pxl的解释和说明 目前 iOS 平台上常见的安装包有三种,deb.ipa 和 pxl.转自链接:http://fanlb.blogbus.com/logs ...
- 如何减小ios安装包大小
以前的老文章了,搬到cnblog 更小的安装包意味着更快的下载安装速度,也往往意味着更快的加载运行速度,是优化ios应用的一个重要方面,本文主要参考<减小iOS应用程序的大小>,在实际测试 ...
- iOS - Bitcode App 瘦身中间码
1.Bitcode 随着 Xcode7 的发布,Apple 提供了一项新的技术来支持 App 瘦身功能,那就是 Bitcode. 1.BitCode 是什么 Bitcode is an interme ...
- 在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤
Xamarin 配置手册和离线包下载 http://pan.baidu.com/s/1eQ3qw8a 具体操作: 安装前提条件 1. 安装Visual Studio 2013,安装过程省略,我这里安装 ...
随机推荐
- Codeforce:208A. Dubstep (字符串处理,正则表达式)
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performanc ...
- Codeforces Round #710 (Div. 3)个人简单题解
补题链接:Here Proble-A. Strange Table 根据 x 确定坐标确定的行数和列数. int main() { ios_base::sync_with_stdio(false), ...
- Android NativeCrash 捕获与解析
Android 开发中,NE一直是不可忽略却又异常难解的一个问题,原因是这里面涉及到了跨端开发和分析,需要同时熟悉 Java,C&C++,并且需要熟悉 NDK开发,并且解决起来不像 Java异 ...
- 2、springboot创建多模块工程
系列导航 springBoot项目打jar包 1.springboot工程新建(单模块) 2.springboot创建多模块工程 3.springboot连接数据库 4.SpringBoot连接数据库 ...
- jdk与tomcat的安装部署(CentOS8)(VM)
一.登陆CentOS8 通过VMware Workstation登陆CentOS8系统 二.VMware Tools安装 1.找到VMware Tools对应文件: VMwareTools-10. ...
- 基于jquery开发的Windows 12网页版
预览 https://win12.gitapp.cn 首页代码 <!DOCTYPE html> <html lang="en"> <head> ...
- java - 运行可执行文件 (.exe)
package filerun; import java.io.File; import java.io.IOException; public class RunExe { public stati ...
- Laravel - 使用 DB facade 实现CURD
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades ...
- [转帖]History of Unicode Release and Publication Dates
www.unicode.org For ease of reference, this page collects together information about the dates for v ...
- [转帖]通过配置优化KingbaseES服务器性能
目录 1. 概述 2. 数据库应用类型 3. 服务器参数 3.1. max_connections 3.2. shared_buffers 3.3. effective_cache_size 3.4. ...