1.下载libiconv库文件
https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
2.编译脚本
(1)建立编译文件夹build
(2)编译脚本build_ios.sh
ROOT_DIR=/Users/hello/Desktop/libiconv-1.15/build
###################################################
# iOS SDK location.
###################################################
IOS_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
SIM_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/
export CC=${DEVROOT}/usr/bin/clang
export CXX=${DEVROOT}/usr/bin/clang++
export PATH=${DEVROOT}/usr/bin:$PATH
export MACOSX_DEPLOYMENT_TARGET=10.13
function build_ for ()
{
make clean
BUILD_FOR=$1
HOST=$2
if [ "$BUILD_FOR" == "x86_64" ] || [ "$BUILD_FOR" == "i386" ]
then
SDKROOT=$SIM_SDKROOT
else
SDKROOT=$IOS_SDKROOT
fi
###################################################
# Build $1 version,
###################################################
export ARCH_TARGET= "-arch ${BUILD_FOR} -isysroot $SDKROOT"
export CFLAGS= "${ARCH_TARGET} -g -O3 -fembed-bitcode -miphoneos-version-min=7.0"
export CXXFLAGS= "${CFLAGS} -std=c++11 -stdlib=libc++"
export LDFLAGS= "${ARCH_TARGET} -stdlib=libc++ -lc++ -lc++abi"
../../configure --prefix=${ROOT_DIR}/bin/${BUILD_FOR} \
--with-sysroot=$SDKROOT \
--enable-shared \
--disable-static \
--host=${HOST} || exit 1
make || exit 2
make install || exit 3
}
#build_for i386 i386-apple-darwin
#build_for x86_64 x86_64-apple-darwin
#build_for armv7 armv7-apple-darwin
#build_for armv7s armv7s-apple-darwin
build_ for arm64 arm-apple-darwin
(3)在真机上使用时,需要使用install_name_tool
install_name_tool -id 改变自身的链接位置
install_name_tool -change 改变依赖库链接位置
(4) 库文件下载地址
https://download.youkuaiyun.com/download/qiushanrenjia/10400652