Search code examples
xcodebashshellcocoapods

CocoaPod Prepare_command bash script


I am trying to use prepare_command of cocoapod I have a .sh file which I want to execute :

#!/bin/bash

XCODE_ROOT=`xcode-select -print-path`
ARCHS="i386 armv7 armv7s arm64"
SDK_VERSION="7.1"
STATIC_ARCHIVES=""
for ARCH in ${ARCHS}
do
    PLATFORM=""
    if [ "${ARCH}" == "i386" ]; then
        PLATFORM="iPhoneSimulator"
    else
        PLATFORM="iPhoneOS"
    fi
    export     

DEV_ROOT="${XCODE_ROOT}/Platforms/${PLATFORM}.platform/Developer"
export SDK_ROOT="${DEV_ROOT}/SDKs/${PLATFORM}${SDK_VERSION}.sdk"
export 

     TOOLCHAIN_ROOT="${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
export CC=clang
export CXX=clang++
export AR=${TOOLCHAIN_ROOT}libtool
export RANLIB=${TOOLCHAIN_ROOT}ranlib
export ARFLAGS="-static -o"
export LDFLAGS="-arch ${ARCH} -isysroot ${SDK_ROOT}"
export BUILD_PATH="BUILD_${ARCH}"
export CXXFLAGS="-x c++ -arch ${ARCH} -isysroot ${SDK_ROOT} -I${BUILD_PATH}"
mkdir -p ${BUILD_PATH}

make -f Makefile
mv *.o ${BUILD_PATH}
mv *.d ${BUILD_PATH}
mv libcryptopp.a ${BUILD_PATH}
STATIC_ARCHIVES="${STATIC_ARCHIVES} ${BUILD_PATH}/libcryptopp.a"
done
echo "Creating universal library..."
mkdir -p bin
lipo -create ${STATIC_ARCHIVES} -output bin/libcryptopp.a
echo "Build done!"

But this is giving me following errors on checking pod for linting:

 make: *** No rule to make target `*.o', needed by `libcryptopp.a'.  Stop.
  mv: rename CryptoppECC/CryptoppLibrary/*.o to  CryptoppECC/CryptoppLibrary/BUILD_x86_64/*.o: No such file or  directory.....

It clearly states that the

make -f Makefile

is not working which executes a 'MakeFile'

The prepare_command used is:

s.prepare_command= "sudo sh CryptoppECC/CryptoppLibrary/builder.sh"

Can anyone help me to tell what I am doing wrong here?


Solution

  • Finally , I got the problem solved. The problem was I was calling the script from another directory and the script was in other directory hence I just placed 1 statement on top of the script file

    cd  CryptoppECC/CryptoppLibrary/
    

    After that everything worked fine.