I would like to compile libical and add it to my Xcode project.
I have read the README file and run the following commands in Terminal.app:
./configure
and
./configure --prefix=/proj/local/
Am I supposed to get compiled .a files somewhere that I can drag and drop into my project?
I am the person who originally created those build scripts located here...
http://code.google.com/p/mwiphonesdk/source/browse/trunk/iMADE/PrepTasks/05+Event+Calendar/Packers+Schedule/libical/build+scripts/
I have now updated the scripts to work with the latest iOS 6/Xcode 4.5 toolset. It is quite different and I have set it to use Clang. I did what I could to make this script adapt to new SDK releases.
http://www.smallsharptools.com/downloads/libical/
The scripts should be placed in the root of the libical folder and run from there. The main script runs the other 2 scripts to build the armv7 and armv7s binaries and then uses xcrun to run lipo for iphoneos to combine these binaries into a fat binary which can be used for an iOS project.
There are some refactorings which could easily be done but I have already spent a ton of time on it already. I hope this helps you make use of the library.
#!/bin/sh
# SEE: http://www.smallsharptools.com/downloads/libical/
PATH="`xcode-select -print-path`/usr/bin:/usr/bin:/bin"
# set the prefix
PREFIX=${HOME}/Library/libical
OUTPUTDIR=../libical-build
export ARCH=armv7
# Select the desired iPhone SDK
export SDKVER="6.0"
export DEVROOT=`xcode-select --print-path`
export SDKROOT=$DEVROOT/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk
export IOSROOT=$DEVROOT/Platforms/iPhoneOS.platform
# Includes
# find $DEVROOT -type d -name include|grep -i iphone|grep -i arm-apple-darwin|grep -vi install-tools|grep -vi simulator
# $SDKROOT/usr/include
# $DEVROOT/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/include
if [ ! -d $DEVROOT ]
then
echo "Developer Root not found! - $DEVROOT"
exit
fi
echo "DEVROOT = $DEVROOT"
if [ ! -d $SDKROOT ]
then
echo "SDK Root not found! - $SDKROOT"
exit
fi
echo "SDKROOT = $SDKROOT"
if [ ! -d $IOSROOT ]
then
echo "iOS Root not found! - $IOSROOT"
exit
fi
echo "IOSROOT = $IOSROOT"
# finding ld
# find $DEVROOT -type f -name ld|grep -i iphone
# Set up relevant environment variables
export CPPFLAGS="-arch $ARCH -I$SDKROOT/usr/include -I$IOSROOT/Developer/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/include"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ -arch $ARCH"
export CLANG=$DEVROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
#export CC=$IOSROOT/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
#export CXX=$IOSROOT/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2
export CC=$CLANG
export CXX=$CLANG
export LD=$IOSROOT/Developer/usr/bin/ld
export AR=$IOSROOT/Developer/usr/bin/ar
export AS=$IOSROOT/Developer/usr/bin/as
export LIBTOOL=$IOSROOT/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool
export STRIP=$IOSROOT/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip
export RANLIB=$IOSROOT/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib
HOST=arm-apple-darwin10
if [ ! -f $CC ]
then
echo "C Compiler not found! - $CC"
exit
fi
if [ ! -f $CXX ]
then
echo "C++ Compiler not found! - $CXX"
exit
fi
if [ ! -f $LD ]
then
echo "Linker not found! - $LD"
exit
fi
if [ -d $OUTPUTDIR/$ARCH ]
then
rm -rf $OUTPUTDIR/$ARCH
fi
find . -name \*.a -exec rm {} \;
make clean
./configure --prefix=$PREFIX --disable-dependency-tracking --host $HOST CXX=$CXX CC=$CC LD=$LD AR=$AR AS=$AS LIBTOOL=$LIBTOOL STRIP=$STRIP RANLIB=$RANLIB
make -j4
# copy the files to the arch folder
mkdir -p $OUTPUTDIR
mkdir -p $OUTPUTDIR/$ARCH
cp `find . -name \*.a` $OUTPUTDIR/$ARCH/
xcrun -sdk iphoneos lipo -info $OUTPUTDIR/$ARCH/*.a
echo $ARCH DONE
echo "See $OUTPUTDIR"
What you do is compile your libraries for both simulator and phone.
1.Make 2 new targets one for iphone one for simulator
2.compile
3.Take them and combine them with lipo.
This link will give you all the specific details.
How to make universal static libraries
Other answers to this question aren't helpful for specifically libical, because its configure script is finicky. You need to have a ton of environment variables right. These scripts have figured all them out for libical.
http://code.google.com/p/mwiphonesdk/source/browse/trunk/iMADE/PrepTasks/05+Event+Calendar/Packers+Schedule/libical/build+scripts/
Download the above scripts, and tweak the build_(platform).sh to find the right compilers and SDK folders. This will change depending on what you are targeting and how recent your Xcode developer tools are. Finding the right values should be pretty easy, just look in the same locations for what they are called on your system.
The output will be a fat ".a" files with binaries for the simulator and device.
In the case these files disappear, I've collected the truly important one (build_arm.sh, the cross-compile) below:
#!/bin/sh
# Created by Robert Carlsen on 15.07.2009.
# build an arm / i386 / x64 lib of standard linux project
#
# adopted from: http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html
#
# copied from: http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
#
# configured for libical
#
# Note:
# To run with the iPhone the assembly just be a Universal binary (FAT) with i386 arch for the simulator
# and arm arch for the iPhone hardware which has the arm processor.
# set the prefix
PREFIX=${HOME}/Library/libical
OUTPUTDIR=../libical-build
export ARCH=armv6
export GCCARCH=arm-apple-darwin9
export GCCVERSION=4.2.1
# Select the desired iPhone SDK
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.1.2.sdk
if [ ! -d $DEVROOT ]
then
echo "Developer Root not found! - $DEVROOT"
exit
fi
echo "DEVROOT = $DEVROOT"
if [ ! -d $SDKROOT ]
then
echo "SDK Root not found! - $SDKROOT"
exit
fi
echo "SDKROOT = $SDKROOT"
# Set up relevant environment variables
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/$GCCARCH/$GCCVERSION/include/ -I$SDKROOT/usr/include/"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ "
CC=$DEVROOT/usr/bin/$GCCARCH-gcc-$GCCVERSION
CXX=$DEVROOT/usr/bin/$GCCARCH-g++-$GCCVERSION
HOST=arm-apple-darwin
if [ ! -f $CC ]
then
echo "C Compiler not found! - $CC"
exit
fi
if [ ! -f $CXX ]
then
echo "C++ Compiler not found! - $CXX"
exit
fi
# TODO: add custom flags as necessary for package
./configure --prefix=$PREFIX --disable-dependency-tracking CXX=$CXX CC=$CC LD=$DEVROOT/usr/bin/ld --host=$HOST
make -j4
# copy the files to the arch folder
mkdir -p $OUTPUTDIR
mkdir -p $OUTPUTDIR/$ARCH
cp `find . -name \*.a` $OUTPUTDIR/$ARCH/
lipo -info $OUTPUTDIR/$ARCH/*.a
echo $ARCH DONE
echo "See $OUTPUTDIR"
This question came up already a year ago, and it was solved. See Help on installing a library like libical into Xcode with hints for cross-compile and further link.
Related
I'm developing a pdf viewer app and I'm using MuPdf library cocoapods. I created a new project, added a pod file and ran pod install. Following error occurred. Any help is appreciated to fix this. I have set automatically manage signing in the project.
Analyzing dependencies
Downloading dependencies
Installing MuPDF (1.10)
[!] /bin/bash -c
set -e
cd platform/ios
# release armv7 + arm64
xcodebuild -scheme MuPDF -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
# debug 64bit sim
xcodebuild -scheme MuPDF -configuration Release -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
cd ../../build/
for i in mupdf mupdfthird; do
LIB=lib${i}.a
lipo -create -output $LIB release-ios-i386-x86_64/$LIB release-ios-armv7-arm64/$LIB
done
# rename to avoid any conflict with the libmupdf.a that the pod generates
mv libmupdf.a libmupdfcore.a
# copy iOS headers into the general include directory, as
# cocoapods 1.0 insists that all headers are under the
# header_mappings_dir location
cd ..
cp platform/ios/Classes/*.h platform/ios/common.h include/mupdf/
cd platform/ios
# now fix the imports/includes to be mupdf/foo.h instead of foo.h
find . -name '*.[mh]' -print0 | xargs -0 perl -pi -e 's,#import "Mu,#import "mupdf/Mu,'
find . -name '*.[mh]' -print0 | xargs -0 perl -pi -e 's,#include "common.h",#include "mupdf/common.h",'
find . -name '*.[mh]' -print0 | xargs -0 perl -pi -e 's,#import "common.h",#import "mupdf/common.h",'
# the reference to memory.h in memento.h upsets xcode when
# building a module (fixed upstream for version after 1.9)
cd ../..
find . -name 'memento.h' -print0 | xargs -0 perl -pi -e 's,#include <memory.h>,#include <stdlib.h>,'
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -scheme MuPDF -configuration Release CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO
Build settings from command line:
CODE_SIGN_IDENTITY =
CODE_SIGNING_REQUIRED = NO
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
error: An empty identity is not valid when signing a binary for the product type 'Application'. (in target 'MuPDF' from project 'MuPDF')
** BUILD FAILED **
I want to setup the ct-ng for my gui application and now I want to use wxwidgets.
For setting up the crosstool, I have used:
# Install prerequisites:
apt-get -y install gcc gperf bison flex gawk libtool automake libncurses5-dev texinfo
# Setup toolchain
# instructions from https://github.com/crosstool-ng/crosstool-ng
cd toolchain/crosstool-ng
./bootstrap
./configure --prefix=$HOME/.local
make && make install
echo -ne "\n\nif [ -d \"$HOME/.local/bin\" ]; then\n PATH=\"$HOME/.local/bin:$PATH\"\nfi" >> ~/.profile
source ~/.profile
mkdir ../tc/
cd ../tc/
ct-ng list-samples
ct-ng x86_64-w64-mingw32
ct-ng build # lasts 30 minutes...
##################### WxWidgets ######################
cd ../wxWidgets/
sh autogen.sh
./configure --prefix="$HOME/prefix" --enable-static --disable-shared --build=x86_64-w64-mingw32 --enable-unicode --without-libtiff --without-libjpeg --with-expat=builtin --with-libpng=builtin
make
The only way I have found is to clone wxwidgets from github and compile it as above in the script. Then, I included as path -I
WXWIDGET=../toolchain/wxWidgets/include/
$(CXX) -I$(FLEX) -I$(WXWIDGET) $(WXWIDGETSFLAGS) $(CPPFLAGS) $(header) $(src) $(obj3) -o $(OUTPUT)/$(bin)
Hundreds of errors appearing while compiling:
In file included from ../toolchain/wxWidgets/include/wx/platform.h:485:0,
from ../toolchain/wxWidgets/include/wx/defs.h:20,
from ../toolchain/wxWidgets/include/wx/string.h:24,
from ../toolchain/wxWidgets/include/wx/artprov.h:14,
from parser/include/gui.h:17,
from parser/include/customdialogs.h:17:
../toolchain/wxWidgets/include/wx/chkconf.h:282:9: error: #error "wxUSE_SECRETSTORE must be defined, please read comment near the top of this file."
# error "wxUSE_SECRETSTORE must be defined, please read comment near the top of this file."
What should I do?
You need to try "--host" and "--target" configure options.
Just try "../configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-shared --enable-unicode".
BTW, "--enable-unicode" should be turned on by default. So you can drop it.
Also, if you software required C++11, you should compile the library as:
CXXFLAGS="-std=c++11" ../configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-shared --enable-unicode
I have a Makefile generated by CMake. The following path to CMake executable is set in the Makefile:
CMAKE_COMMAND = /home/xyz/opt/cmake/cmake-3.1.1/bin/cmake
How can I integrate Fortify sourceanalyzer with it and run scans?
I had the same challenge but solved it by running it like this:
sourceanalyzer -b project_ID -clean
Go to your build directory and perform make clean or remove all contents including the Makefile
Run cmake by changing CC and CXX variables:
CC="sourceanalyzer -b project_ID gcc" CXX="sourceanalyzer -b project_ID g++" cmake ..
Run make and fortify should be translating files while compilers do their job.
Run sourceanalyzer -b project_ID -scan -f results.fpr
Hope it helps.
I was tasked with integrating our CMake build system with HP Fortify SCA and came across this Thread that gave some insights but lacked specifics as related to HP Fortify so I thought I would share my implementation.
I created a fortify_tools directory at the same level as the source directory. Inside the fortify_tools are a toolchain file and fortify_cc, fortify_cxx, and fortify_ar scripts that will be set as the cmake_compilers via the toolchain file.
fortify_cc
#!/bin/bash
sourceanalyzer -b <PROJECT_ID> gcc $#
fortify_cxx
#!/bin/bash
sourceanalyzer -b <PROJECT_ID> g++ $#
fortify_ar
#!/bin/bash
sourceanalyzer -b <PROJECT_ID> ar $#
NOTE: insert your project name in place of PROJECT_ID
Setting cmake to use the scripts is accomplished in a toolchain file.
fortify_linux_toolchain.cmake
INCLUDE (CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
#specify the compilers
SET(CMAKE_C_COMPILER ${CMAKE_SOURCE_DIR}/fortify_tools/fortify_cc)
SET(CMAKE_CXX_COMPILER ${CMAKE_SOURCE_DIR}/fortify_tools/fortify_cxx)
SET(CMAKE_AR_COMPILER ${CMAKE_SOURCE_DIR}/fortify_tools/fortify_ar)
To generate makefiles using the toolchain file
ccmake -DCMAKE_TOOLCHAIN_FILE=../fortify_tools/foritfy_linux_toolchain.cmake ../
configure and generate your makefiles and build your project.
Once the project is built from within the build directory generate a fortify report by
sourceanalyzer -Xmx2400M -debug -verbose -b <PROJECT_ID> -scan -f <PROJECT_ID>.fpr
I understand the last step is outside of CMake but I am pretty confident a cmake_custom_command can be created to perform the scan step as a post build action.
Finally, this is just the linux implementation but the concept scales well to Windows by creating the necessary batch files and windows specific toolchain file
Fortify doesn't support CMake, I received confirmation from Fortify support team.
This answer is late, but might help someone. This is actually easy to fix - you simply need to run cmake inside sourceanalyzer as well. Make a simple build script that calls cmake and then make, and use sourceanalyzer on that instead. I am using fortify 4.21.
Our old Fortify script for building hand-created Makefiles used a build command that looked like this:
$SOURCEANALYZER $MEMORY $LAUNCHERSWITCHES -b $BUILDID make -f Makefile -j12
I was able to get it working for a project that had been converted to CMake by replacing the above line with this, inspired by a couple of the other answers here:
CC="$SOURCEANALYZER $MEMORY $LAUNCHERSWITCHES -b $BUILDID gcc" \
CXX="$SOURCEANALYZER $MEMORY $LAUNCHERSWITCHES -b $BUILDID g++" \
AR="$SOURCEANALYZER $MEMORY $LAUNCHERSWITCHES -b $BUILDID ar" \
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
make -f Makefile -j12 VERBOSE=1
This is with cmake 2.8.12.2 on Linux.
Below is the script i use for my example project to generate HP Fortify report for Android JNI C/C++ Code.
#!/bin/sh
# Configure NDK version and CMake version
NDK_VERSION=21.0.6113669
CMAKE_VERSION=3.10.2
CMAKE_VERSION_PATH=$CMAKE_VERSION.4988404
PROJECTID="JNI_EXAMPLE"
REPORT_NAME=$PROJECTID"_$(date +'%Y%m%d_%H:%M:%S')"
WORKING_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_HOME=${WORKING_DIR}/../hpfortify_build
FPR="$BUILD_HOME/$REPORT_NAME.fpr"
# Following exports need to be configured according to host machine.
export ANDROID_SDK_HOME=/Library/Android/sdk
export ANDROID_CMAKE_HOME=$ANDROID_SDK_HOME/cmake/$CMAKE_VERSION_PATH/bin
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/$NDK_VERSION
# E.g. JniExample/app/hpfortify/build/CMakeFiles/3.10.2
export CMAKE_FILES_PATH=${BUILD_HOME}/CMakeFiles/$CMAKE_VERSION
export HPFORTIFY_HOME="/Applications/Fortify/Fortify_SCA_and_Apps_20.1.0/bin"
export PATH=$PATH:$ANDROID_SDK_HOME:$ANDROID_NDK_HOME:$ANDROID_CMAKE_HOME:$HPFORTIFY_HOME
echo "[========Start Android JNI C/C++ HP Fortify scanning========]"
echo "[========Build Dir: $BUILD_HOME========]"
echo "[========HP Fortify report path: $FPR========]"
function create_build_folder {
rm -rf $BUILD_HOME
mkdir $BUILD_HOME
}
# The standalone cmake build command can be found from below file.
# JniExample/app/.cxx/cmake/release/x86/build_command.txt
# This file is generated after running command
# `➜ JniExample git:(master) ✗ ./gradlew :app:externalNativeBuildRelease`
function configure_cmake_files {
cd $BUILD_HOME
$ANDROID_CMAKE_HOME/cmake -H$BUILD_HOME/. \
-DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions \
-DCMAKE_FIND_ROOT_PATH=$BUILD_HOME/.cxx/cmake/release/prefab/x86/prefab \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_SDK_HOME/ndk/$NDK_VERSION/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=x86 \
-DANDROID_NDK=$ANDROID_SDK_HOME/ndk/$NDK_VERSION \
-DANDROID_PLATFORM=android-16 \
-DCMAKE_ANDROID_ARCH_ABI=x86 \
-DCMAKE_ANDROID_NDK=$ANDROID_SDK_HOME/ndk/$NDK_VERSION \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$BUILD_HOME/intermediates/cmake/release/obj/x86 \
-DCMAKE_MAKE_PROGRAM=$ANDROID_SDK_HOME/cmake/$CMAKE_VERSION_PATH/bin/ninja \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_SYSTEM_VERSION=16 \
-B$BUILD_HOME/.cxx/cmake/release/x86 \
-GNinja ..
}
function build {
cmake --build .
}
function cleanup {
rm -rf $BUILD_HOME/CMakeFiles/native-lib.dir
rm -rf $FPR
$HPFORTIFY_HOME/sourceanalyzer -clean
}
function replace_compiler_paths {
FORTIFY_TOOLS_PATH="$WORKING_DIR"
CLANG_PATH="$ANDROID_SDK_HOME/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang"
CLANGXX_PATH="$ANDROID_SDK_HOME/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++"
HPFORTIFY_CCPATH="$FORTIFY_TOOLS_PATH/fortify_cc"
HPFORTIFY_CXXPATH="$FORTIFY_TOOLS_PATH/fortify_cxx"\"
sed -i '' 's+'$CLANG_PATH'+'$HPFORTIFY_CCPATH'+g' $CMAKE_FILES_PATH/CMakeCCompiler.cmake
sed -i '' 's+'$CLANG_PATH.*[^")"]'+'$HPFORTIFY_CXXPATH'+g' $CMAKE_FILES_PATH/CMakeCXXCompiler.cmake
}
function scan {
$HPFORTIFY_HOME/sourceanalyzer -b $PROJECTID -scan -f $FPR
# copy the file to $WORKING_DIR
cp $FPR $WORKING_DIR
}
create_build_folder
configure_cmake_files
echo "[========Compile C/C++ using normal compiler ========"]
build
echo "[========Replace the compiler with HP Fortify analyser wrapper compilers ========"]
replace_compiler_paths
echo "[========Clean up the build intermediates and the older build ID and fpr file ========"]
cleanup
echo "[========Recompile C/C++ using HP Fortify analyser wrapper compilers ========"]
build
echo "[========Scan the compiled files and generate final report ========"]
scan
echo "[========Change directory to original working dir ========"]
cd $WORKING_DIR
Need to configure below vars before using it. For my case, I use NDK 21 and CMake 3.10.2 and my project ID is "JNI_EXAMPLE"
# Configure NDK version and CMake version
NDK_VERSION=21.0.6113669
CMAKE_VERSION=3.10.2
CMAKE_VERSION_PATH=$CMAKE_VERSION.4988404
PROJECTID="JNI_EXAMPLE"
# Following exports need to be configured according to host machine.
export ANDROID_SDK_HOME=/Library/Android/sdk
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/$NDK_VERSION
export HPFORTIFY_HOME="/Applications/Fortify/Fortify_SCA_and_Apps_20.1.0/bin"
Here is a more detailed explanation: Using HP Fortify to Scan Android JNI C/C++ Code
On recent version of CMake one can use:
CMAKE_<LANG>_COMPILER_LAUNCHER='sourceanalyzer;-b;<PROJECT_ID>'
You can add other arguments (like -Xmx2G for instance), semicolon separated, as mentioned on cmake documentation
You need to check if you don't use the compiler launcher for another tool like ccache. We can probably use both with
CCACHE_PREFIX='.../sourceanalyzer -b ID'
Here is what I've used in CMake project:
project(myFortifiedProject LANGUAGES CXX)
set(CMAKE_CXX_COMPILER_LAUNCHER ${FORTIFY_TOOL} -b ${PROJECT_NAME})
So when running cmake (assuming sourceanalyzer is on the path):
cmake <other args> -DFORTIFY_TOOL=sourceanalyzer
So the normal build command works:
make myFortifiedProject
And you can finally collect results with:
sourceanalyzer -b myFortifiedProject -scan
I'm getting fatal error: lipo: can't open input file: /Users/.../libABC.a (No such file or directory)
I've cross-checked this file exists in same location after checking with 'Show in Finder'
I'm getting this error while building library. I've tried below solutions but didn't worked:
1. Build Active architecture only - YES/NO
2. Enable BitCode - YES/NO
3. Clean / Clean Build Folder, Quit simulator.
Any other fix?
Xcode-Build phases
check the scripts wheacher contain codes or not look like this to Removex86_64Andi386Framework:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[#]}"
rm "${EXTRACTED_ARCHS[#]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
delete the shell script and clean the project then run again.
I have a Core Library for my ios projects. I use this library in several projects.
When building the library, I copied the .a -file and the header-files into several xcode projects. Everything worked fine.
Now I would like that each project, which uses the library, build the library on their own.
I tried to use this runscript:
# Build Core library first
CORE="${PWD}/../Core"
IDENT="PROJECTIDENT"
PROJ=$CORE/Core.xcodeproj
CORE_LIB="${PWD}/Classes/Core"
mkdir -p "${CORE_LIB}"
#rm -rf "${CORE_LIB}/"*
mkdir -p "/tmp/${IDENT}"
IS_EMPTY=`ls "${CORE_LIB}" | wc -l`
if [ "true" == ${ALREADYINVOKED:-false} ]; then
echo "ALREADY INVOKED"
else
# CRITICAL:
# Prevent infinite recursion (Xcode sucks)
export ALREADYINVOKED="true"
SDK_VERSION=$(echo ${SDK_NAME} | grep -o '.\{3\}$')
OUT_DIR="/tmp/${IDENT}"
EXEC_NAME="libCore.a"
UNIVERSAL_DIR="${OUT_DIR}/Universal"
rm -rf "${UNIVERSAL_DIR}"
mkdir -p "${UNIVERSAL_DIR}"
CONFIG="Debug"
if [ ${CONFIGURATION} != "Debug" ]; then
CONFIG="Release"
fi
echo "${CONFIG}"
# Create build
DID_COMPILE=`xcodebuild -project $PROJ -target Core -configuration "${CONFIG}" -sdk "${PLATFORM_NAME}${SDK_VERSION}" build RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR="${OUT_DIR}" BUILD_ROOT="${OUT_DIR}" EXECUTABLE_NAME="${EXEC_NAME}" | grep "CompileC"`
if [ ! -z "${DID_COMPILE}" ] || [ ${IS_EMPTY} -eq 0 ]; then
# Copy Headers
cp "${OUT_DIR}/${CONFIG}-${PLATFORM_NAME}/usr/local/include/"* "${UNIVERSAL_DIR}"
cp "${OUT_DIR}/${CONFIG}-${PLATFORM_NAME}/${EXEC_NAME}"* "${UNIVERSAL_DIR}"
# Finally we have a fat static library with .a and .h files
# now we copy them to the Project
rm -rf "${CORE_LIB}"
cp -Rf "${UNIVERSAL_DIR}" "${CORE_LIB}"
fi
fi
This script works but only every second time.
E.g. I make a change in a Library Class, and built, the main project is not compiled while the Library dependency get refreshed.
Then I make another change to the Library, build again, and all changes are usable in the main probject.
But always only each second build....
How can I fix this?