iOS使用CocoaPods安装OpenSSL出现错误解决方法
在项目中使用RSA加密,需要用到OpenSSL,在执行 Pod ‘OpenSSL’ 的时候 出现错误:
[!] /bin/bash -c
set -e
VERSION="1.0.2j"
SDKVERSION=xcrun --sdk iphoneos --show-sdk-version 2> /dev/null
MIN_SDK_VERSION_FLAG="-miphoneos-version-min=7.0"
BASEPATH="${PWD}"
CURRENTPATH="/tmp/openssl"
ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=xcode-select -print-path
mkdir -p "{CURRENTPATH}/bin"
cp "file.tgz" "{CURRENTPATH}"
tar -xzf file.tgz
cd "openssl-${VERSION}"
for ARCH in ${ARCHS}
do
CONFIGURE_FOR="iphoneos-cross"
if [ "{ARCH}" == "x86_64" ] ;
then
PLATFORM="iPhoneSimulator"
if [ "${ARCH}" == "x86_64" ] ;
then
CONFIGURE_FOR="darwin64-x86_64-cc"
fi
else
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
PLATFORM="iPhoneOS"
fi
export CROSS_TOP="{PLATFORM}.platform/Developer"
export CROSS_SDK="{SDKVERSION}.sdk"
echo "Building openssl-{PLATFORM} {ARCH}"
echo "Please stand by..."
export CC="{ARCH} {CURRENTPATH}/bin/{SDKVERSION}-{CURRENTPATH}/bin/{SDKVERSION}-{VERSION}.log"
LIPO_LIBSSL="{CURRENTPATH}/bin/{SDKVERSION}-{LIPO_LIBCRYPTO} {PLATFORM}{ARCH}.sdk/lib/libcrypto.a"
./Configure {CURRENTPATH}/bin/{SDKVERSION}-{LOG}" 2>&1
sed -ie "s!^CFLAG=!CFLAG=-isysroot {CROSS_SDK} !" "Makefile"
make >> "{LOG}" 2>&1
make clean >> "${LOG}" 2>&1
done
echo "Build library..."
rm -rf "{BASEPATH}/lib/"
lipo -create {BASEPATH}/lib/libssl.a"
lipo -create {BASEPATH}/lib/libcrypto.a"
echo "Copying headers..."
rm -rf "{BASEPATH}/opensslIncludes/"
cp -RL "{VERSION}/include/openssl" "${BASEPATH}/opensslIncludes/"
cd "${BASEPATH}"
echo "Building done."
echo "Cleaning up..."
rm -rf "${CURRENTPATH}"
echo "Done."
Building openssl-1.0.2h for iPhoneSimulator 9.2 i386
Please stand by…
解决方法:
第一种解决方法:替换你的openssl 使用OpenSSL-Universal pod 'OpenSSL-Universal'替换你原来的pod 'OpenSSL'
第二种方法:终端执行两面两个命令:
sudo gem uninstall cocoapods-downloader
sudo gem install cocoapods-downloader -v 1.2.0
第三种方法:rm -r ${TMPDIR}/openssl/
第四种方法(这种方法看个人情况): xcode -> preferences -> locations. 查看command line tools是否是空
然后执行pod install