tobefuturer/app2dylib

not a position-independent executable, can't convert to dylib.

magicalccong opened this issue · 3 comments

请问一下我出现了这个错误要怎么解决,文件取的是xx.app包里的二进制文件

app2dylib supports armv7 and arm64 archtecture, but not support fat file. Please use lipo to thin the image file first. 不好意思,这个才对

需要瘦身 二进制文件。
比如瘦身armv7 设备。就用如下命令,还有arm64等
lipo -thin armv7 XXAPP -output XXAPP.armv7

我写了个脚本转换

#!/bin/sh

src="$1"
dst="$2"
shift 2

if [ ! -f "$src" ]; then
	echo "usage: app2dylib.sh <src> <dst> [armv7 armv7s arm64 i386 x86_64]"
	exit
fi

if [ '' = "$1" ]; then
	"$0" "$src" "$dst" armv7 armv7s arm64 i386 x86_64
	exit
fi

param="lipo -create -o '$dst'"
for a in "$@"; do
	lipo -thin "$a" "$src" -o "$src.$a" 2>/dev/null
	[ -f "$src.$a" ] && app2dylib "$src.$a" -o "$src.$a.dylib"
	[ -f "$src.$a.dylib" ] && param="${param} '$src.$a.dylib'"
done

eval "$param"

for a in "$@"; do
	rm -f "$src.$a"
	rm -f "$src.$a.dylib"
done

lipo -info "$dst"

exit

使用方法: app2dylib.sh <源文件> <目标文件> <要转换的架构列表>

例如: app2dylib.sh /tmp/1.exe /tmp/1.dylib arm64 armv7