How to Build OpenSSL for iOS and OSX - ios

I have been trying to figure out how to create/build static and dynamic OpenSSL libraries for apple platform i.e iOS and osx but unable to find any proper documentation.
I need to build the 1.1.1i version of openssl or any 1.1.1 equivalent.
Tried to follow this https://github.com/keeshux/openssl-apple but then it fails while building MAC-OSX arm64.
Can anybody please point me right/working direction??
Thanks!!

This script may help. It builds the OpenSSL 1.1.1 and 1.0.2 series libraries (reference - also has build script for OSX)
iOS Build
#!/bin/bash
#
# This script downloads and builds the iOS openSSL libraries with Bitcode enabled
#
# Author: Jason Cox, #jasonacox https://github.com/jasonacox/Build-OpenSSL-cURL
# Date: 2020-Aug-15
#
set -e
# Custom build options
CUSTOMCONFIG="enable-ssl-trace"
# Formatting
default="\033[39m"
white="\033[97m"
green="\033[32m"
red="\033[91m"
yellow="\033[33m"
bold="\033[0m${green}\033[1m"
subbold="\033[0m${green}"
archbold="\033[0m${yellow}\033[1m"
normal="${white}\033[0m"
dim="\033[0m${white}\033[2m"
alert="\033[0m${red}\033[1m"
alertdim="\033[0m${red}\033[2m"
# set trap to help debug build errors
trap 'echo -e "${alert}** ERROR with Build - Check /tmp/openssl*.log${alertdim}"; tail -3 /tmp/openssl*.log' INT TERM EXIT
# Set minimum OS versions for target
MACOS_X86_64_VERSION="" # Empty = use host version
MACOS_ARM64_VERSION="" # Min supported is MacOS 11.0 Big Sur
CATALYST_IOS="13.0" # Min supported is iOS 13.0 for Mac Catalyst
IOS_MIN_SDK_VERSION="8.0"
IOS_SDK_VERSION=""
TVOS_MIN_SDK_VERSION="9.0"
TVOS_SDK_VERSION=""
catalyst="0"
VERSION="1.1.1i" # OpenSSL version default
CORES=$(sysctl -n hw.ncpu)
OPENSSL_VERSION="openssl-${VERSION}"
if [ -z "${MACOS_X86_64_VERSION}" ]; then
MACOS_X86_64_VERSION=$(sw_vers -productVersion)
fi
if [ -z "${MACOS_ARM64_VERSION}" ]; then
MACOS_ARM64_VERSION=$(sw_vers -productVersion)
fi
usage ()
{
echo
echo -e "${bold}Usage:${normal}"
echo
echo -e " ${subbold}$0${normal} [-v ${dim}<version>${normal}] [-s ${dim}<version>${normal}] [-t ${dim}<version>${normal}] [-i ${dim}<version>${normal}] [-a ${dim}<version>${normal}] [-u ${dim}<version>${normal}] [-e] [-m] [-3] [-x] [-h]"
echo
echo " -v version of OpenSSL (default $VERSION)"
echo " -s iOS min target version (default $IOS_MIN_SDK_VERSION)"
echo " -t tvOS min target version (default $TVOS_MIN_SDK_VERSION)"
echo " -i macOS 86_64 min target version (default $MACOS_X86_64_VERSION)"
echo " -a macOS arm64 min target version (default $MACOS_ARM64_VERSION)"
echo " -e compile with engine support"
echo " -m compile Mac Catalyst library"
echo " -u Mac Catalyst iOS min target version (default $CATALYST_IOS)"
echo " -3 compile with SSLv3 support"
echo " -x disable color output"
echo " -h show usage"
echo
trap - INT TERM EXIT
exit 127
}
engine=0
while getopts "v:s:t:i:a:u:emx3h\?" o; do
case "${o}" in
v)
OPENSSL_VERSION="openssl-${OPTARG}"
;;
s)
IOS_MIN_SDK_VERSION="${OPTARG}"
;;
t)
TVOS_MIN_SDK_VERSION="${OPTARG}"
;;
i)
MACOS_X86_64_VERSION="${OPTARG}"
;;
a)
MACOS_ARM64_VERSION="${OPTARG}"
;;
e)
engine=1
;;
m)
catalyst="1"
;;
u)
catalyst="1"
CATALYST_IOS="${OPTARG}"
;;
x)
bold=""
subbold=""
normal=""
dim=""
alert=""
alertdim=""
archbold=""
;;
3)
CUSTOMCONFIG="enable-ssl3 enable-ssl3-method enable-ssl-trace"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
DEVELOPER=`xcode-select -print-path`
# Semantic Version Comparison
version_lte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
if version_lte $MACOS_ARM64_VERSION 11.0; then
MACOS_ARM64_VERSION="11.0" # Min support for Apple Silicon is 11.0
fi
buildIOS()
{
ARCH=$1
pushd . > /dev/null
cd "${OPENSSL_VERSION}"
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
#sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
fi
export $PLATFORM
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${IOS_SDK_VERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -fembed-bitcode -arch ${ARCH}"
echo -e "${subbold}Building ${OPENSSL_VERSION} for ${PLATFORM} ${IOS_SDK_VERSION} ${archbold}${ARCH}${dim} (iOS ${IOS_MIN_SDK_VERSION})"
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
TARGET="darwin-i386-cc"
if [[ $ARCH == "x86_64" ]]; then
TARGET="darwin64-x86_64-cc"
fi
if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
./Configure no-asm ${TARGET} -no-shared --prefix="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
else
./Configure no-asm ${TARGET} -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
fi
else
if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
# export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
./Configure iphoneos-cross DSO_LDFLAGS=-fembed-bitcode --prefix="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
else
./Configure iphoneos-cross -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
fi
fi
# add -isysroot to CC=
if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
sed -ie "s!^CFLAGS=!CFLAGS=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${IOS_MIN_SDK_VERSION} !" "Makefile"
else
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${IOS_MIN_SDK_VERSION} !" "Makefile"
fi
make -j${CORES} >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
make install_sw >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
make clean >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
popd > /dev/null
# Clean up exports
export PLATFORM=""
export CC=""
export CXX=""
export CFLAGS=""
export LDFLAGS=""
export CPPFLAGS=""
export CROSS_TOP=""
export CROSS_SDK=""
export BUILD_TOOLS=""
}
buildIOSsim()
{
ARCH=$1
pushd . > /dev/null
cd "${OPENSSL_VERSION}"
PLATFORM="iPhoneSimulator"
export $PLATFORM
TARGET="darwin-i386-cc"
RUNTARGET=""
MIPHONEOS="${IOS_MIN_SDK_VERSION}"
if [[ $ARCH != "i386" ]]; then
TARGET="darwin64-${ARCH}-cc"
RUNTARGET="-target ${ARCH}-apple-ios${IOS_MIN_SDK_VERSION}-simulator"
# e.g. -target arm64-apple-ios11.0-simulator
#if [[ $ARCH == "arm64" ]]; then
# if (( $(echo "${MIPHONEOS} < 11.0" |bc -l) )); then
# MIPHONEOS="11.0" # Min support for Apple Silicon is iOS 11.0
# fi
#fi
fi
# set up exports for build
export CFLAGS=" -Os -miphoneos-version-min=${MIPHONEOS} -fembed-bitcode -arch ${ARCH} ${RUNTARGET} "
export LDFLAGS=" -arch ${ARCH} -isysroot ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk "
export CPPFLAGS=" -I.. -isysroot ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk "
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${IOS_SDK_VERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc"
export CXX="${BUILD_TOOLS}/usr/bin/gcc"
echo -e "${subbold}Building ${OPENSSL_VERSION} for ${PLATFORM} ${iOS_SDK_VERSION} ${archbold}${ARCH}${dim} (iOS ${MIPHONEOS})"
# configure
if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
./Configure no-asm ${TARGET} -no-shared --prefix="/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}" --openssldir="/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}.log"
else
./Configure no-asm ${TARGET} -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}.log"
fi
# add -isysroot to CC=
# no longer needed with exports
#if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
# sed -ie "s!^CFLAGS=!CFLAGS=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${IOS_MIN_SDK_VERSION} !" "Makefile"
#else
# sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${IOS_MIN_SDK_VERSION} !" "Makefile"
#fi
# make
make -j${CORES} >> "/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}.log" 2>&1
make install_sw >> "/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}.log" 2>&1
make clean >> "/tmp/${OPENSSL_VERSION}-iOS-Simulator-${ARCH}.log" 2>&1
popd > /dev/null
# Clean up exports
export PLATFORM=""
export CC=""
export CXX=""
export CFLAGS=""
export LDFLAGS=""
export CPPFLAGS=""
export CROSS_TOP=""
export CROSS_SDK=""
export BUILD_TOOLS=""
}
#echo -e "${bold}Cleaning up${dim}"
#rm -rf include/openssl/* lib/*
mkdir -p Mac/lib
mkdir -p Catalyst/lib
mkdir -p iOS/lib
mkdir -p iOS-simulator/lib
mkdir -p iOS-fat/lib
mkdir -p tvOS/lib
mkdir -p Mac/include/openssl/
mkdir -p Catalyst/include/openssl/
mkdir -p iOS/include/openssl/
mkdir -p iOS-simulator/include/openssl/
mkdir -p iOS-fat/include/openssl/
mkdir -p tvOS/include/openssl/
rm -rf "/tmp/${OPENSSL_VERSION}-*"
rm -rf "/tmp/${OPENSSL_VERSION}-*.log"
rm -rf "${OPENSSL_VERSION}"
if [ ! -e ${OPENSSL_VERSION}.tar.gz ]; then
echo "Downloading ${OPENSSL_VERSION}.tar.gz"
curl -LOs https://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz
else
echo "Using ${OPENSSL_VERSION}.tar.gz"
fi
if [[ "$OPENSSL_VERSION" = "openssl-1.1.1"* ]]; then
echo "** Building OpenSSL 1.1.1 **"
else
if [[ "$OPENSSL_VERSION" = "openssl-1.0."* ]]; then
echo "** Building OpenSSL 1.0.x ** "
echo -e "${alert}** WARNING: End of Life Version - Upgrade to 1.1.1 **${dim}"
else
echo -e "${alert}** WARNING: This build script has not been tested with $OPENSSL_VERSION **${dim}"
fi
fi
echo "Unpacking openssl"
tar xfz "${OPENSSL_VERSION}.tar.gz"
if [ "$engine" == "1" ]; then
echo "+ Activate Static Engine"
sed -ie 's/\"engine/\"dynamic-engine/' ${OPENSSL_VERSION}/Configurations/15-ios.conf
fi
echo -e "${bold}Building iOS libraries${dim}"
buildIOS "armv7"
buildIOS "armv7s"
buildIOS "arm64"
buildIOS "arm64e"
buildIOSsim "i386"
buildIOSsim "x86_64"
buildIOSsim "arm64"
echo " Copying headers and libraries"
cp /tmp/${OPENSSL_VERSION}-iOS-arm64/include/openssl/* iOS/include/openssl/
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-armv7/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-armv7s/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64e/lib/libcrypto.a" \
-create -output iOS/lib/libcrypto.a
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-armv7/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-armv7s/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64e/lib/libssl.a" \
-create -output iOS/lib/libssl.a
cp /tmp/${OPENSSL_VERSION}-iOS-Simulator-x86_64/include/openssl/* iOS-simulator/include/openssl/
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-i386/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-x86_64/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-arm64/lib/libcrypto.a" \
-create -output iOS-simulator/lib/libcrypto.a
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-i386/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-x86_64/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-arm64/lib/libssl.a" \
-create -output iOS-simulator/lib/libssl.a
cp /tmp/${OPENSSL_VERSION}-iOS-arm64/include/openssl/* iOS-fat/include/openssl/
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-armv7/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-armv7s/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64e/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-i386/lib/libcrypto.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-x86_64/lib/libcrypto.a" \
-create -output iOS-fat/lib/libcrypto.a
lipo \
"/tmp/${OPENSSL_VERSION}-iOS-armv7/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-armv7s/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-arm64e/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-x86_64/lib/libssl.a" \
"/tmp/${OPENSSL_VERSION}-iOS-Simulator-i386/lib/libssl.a" \
-create -output iOS-fat/lib/libssl.a
echo " Creating combined OpenSSL libraries for iOS"
libtool -no_warning_for_no_symbols -static -o openssl-ios-armv7_armv7s_arm64_arm64e.a iOS/lib/libcrypto.a iOS/lib/libssl.a
libtool -no_warning_for_no_symbols -static -o openssl-ios-i386_x86_64_arm64-simulator.a iOS-simulator/lib/libcrypto.a iOS-simulator/lib/libssl.a
echo -e "${bold}Cleaning up${dim}"
rm -rf /tmp/${OPENSSL_VERSION}-*
rm -rf ${OPENSSL_VERSION}
#reset trap
trap - INT TERM EXIT
echo -e "${normal}Done"
Note:
The overarching project builds OpenSSL, nghttp2 and cURL/libcurl for MacOS (x86_64, arm64), Mac Catalyst (x86_64, arm64), iOS (armv7, armv7s, arm64 and arm64e), iOS Simulator (x86_64, arm64), tvOS (arm64) and tvOS Simulator (x86_64). Update now builds XCFrameworks which supports all platforms and targets for easy import into your projects.

Use LibreSSL instead
Granted, this is not a 1.1 version of OpenSSL, but if you're not familiar with LibreSSL it is a drop-in replacement for OpenSSL 1.0.x and I think is easier to work with from a compilation standpoint, because it relies on CMake.
Building for macOS would not necessarily require a toolchain file.
You need to do three things
Modify the CMakeLists.txt to generate a framework (if desired)
Provide a toolchain file for each SDK
Combine the output into an XCFramework - optional
I have applied the following snippet to the source root CMakeLists.txt as a Pull Request.
if (BUILD_APPLE_FRAMEWORK)
# Trick cmake into doing work - like copying the headers
set(EMPTY_C ${CMAKE_CURRENT_BINARY_DIR}/empty.c)
file(TOUCH ${EMPTY_C})
set(MODULE_MODULEMAP ${CMAKE_CURRENT_BINARY_DIR}/module.modulemap)
file(WRITE ${MODULE_MODULEMAP} "\
framework module LibreSSL {
umbrella header \"LibreSSL.h\"
export *
module * { export * }
}
")
set_source_files_properties(${MODULE_MODULEMAP} PROPERTIES
MACOSX_PACKAGE_LOCATION Modules)
# Create the umbrella header
set(LIBRESSL_H ${CMAKE_CURRENT_BINARY_DIR}/LibreSSL.h)
file(REMOVE ${LIBRESSL_H})
file(GLOB LIBRESSL_INCLUDES
${CMAKE_CURRENT_LIST_DIR}/include/*.h ${CMAKE_CURRENT_LIST_DIR}/include/openssl/*.h)
foreach(LIBRESSL_INCLUDE ${LIBRESSL_INCLUDES})
file(RELATIVE_PATH RELATIVE_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/include ${LIBRESSL_INCLUDE})
get_filename_component(RELATIVE_INCLUDE_DIR ${RELATIVE_INCLUDE} DIRECTORY)
set_source_files_properties(${LIBRESSL_INCLUDE} PROPERTIES
MACOSX_PACKAGE_LOCATION Headers/${RELATIVE_INCLUDE_DIR})
file(APPEND ${LIBRESSL_H} "#include \"${RELATIVE_INCLUDE}\"\n")
endforeach()
# Create the framework from object libraries
add_library(LibreSSL_framework ${EMPTY_C}
$<TARGET_OBJECTS:crypto_obj> $<TARGET_OBJECTS:ssl_obj>
${LIBRESSL_H} ${LIBRESSL_INCLUDES}
${MODULE_MODULEMAP})
set_target_properties(LibreSSL_framework PROPERTIES
OUTPUT_NAME LibreSSL
PUBLIC_HEADER "${LIBRESSL_H}"
FRAMEWORK on)
install(TARGETS LibreSSL_framework
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(BUILD_APPLE_FRAMEWORK)
generate_xcframework.sh
#!/usr/bin/env bash
set -e
FRAMEWORKS=()
for SDK in macosx iphoneos iphonesimulator; do
BUILD_DIR=build-${SDK}
rm -rf ${BUILD_DIR}
mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR}
cmake -G Ninja -D CMAKE_TOOLCHAIN_FILE=cmake/${SDK}.toolchain.cmake ..
cmake --build . --target LibreSSL_framework
FRAMEWORKS+=(-framework ${BUILD_DIR}/LibreSSL.framework)
popd
done
XCFRAMEWORK_DIR=build-xcframework
rm -rf ${XCFRAMEWORK_DIR}
mkdir -p ${XCFRAMEWORK_DIR}
xcodebuild -create-xcframework \
"${FRAMEWORKS[#]}" \
-output ${XCFRAMEWORK_DIR}/LibreSSL.xcframework
macosx.toolchain.cmake
set( CMAKE_SYSTEM_NAME Darwin )
set( SDK macosx CACHE STRING "Xcode SDK" )
set( CMAKE_OSX_ARCHITECTURES x86_64 arm64 CACHE STRING "Architectures" )
iphoneos.toolchain.cmake
set( CMAKE_SYSTEM_NAME Darwin )
set( SDK iphoneos CACHE STRING "Xcode SDK" )
set( CMAKE_OSX_ARCHITECTURES armv7 armv7s arm64 CACHE STRING "Architectures" )
include(${CMAKE_CURRENT_LIST_DIR}/apple-common-toolchain.cmake)
iphonesimulator.toolchain.cmake
set( CMAKE_SYSTEM_NAME Darwin )
set( SDK iphonesimulator CACHE STRING "Xcode SDK" )
set( CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING "Architectures" )
include(${CMAKE_CURRENT_LIST_DIR}/apple-common-toolchain.cmake)
apple-common-toolchain.cmake
set(BUILD_APPLE_FRAMEWORK on)
if(SDK STREQUAL iphoneos OR SDK STREQUAL iphonesimulator)
set(IOS_DEPLOYMENT_TARGET "9.0")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET} CACHE STRING "" FORCE)
elseif(SDK STREQUAL macosx)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "" FORCE)
else()
message(FATAL_ERROR "Unknown sdk when setting deployment target: ${SDK}")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
execute_process(COMMAND xcrun --sdk ${SDK} --find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE PATH "clang executable")
execute_process( COMMAND xcrun --sdk ${SDK} --find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE PATH "clang++ executable")
execute_process( COMMAND xcrun --sdk ${SDK} --find libtool
OUTPUT_VARIABLE CMAKE_LIBTOOL
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
execute_process( COMMAND xcrun --sdk ${SDK} --find strip
OUTPUT_VARIABLE CMAKE_STRIP
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_STRIP ${CMAKE_STRIP} CACHE PATH "strip executable")
execute_process( COMMAND xcrun --sdk ${SDK} --find dsymutil
OUTPUT_VARIABLE DSYMUTIL
OUTPUT_STRIP_TRAILING_WHITESPACE)
if( BUILD_TARGET_IOS AND NOT BUILD_TARGET_SIMULATOR)
if( XCODE_VERSION VERSION_LESS 11)
set(DSYMUTIL ${DSYMUTIL} -t 1)
endif()
endif()
set(DSYMUTIL ${DSYMUTIL} CACHE PATH "dsymutil executable")
execute_process( COMMAND xcrun --sdk ${SDK} --show-sdk-path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT} CACHE PATH "sysroot")
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_Swift_COMPILER_WORKS TRUE)
set(CMAKE_FIND_FRAMEWORK FIRST)
set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Related

Running default RN native project in iOS gives error

Any idea what is going wrong? I have updated all the relevant components to their latest version.
I am creating a default react-native project and trying to run the iOS simulator
npx react-native init {project_name}
cd {project_name}
npx react-native run-ios
I receive the following error:
/bin/sh -c {user}/Library/Developer/Xcode/DerivedData/{project_name}-epegcqhmisnuaeenegumkazvqqys/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh
N/A: version "default -> N/A" is not yet installed.
You need to run "nvm install default" to install it before using it.
Command PhaseScriptExecution failed with a nonzero exit code
The script (self-generated) in question is below:
#!/bin/sh
set -o pipefail
set -e
RN_DIR=$(cd "${PODS_TARGET_SRCROOT}/../.." && pwd)
GENERATED_SRCS_DIR="${DERIVED_FILE_DIR}/generated/source/codegen"
GENERATED_SCHEMA_FILE="$GENERATED_SRCS_DIR/schema.json"
TEMP_OUTPUT_DIR="$GENERATED_SRCS_DIR/out"
LIBRARY_NAME="FBReactNativeSpec"
OUTPUT_DIR="${PODS_TARGET_SRCROOT}/../../React/FBReactNativeSpec/FBReactNativeSpec"
CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"
CODEGEN_CLI_PATH=""
# Determine path to react-native-codegen
if [ -d "$CODEGEN_REPO_PATH" ]; then
CODEGEN_CLI_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
elif [ -d "$CODEGEN_NPM_PATH" ]; then
CODEGEN_CLI_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
else
echo "error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
exit 1
fi
find_node () {
source "$RN_DIR/scripts/find-node.sh"
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
if [ -z "$NODE_BINARY" ]; then
echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
exit 1
fi
}
setup_dirs () {
set +e
rm -rf "$GENERATED_SRCS_DIR"
set -e
mkdir -p "$GENERATED_SRCS_DIR" "$TEMP_OUTPUT_DIR"
# Clear output files
> "${SCRIPT_OUTPUT_FILE_0}"
}
describe () {
printf "\n\n>>>>> %s\n\n\n" "$1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
buildCodegenCLI () {
if [ ! -d "$CODEGEN_CLI_PATH/lib" ]; then
describe "Building react-native-codegen package"
bash "$CODEGEN_CLI_PATH/scripts/oss/build.sh"
fi
}
generateCodegenSchemaFromJavaScript () {
describe "Generating codegen schema from JavaScript"
SRCS_PATTERN="Native*.js"
SRCS_DIR="../../Libraries"
if [ $SRCS_PATTERN ]; then
JS_SRCS=$(find "${PODS_TARGET_SRCROOT}"/$SRCS_DIR -type f -name "$SRCS_PATTERN" -print0 | xargs -0)
echo "["../../Libraries/ActionSheetIOS/NativeActionSheetManager.js", "../../Libraries/Alert/NativeAlertManager.js", "../../Libraries/Animated/NativeAnimatedHelper.js", "../../Libraries/Animated/NativeAnimatedModule.js", "../../Libraries/Animated/NativeAnimatedTurboModule.js", "../../Libraries/AppState/NativeAppState.js", "../../Libraries/BatchedBridge/NativeModules.js", "../../Libraries/Blob/NativeBlobModule.js", "../../Libraries/Blob/NativeFileReaderModule.js", "../../Libraries/BugReporting/NativeBugReporting.js", "../../Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js", "../../Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js", "../../Libraries/Components/Clipboard/NativeClipboard.js", "../../Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js", "../../Libraries/Components/Keyboard/NativeKeyboardObserver.js", "../../Libraries/Components/Sound/NativeSoundManager.js", "../../Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js", "../../Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js", "../../Libraries/Components/ToastAndroid/NativeToastAndroid.js", "../../Libraries/Core/NativeExceptionsManager.js", "../../Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js", "../../Libraries/Core/Timers/NativeTiming.js", "../../Libraries/EventEmitter/NativeEventEmitter.js", "../../Libraries/EventEmitter/__mocks__/NativeEventEmitter.js", "../../Libraries/HeapCapture/NativeJSCHeapCapture.js", "../../Libraries/Image/NativeImageEditor.js", "../../Libraries/Image/NativeImageLoaderAndroid.js", "../../Libraries/Image/NativeImageLoaderIOS.js", "../../Libraries/Image/NativeImagePickerIOS.js", "../../Libraries/Image/NativeImageStoreAndroid.js", "../../Libraries/Image/NativeImageStoreIOS.js", "../../Libraries/Interaction/NativeFrameRateLogger.js", "../../Libraries/Linking/NativeIntentAndroid.js", "../../Libraries/Linking/NativeLinkingManager.js", "../../Libraries/Modal/NativeModalManager.js", "../../Libraries/NativeComponent/NativeComponentRegistry.js", "../../Libraries/NativeModules/specs/NativeAnimationsDebugModule.js", "../../Libraries/NativeModules/specs/NativeDevMenu.js", "../../Libraries/NativeModules/specs/NativeDevSettings.js", "../../Libraries/NativeModules/specs/NativeDeviceEventManager.js", "../../Libraries/NativeModules/specs/NativeDialogManagerAndroid.js", "../../Libraries/NativeModules/specs/NativeLogBox.js", "../../Libraries/NativeModules/specs/NativeRedBox.js", "../../Libraries/NativeModules/specs/NativeSourceCode.js", "../../Libraries/Network/NativeNetworkingAndroid.js", "../../Libraries/Network/NativeNetworkingIOS.js", "../../Libraries/Performance/NativeJSCSamplingProfiler.js", "../../Libraries/PermissionsAndroid/NativePermissionsAndroid.js", "../../Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js", "../../Libraries/ReactNative/NativeHeadlessJsTaskSupport.js", "../../Libraries/ReactNative/NativeI18nManager.js", "../../Libraries/ReactNative/NativeUIManager.js", "../../Libraries/Settings/NativeSettingsManager.js", "../../Libraries/Share/NativeShareModule.js", "../../Libraries/Storage/NativeAsyncLocalStorage.js", "../../Libraries/Storage/NativeAsyncSQLiteDBStorage.js", "../../Libraries/TurboModule/samples/NativeSampleTurboModule.js", "../../Libraries/Utilities/NativeAppearance.js", "../../Libraries/Utilities/NativeDevLoadingView.js", "../../Libraries/Utilities/NativeDevSplitBundleLoader.js", "../../Libraries/Utilities/NativeDeviceInfo.js", "../../Libraries/Utilities/NativeJSDevSupport.js", "../../Libraries/Utilities/NativePlatformConstantsAndroid.js", "../../Libraries/Utilities/NativePlatformConstantsIOS.js", "../../Libraries/Vibration/NativeVibration.js", "../../Libraries/WebSocket/NativeWebSocketModule.js"]" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
else
JS_SRCS="${PODS_TARGET_SRCROOT}/$SRCS_DIR"
echo "../../Libraries" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
fi
"$NODE_BINARY" "$CODEGEN_CLI_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$GENERATED_SCHEMA_FILE" $JS_SRCS
}
generateCodegenArtifactsFromSchema () {
describe "Generating codegen artifacts from schema"
pushd "$RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" "scripts/generate-specs-cli.js" ios "$GENERATED_SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$LIBRARY_NAME"
popd >/dev/null || exit 1
}
moveOutputs () {
mkdir -p "$OUTPUT_DIR"
# Copy all output to output_dir
cp -R "$TEMP_OUTPUT_DIR/" "$OUTPUT_DIR" || exit 1
echo "$LIBRARY_NAME output has been written to $OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
ls -1 "$OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
main () {
setup_dirs
find_node
buildCodegenCLI
generateCodegenSchemaFromJavaScript
generateCodegenArtifactsFromSchema
moveOutputs
}
main "$#"
echo 'Done.' >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
Trying to run from Xcode yields in the same error.
Needless to say, I tried running
nvm install default
and received the following error:
Version 'default' not found - try `nvm ls-remote` to browse available versions.
I don't answer on Stackoverflow often but I had the same issue and used this post to solve it.
It basically revolves around the command
nvm alias default system
or swapping system to whatever version of NodeJS you would like.
I had the same issue when building the IOS app.
Open a terminal and type:
git clone https://github.com/nvm-sh/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
nvm alias default system
Rather than modifying the system node, applying the commit that removes the find-node.sh script with patch-package fixed this issue for a dev on our team who was stuck with this issue.
The contents of our patch is simply
diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
deleted file mode 100755
index 5d6d2c4..0000000
--- a/node_modules/react-native/scripts/find-node.sh
+++ /dev/null
## -1,56 +0,0 ##
-#!/bin/bash
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-set -e
-
-# remove global prefix if it's already set
-# the running shell process will choose a node binary and a global package directory breaks version managers
-unset PREFIX
-
-# Support Homebrew on M1
-HOMEBREW_M1_BIN=/opt/homebrew/bin
-if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then
- export PATH="$HOMEBREW_M1_BIN:$PATH"
-fi
-
-# Define NVM_DIR and source the nvm.sh setup script
-[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
-
-# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc
-# See: https://github.com/nvm-sh/nvm/issues/2053
-if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
- # shellcheck source=/dev/null
- . "$HOME/.nvm/nvm.sh" --no-use
- nvm use 2> /dev/null || nvm use default
-elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
- # shellcheck source=/dev/null
- . "$(brew --prefix nvm)/nvm.sh" --no-use
- nvm use 2> /dev/null || nvm use default
-fi
-
-# Set up the nodenv node version manager if present
-if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
- eval "$("$HOME/.nodenv/bin/nodenv" init -)"
-elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
- eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
-fi
-
-# Set up the ndenv of anyenv if preset
-if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
- export PATH=${HOME}/.anyenv/bin:${PATH}
- if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
- eval "$(anyenv init -)"
- fi
-fi
-
-# Set up asdf-vm if present
-if [[ -f "$HOME/.asdf/asdf.sh" ]]; then
- # shellcheck source=/dev/null
- . "$HOME/.asdf/asdf.sh"
-elif [[ -x "$(command -v brew)" && -f "$(brew --prefix asdf)/asdf.sh" ]]; then
- # shellcheck source=/dev/null
- . "$(brew --prefix asdf)/asdf.sh"
-fi
diff --git a/node_modules/react-native/scripts/react-native-xcode.sh b/node_modules/react-native/scripts/react-native-xcode.sh
index 3ef9a71..304a5dc 100755
--- a/node_modules/react-native/scripts/react-native-xcode.sh
+++ b/node_modules/react-native/scripts/react-native-xcode.sh
## -79,9 +79,7 ## if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
exit 2
fi
-# Find path to Node
-# shellcheck source=/dev/null
-source "$REACT_NATIVE_DIR/scripts/find-node.sh"
+NODE_BINARY="$(command -v node)"
# check and assign NODE_BINARY env
# shellcheck source=/dev/null
diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 1b8a078..d65c9ca 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
## -289,8 +289,6 ## else
fi
find_node () {
- source "$RN_DIR/scripts/find-node.sh"
-
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
if [ -z "$NODE_BINARY" ]; then
echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1

Implementing SonarQube to iOS Project getting error on run-sonar-swift.sh

I am implementing the SonarQube to my project. SonarQube server is up but when i am try to run the run-sonar-swift.sh script i got console error and i can't see the project on the console. SonarQube and SonarScanner added under the Application folder.
Here is my run-sonar-swift.sh script:
#!/bin/bash
#
# backelite-sonar-swift-plugin - Enables analysis of Swift and Objective-C projects into SonarQube.
# Copyright © 2015 Backelite (${email})
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
## INSTALLATION: Copy this script somewhere in your PATH
## USAGE: ./run-sonar-swift.sh
## DEBUG: ./run-sonar-swift.sh -v
## WARNING: edit your project parameters in sonar-project.properties rather than modifying this script
#
# Global parameters
SLATHER_CMD=slather
SWIFTLINT_CMD=swiftlint
TAILOR_CMD=tailor
XCPRETTY_CMD=xcpretty
LIZARD_CMD=lizard
XCODEBUILD_CMD=xcodebuild
trap "echo 'Script interrupted by Ctrl+C'; stopProgress; exit 1" SIGHUP SIGINT SIGTERM
function startProgress() {
while true
do
echo -n "."
sleep 5
done
}
function stopProgress() {
if [ "$vflag" = "" -a "$nflag" = "" ]; then
kill $PROGRESS_PID &>/dev/null
fi
}
function testIsInstalled() {
hash $1 2>/dev/null
if [ $? -eq 1 ]; then
echo >&2 "ERROR - $1 is not installed or not in your PATH"; exit 1;
fi
}
function readParameter() {
variable=$1
shift
parameter=$1
shift
eval $variable="\"$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')\""
}
# Run a set of commands with logging and error handling
function runCommand() {
# 1st arg: redirect stdout
# 2nd arg: command to run
# 3rd..nth arg: args
redirect=$1
shift
command=$1
shift
if [ "$nflag" = "on" ]; then
# don't execute command, just echo it
echo
if [ "$redirect" = "/dev/stdout" ]; then
if [ "$vflag" = "on" ]; then
echo "+" $command "$#"
else
echo "+" $command "$#" "> /dev/null"
fi
elif [ "$redirect" != "no" ]; then
echo "+" $command "$#" "> $redirect"
else
echo "+" $command "$#"
fi
elif [ "$vflag" = "on" ]; then
echo
if [ "$redirect" = "/dev/stdout" ]; then
set -x #echo on
$command "$#"
returnValue=$?
set +x #echo off
elif [ "$redirect" != "no" ]; then
set -x #echo on
$command "$#" > $redirect
returnValue=$?
set +x #echo off
else
set -x #echo on
$command "$#"
returnValue=$?
set +x #echo off
fi
if [[ $returnValue != 0 && $returnValue != 5 ]] ; then
stopProgress
echo "ERROR - Command '$command $#' failed with error code: $returnValue"
exit $returnValue
fi
else
if [ "$redirect" = "/dev/stdout" ]; then
$command "$#" > /dev/null
elif [ "$redirect" != "no" ]; then
$command "$#" > $redirect
else
$command "$#"
fi
returnValue=$?
if [[ $returnValue != 0 && $returnValue != 5 ]] ; then
stopProgress
echo "ERROR - Command '$command $#' failed with error code: $returnValue"
exit $returnValue
fi
echo
fi
}
## COMMAND LINE OPTIONS
vflag=""
nflag=""
unittests="on"
swiftlint="on"
tailor="on"
lizard="on"
oclint="on"
fauxpas="on"
sonarscanner=""
while [ $# -gt 0 ]
do
case "$1" in
-v) vflag=on;;
-n) nflag=on;;
-nounittests) unittests="";;
-noswiftlint) swiftlint="";;
-notailor) tailor="";;
-usesonarscanner) sonarscanner="on";;
--) shift; break;;
-*)
echo >&2 "Usage: $0 [-v]"
exit 1;;
*) break;; # terminate while loop
esac
shift
done
# Usage OK
echo "Running run-sonar-swift.sh..."
## CHECK PREREQUISITES
# sonar-project.properties in current directory
if [ ! -f sonar-project.properties ]; then
echo >&2 "ERROR - No sonar-project.properties in current directory"; exit 1;
fi
## READ PARAMETERS from sonar-project.properties
#.xcodeproj filename
projectFile=''; readParameter projectFile 'sonar.swift.project'
workspaceFile=''; readParameter workspaceFile 'sonar.swift.workspace'
# Count projects
if [[ ! -z "$projectFile" ]]; then
projectCount=$(echo $projectFile | sed -n 1'p' | tr ',' '\n' | wc -l | tr -d '[[:space:]]')
if [ "$vflag" = "on" ]; then
echo "Project count is [$projectCount]"
fi
fi
# Source directories for .swift files
srcDirs=''; readParameter srcDirs 'sonar.sources'
# The name of your application scheme in Xcode
appScheme=''; readParameter appScheme 'sonar.swift.appScheme'
# The app configuration to use for the build
appConfiguration=''; readParameter appConfiguration 'sonar.swift.appConfiguration'
# The name of your test scheme in Xcode
testScheme=''; readParameter testScheme 'sonar.swift.testScheme'
# The name of your binary file (application)
binaryName=''; readParameter binaryName 'sonar.swift.appName'
# Get the path of plist file
plistFile=`xcodebuild -showBuildSettings -project "${projectFile}" | grep -i 'PRODUCT_SETTINGS_PATH' -m 1 | sed 's/[ ]*PRODUCT_SETTINGS_PATH = //'`
# Number version from plist if no sonar.projectVersion
numVerionFromPlist=`defaults read ${plistFile} CFBundleShortVersionString`
# Read destination simulator
destinationSimulator=''; readParameter destinationSimulator 'sonar.swift.simulator'
# Read tailor configuration
tailorConfiguration=''; readParameter tailorConfiguration 'sonar.swift.tailor.config'
# The file patterns to exclude from coverage report
excludedPathsFromCoverage=''; readParameter excludedPathsFromCoverage 'sonar.swift.excludedPathsFromCoverage'
# Check for mandatory parameters
if [ -z "$projectFile" -o "$projectFile" = " " ] && [ -z "$workspaceFile" -o "$workspaceFile" = " " ]; then
echo >&2 "ERROR - sonar.swift.project or/and sonar.swift.workspace parameter is missing in sonar-project.properties. You must specify which projects (comma-separated list) are application code or which workspace and project to use."
exit 1
elif [ ! -z "$workspaceFile" ] && [ -z "$projectFile" ]; then
echo >&2 "ERROR - sonar.swift.workspace parameter is present in sonar-project.properties but sonar.swift.project and is not. You must specify which projects (comma-separated list) are application code or which workspace and project to use."
exit 1
fi
if [ -z "$srcDirs" -o "$srcDirs" = " " ]; then
echo >&2 "ERROR - sonar.sources parameter is missing in sonar-project.properties. You must specify which directories contain your .swift source files (comma-separated list)."
exit 1
fi
if [ -z "$appScheme" -o "$appScheme" = " " ]; then
echo >&2 "ERROR - sonar.swift.appScheme parameter is missing in sonar-project.properties. You must specify which scheme is used to build your application."
exit 1
fi
if [ "$unittests" = "on" ]; then
if [ -z "$destinationSimulator" -o "$destinationSimulator" = " " ]; then
echo >&2 "ERROR - sonar.swift.simulator parameter is missing in sonar-project.properties. You must specify which simulator to use."
exit 1
fi
fi
# if the appConfiguration is not specified then set to Debug
if [ -z "$appConfiguration" -o "$appConfiguration" = " " ]; then
appConfiguration="Debug"
fi
if [ "$vflag" = "on" ]; then
echo "Xcode project file is: $projectFile"
echo "Xcode workspace file is: $workspaceFile"
echo "Xcode application scheme is: $appScheme"
echo "Number version from plist is: $numVerionFromPlist"
if [ -n "$unittests" ]; then
echo "Destination simulator is: $destinationSimulator"
echo "Excluded paths from coverage are: $excludedPathsFromCoverage"
else
echo "Unit surefire are disabled"
fi
fi
## SCRIPT
# Start progress indicator in the background
if [ "$vflag" = "" -a "$nflag" = "" ]; then
startProgress &
# Save PID
PROGRESS_PID=$!
fi
# Create sonar-reports/ for reports output
if [ "$vflag" = "on" ]; then
echo 'Creating directory sonar-reports/'
fi
rm -rf sonar-reports
mkdir sonar-reports
# Extracting project information needed later
echo -n 'Extracting Xcode project information'
if [[ "$workspaceFile" != "" ]] ; then
buildCmdPrefix="-workspace $workspaceFile"
else
buildCmdPrefix="-project $projectFile"
fi
buildCmd=($XCODEBUILD_CMD clean build $buildCmdPrefix -scheme $appScheme)
if [[ ! -z "$destinationSimulator" ]]; then
buildCmd+=(-destination "$destinationSimulator" -destination-timeout 360 COMPILER_INDEX_STORE_ENABLE=NO)
fi
runCommand xcodebuild.log "${buildCmd[#]}"
#oclint-xcodebuild # Transform the xcodebuild.log file into a compile_command.json file
cat xcodebuild.log | $XCPRETTY_CMD -r json-compilation-database -o compile_commands.json
# Objective-C code detection
hasObjC="no"
compileCmdFile=compile_commands.json
minimumSize=3
actualSize=$(stat -f%z "$compileCmdFile")
echo "actual = $actualSize, min = $minimumSize"
if [ $actualSize -ge $minimumSize ]; then
hasObjC="yes"
fi
# Unit surefire and coverage
if [ "$unittests" = "on" ]; then
# Put default xml files with no surefire and no coverage...
echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><testsuites name='AllTestUnits'></testsuites>" > sonar-reports/TEST-report.xml
echo "<?xml version='1.0' ?><!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'><coverage><sources></sources><packages></packages></coverage>" > sonar-reports/coverage-swift.xml
echo -n 'Running surefire'
buildCmd=($XCODEBUILD_CMD clean build test)
if [[ ! -z "$workspaceFile" ]]; then
buildCmd+=(-workspace "$workspaceFile")
elif [[ ! -z "$projectFile" ]]; then
buildCmd+=(-project "$projectFile")
fi
buildCmd+=( -scheme "$appScheme" -configuration "$appConfiguration" -enableCodeCoverage YES)
if [[ ! -z "$destinationSimulator" ]]; then
buildCmd+=(-destination "$destinationSimulator" -destination-timeout 60)
fi
runCommand sonar-reports/xcodebuild.log "${buildCmd[#]}"
cat sonar-reports/xcodebuild.log | $XCPRETTY_CMD -t --report junit
mv build/reports/junit.xml sonar-reports/TEST-report.xml
echo '\nComputing coverage report\n'
# Build the --exclude flags
excludedCommandLineFlags=""
if [ ! -z "$excludedPathsFromCoverage" -a "$excludedPathsFromCoverage" != " " ]; then
echo $excludedPathsFromCoverage | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh2
while read word; do
excludedCommandLineFlags+=" -i $word"
done < tmpFileRunSonarSh2
rm -rf tmpFileRunSonarSh2
fi
if [ "$vflag" = "on" ]; then
echo "Command line exclusion flags for slather is:$excludedCommandLineFlags"
fi
firstProject=$(echo $projectFile | sed -n 1'p' | tr ',' '\n' | head -n 1)
slatherCmd=($SLATHER_CMD coverage)
if [[ ! -z "$binaryName" ]]; then
slatherCmd+=( --binary-basename "$binaryName")
fi
slatherCmd+=( --input-format profdata $excludedCommandLineFlags --cobertura-xml --output-directory sonar-reports)
if [[ ! -z "$workspaceFile" ]]; then
slatherCmd+=( --workspace "$workspaceFile")
fi
slatherCmd+=( --scheme "$appScheme" "$firstProject")
echo "${slatherCmd[#]}"
runCommand /dev/stdout "${slatherCmd[#]}"
mv sonar-reports/cobertura.xml sonar-reports/coverage-swift.xml
fi
# SwiftLint
if [ "$swiftlint" = "on" ]; then
if hash $SWIFTLINT_CMD 2>/dev/null; then
echo -n 'Running SwiftLint...'
# Build the --include flags
currentDirectory=${PWD##*/}
echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh
while read word; do
# Run SwiftLint command
$SWIFTLINT_CMD lint --path "$word" > sonar-reports/"$appScheme"-swiftlint.txt
done < tmpFileRunSonarSh
rm -rf tmpFileRunSonarSh
else
echo "Skipping SwiftLint (not installed!)"
fi
else
echo 'Skipping SwiftLint (test purposes only!)'
fi
# Tailor
if [ "$tailor" = "on" ]; then
if hash $TAILOR_CMD 2>/dev/null; then
echo -n 'Running Tailor...'
# Build the --include flags
currentDirectory=${PWD##*/}
echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh
while read word; do
# Run tailor command
$TAILOR_CMD $tailorConfiguration "$word" > sonar-reports/"$appScheme"-tailor.txt
done < tmpFileRunSonarSh
rm -rf tmpFileRunSonarSh
else
echo "Skipping Tailor (not installed!)"
fi
else
echo 'Skipping Tailor!'
fi
if [ "$oclint" = "on" ] && [ "$hasObjC" = "yes" ]; then
echo -n 'Running OCLint...'
# Options
maxPriority=10000
longLineThreshold=250
# Build the --include flags
currentDirectory=${PWD##*/}
echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh
while read word; do
includedCommandLineFlags=" --include .*/${currentDirectory}/${word}/*"
if [ "$vflag" = "on" ]; then
echo
echo -n "Path included in oclint analysis is:$includedCommandLineFlags"
fi
# Run OCLint with the right set of compiler options
runCommand no oclint-json-compilation-database -v $includedCommandLineFlags -- -rc LONG_LINE=$longLineThreshold -max-priority-1 $maxPriority -max-priority-2 $maxPriority -max-priority-3 $maxPriority -report-type pmd -o sonar-reports/$appScheme-oclint.xml
done < tmpFileRunSonarSh
rm -rf tmpFileRunSonarSh
else
echo 'Skipping OCLint (test purposes only!)'
fi
#FauxPas
if [ "$fauxpas" = "on" ] && [ "$hasObjC" = "yes" ]; then
hash fauxpas 2>/dev/null
if [ $? -eq 0 ]; then
echo -n 'Running FauxPas...'
if [ "$projectCount" = "1" ]
then
fauxpas -o json check $projectFile --workspace $workspaceFile --scheme $appScheme > sonar-reports/fauxpas.json
else
echo $projectFile | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh
while read projectName; do
$XCODEBUILD_CMD -list -project $projectName | sed -n '/Schemes/,$p' | while read scheme
do
if [ "$scheme" = "" ]
then
exit
fi
if [ "$scheme" == "${scheme/Schemes/}" ]
then
if [ "$scheme" != "$testScheme" ]
then
projectBaseDir=$(dirname $projectName)
workspaceRelativePath=$(python -c "import os.path; print os.path.relpath('$workspaceFile', '$projectBaseDir')")
fauxpas -o json check $projectName --workspace $workspaceRelativePath --scheme $scheme > sonar-reports/$(basename $projectName .xcodeproj)-$scheme-fauxpas.json
fi
fi
done
done < tmpFileRunSonarSh
rm -rf tmpFileRunSonarSh
fi
else
echo 'Skipping FauxPas (not installed)'
fi
else
echo 'Skipping FauxPas'
fi
# Lizard Complexity
if [ "$lizard" = "on" ]; then
if hash $LIZARD_CMD 2>/dev/null; then
echo -n 'Running Lizard...'
$LIZARD_CMD --xml "$srcDirs" > sonar-reports/lizard-report.xml
else
echo 'Skipping Lizard (not installed!)'
fi
else
echo 'Skipping Lizard (test purposes only!)'
fi
# The project version from properties file
numVersionSonarRunner=''; readParameter numVersionSonarRunner 'sonar.projectVersion'
if [ -z "$numVersionSonarRunner" -o "$numVersionSonarRunner" = " " ]; then
numVersionSonarRunner=" --define sonar.projectVersion=$numVerionFromPlist"
else
#if we have version number in properties file, we don't overide numVersion for sonar-runner/sonar-scanner command
numVersionSonarRunner='';
fi
# SonarQube
if [ "$sonarscanner" = "on" ]; then
echo -n 'Running SonarQube using SonarQube Scanner'
if hash /dev/stdout sonar-scanner 2>/dev/null; then
runCommand /dev/stdout sonar-scanner $numVersionSonarRunner
else
echo 'Skipping sonar-scanner (not installed!)'
fi
else
echo -n 'Running SonarQube using SonarQube Runner'
if hash /dev/stdout sonar-runner 2>/dev/null; then
runCommand /dev/stdout sonar-runner $numVersionSonarRunner
else
runCommand /dev/stdout sonar-scanner $numVersionSonarRunner
fi
fi
# Kill progress indicator
stopProgress
exit 0
Here is the terminal output:
Running run-sonar-swift.sh...
Project count is [1]
2021-09-07 14:48:13.089 defaults[49259:620007]
The domain/default pair of (/Users/ebubekirsezer/Desktop/Projects/SonarDemo/SonarDemo/Info.plist, CFBundleShortVersionString) does not exist
Xcode project file is: SonarDemo.xcodeproj
Xcode workspace file is:
Xcode application scheme is: SonarDemo
Number version from plist is:
Destination simulator is: platform=iOS Simulator,name=iPhone 8,OS=14.5
Excluded paths from coverage are:
Creating directory sonar-reports/
Extracting Xcode project information
+ xcodebuild clean build -project SonarDemo.xcodeproj -scheme SonarDemo -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.5' -destination-timeout 360 COMPILER_INDEX_STORE_ENABLE=NO
+ returnValue=0
+ set +x
./run-sonar-swift.sh: line 291: xcpretty: command not found
stat: compile_commands.json: stat: No such file or directory
actual = , min = 3
./run-sonar-swift.sh: line 299: [: -ge: unary operator expected
Running surefire
+ xcodebuild clean build test -project SonarDemo.xcodeproj -scheme SonarDemo -configuration Debug -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.5' -destination-timeout 60
2021-09-07 14:48:26.363 xcodebuild[49322:621312] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678
Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fced2696a60>
Object: <IDETestRunSpecificationBuilder>
Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error:
Thread: <NSThread: 0x7fcf0241a660>{number = 1, name = main}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
2021-09-07 14:48:26.365 xcodebuild[49322:621312] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678
Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fceb25809f0>
Object: <IDETestRunSpecificationBuilder>
Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error:
Thread: <NSThread: 0x7fcf0241a660>{number = 1, name = main}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
2021-09-07 14:50:17.771 xcodebuild[49322:621312] [MT] IDETestOperationsObserverDebug: 110.166 elapsed -- Testing started completed.
2021-09-07 14:50:17.772 xcodebuild[49322:621312] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2021-09-07 14:50:17.772 xcodebuild[49322:621312] [MT] IDETestOperationsObserverDebug: 110.166 sec, +110.166 sec -- end
+ returnValue=0
+ set +x
./run-sonar-swift.sh: line 323: xcpretty: command not found
mv: build/reports/junit.xml: No such file or directory
\nComputing coverage report\n
Command line exclusion flags for slather is:
slather coverage --binary-basename SonarDemo --input-format profdata --cobertura-xml --output-directory sonar-reports --scheme SonarDemo SonarDemo.xcodeproj
+ slather coverage --binary-basename SonarDemo --input-format profdata --cobertura-xml --output-directory sonar-reports --scheme SonarDemo SonarDemo.xcodeproj
./run-sonar-swift.sh: line 101: slather: command not found
+ returnValue=127
+ set +x
ERROR - Command 'slather coverage --binary-basename SonarDemo --input-format profdata --cobertura-xml --output-directory sonar-reports --scheme SonarDemo SonarDemo.xcodeproj' failed with error code: 127

make dep: Nothing to be done for 'depend'

I have been trying to compile the PJSIP library for an iOS project which needs SIP. Following this tutorial, I have been able to run the configure-iphone script. The next step would to run the make dep for the dependencies, but sadly it fails bcs of some error, unknown to me. I have also tried to edit the makefile, so it points directly to the file, but I still get the error, so it can find the file.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f Samples.mak depend
make[2]: Nothing to be done for `depend'.
is the error I get.
The make file:
include ../../build.mak
include $(PJDIR)/build/common.mak
export LIBDIR := ../lib
export BINDIR := ../bin
RULES_MAK := $(PJDIR)/build/rules.mak
SAMPLES_MAK := $(PJDIR)/pjsip-apps/build/Samples.mak
###############################################################################
# Gather all flags.
#
export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
$(PJ_CFLAGS) $(CFLAGS) $(CC_INC)../../pjsip/include \
$(CC_INC)../../pjlib/include \
$(CC_INC)../../pjlib-util/include \
$(CC_INC)../../pjnath/include \
$(CC_INC)../../pjmedia/include
export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
$(HOST_CXXFLAGS) $(CXXFLAGS)
export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
$(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
###############################################################################
# Defines for building PJSUA
#
export PJSUA_SRCDIR = ../src/pjsua
export PJSUA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
main.o pjsua_app.o pjsua_app_cli.o pjsua_app_common.o \
pjsua_app_config.o pjsua_app_legacy.o
export PJSUA_CFLAGS += $(PJ_CFLAGS) $(CFLAGS)
export PJSUA_CXXFLAGS += $(PJ_CXXFLAGS) $(CFLAGS)
export PJSUA_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
export PJSUA_EXE:=pjsua-$(TARGET_NAME)$(HOST_EXE)
###############################################################################
# Defines for building pjsystest
#
export PJSYSTEST_SRCDIR = ../src/pjsystest
export PJSYSTEST_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
systest.o main_console.o
export PJSYSTEST_CFLAGS += $(PJ_CFLAGS) $(CFLAGS)
export PJSYSTEST_CXXFLAGS += $(PJ_CXXFLAGS) $(CFLAGS)
export PJSYSTEST_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
export PJSYSTEST_EXE:=pjsystest-$(TARGET_NAME)$(HOST_EXE)
export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
TARGETS := $(PJSUA_EXE) $(PJSYSTEST_EXE) samples
all: $(TARGETS)
swig:
$(MAKE) -C ../src/swig
doc:
dep: depend
distclean: realclean
.PHONY: all dep depend clean realclean distclean
.PHONY: $(TARGETS)
.PHONY: $(PJSUA_EXE) $(PJSYSTEST_EXE)
pjsua: $(PJSUA_EXE)
$(PJSUA_EXE):
$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(subst /,$(HOST_PSEP),$(BINDIR)/$#)
#if echo "$(TARGET_NAME)" | grep -q "apple-darwin_ios$$"; then \
for F in $(filter %$(TARGET_NAME).a,$(PJ_LIBXX_FILES)); do \
if test -f $$F; then \
tmp=`echo $${F##*/} | sed -e "s/\-$(TARGET_NAME)\.a/.a/"`; \
ln -sf $$F ../src/pjsua/ios/$$tmp; \
fi; \
done; \
fi;
pjsystest: $(PJSYSTEST_EXE)
$(PJSYSTEST_EXE):
$(MAKE) -f $(RULES_MAK) APP=PJSYSTEST app=pjsystest $(subst /,$(HOST_PSEP),$(BINDIR)/$#)
samples:
$(MAKE) -f $(SAMPLES_MAK)
.PHONY: pjsua.ko
pjsua.ko:
$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(subst /,$(HOST_PSEP),$(LIBDIR)/$#)
clean depend realclean:
$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $#
$(MAKE) -f $(RULES_MAK) APP=PJSYSTEST app=pjsystest $#
#Problem happens in the next row!
$(MAKE) -f $(SAMPLES_MAK) $#
#if test "$#" = "depend"; then \
echo '$(BINDIR)/$(PJSUA_EXE): $(APP_LIB_FILES)' >> .pjsua-$(TARGET_NAME).depend; \
echo '$(BINDIR)/$(PJSYSTEST_EXE): $(APP_LIB_FILES)' >> .pjsystest-$(TARGET_NAME).depend; \
fi
#if echo "$(TARGET_NAME)" | grep -q "apple-darwin_ios$$"; then \
for F in $(filter %$(TARGET_NAME).a,$(PJ_LIBXX_FILES)); do \
tmp=`echo $${F##*/} | sed -e "s/\-$(TARGET_NAME)\.a/.a/"`; \
rm -f ../src/pjsua/ios/$$tmp; \
done; \
fi;
Like I said, I added the SAMPLES_MAK variable, but sadly it didn't help. I also found out which line is giving me the error, it's close to the end of the file $(MAKE) -f $(SAMPLES_MAK) $#.
Use official documentation for building. It works 100% for all current architectures for iOS.
Usually this means you've accidentally (?) created a file or directory named depend in your working directory. So, make sees that file or directory and, since the makefile doesn't list any prerequisites of the depend target, it believe the target is up to date.
This is why generally you declare these types of helper targets to be .PHONY, but apparently that makefile doesn't do this.

Minix 3.2.1 Makefile issue

I'm trying to run make with the below Makefile and I get the following error Makefile:2: *** missing separator. Stop.. This Makefile is the original file from Minix 3.2.1. I haven't done any changes. I check from the tabs problem. Can someone help me?
Thanks.
# Makefile for the kernel image.
.include <bsd.own.mk>
.include "nbsd.config"
.include <bsd.own.mk>
.include <bsd.sys.mk>
u=/usr
MDEC= /usr/mdec
GEN_FILES= *.bak image kernel *.iso *.iso.gz cdfdimage rootimage src
# LSC detect where were built the objects files
PROGROOT:= ..
.if "${MAKEOBJDIR:S,${.CURDIR},,}" != ""
PROGROOT:= ${MAKEOBJDIR:S,releasetools,,}
.endif
# Specify the programs that are part of the system image.
KERNEL= ${PROGROOT}/kernel/kernel
# PROGRAMS are in the order they should be loaded by boot
PROGRAMS+= ${PROGROOT}/servers/ds/ds
PROGRAMS+= ${PROGROOT}/servers/rs/rs
PROGRAMS+= ${PROGROOT}/servers/pm/pm
PROGRAMS+= ${PROGROOT}/servers/sched/sched
PROGRAMS+= ${PROGROOT}/servers/vfs/vfs
PROGRAMS+= ${PROGROOT}/drivers/memory/memory
.if ${MACHINE_ARCH} == "i386"
PROGRAMS+= ${PROGROOT}/drivers/log/log
.endif
PROGRAMS+= ${PROGROOT}/drivers/tty/tty
PROGRAMS+= ${PROGROOT}/servers/mfs/mfs
PROGRAMS+= ${PROGROOT}/servers/vm/vm
PROGRAMS+= ${PROGROOT}/servers/pfs/pfs
PROGRAMS+= ${PROGROOT}/servers/init/init
usage:
#echo " " >&2
#echo "Master Makefile to create new MINIX configuration." >& 2
#echo "Root privileges are required." >&2
#echo " " >&2
#echo "Usage:" >&2
#echo " make includes # Install include files" >&2
#echo " make depend # Generate dependency files" >&2
#echo " make services # Compile and install all services" >&2
#echo " make install # Make image, and install to hard disk" >&2
#echo " make hdboot # Make image, and install to hard disk" >&2
#echo " make bootable # Make hard disk bootable" >&2
#echo " make nbsd_fetch # Download current NetBSD reference sources" >&2
#echo " make nbsd_diff # Update minix-port.patch in NetBSD sources" >&2
#echo " make clean # Remove all compiler results, except libs" >&2
#echo " " >&2
#echo "To create a fresh MINIX configuration, try:" >&2
#echo " make clean install # new boot image" >&2
#echo " make fresh install # new everything" >&2
#echo " " >&2
all: services
# rebuild the program or system libraries
includes:
$(MAKE) -C ../ includes
depend: includes .gitignore
$(MAKE) -C ../ depend
.gitignore: Makefile
echo $(GEN_FILES) | tr ' ' '\n' >.gitignore
services: includes kernel servers .WAIT drivers
kernel: includes
$(MAKE) -C ../kernel
servers: includes
$(MAKE) -C ../servers all install
drivers: includes servers
$(MAKE) -C ../drivers all install
# make bootable and place system images
bootable:
exec su root mkboot bootable ${DESTDIR}
hdboot: services .WAIT do-hdboot
do-hdboot:
#rm -rf ${DESTDIR}/boot/minix/.temp/
${INSTALL_DIR} ${DESTDIR}/boot/minix/.temp
# mod_0 is used to make alphabetical order equal to the boot order
#n=0; \
for i in ${PROGRAMS}; \
do \
n=`expr $$n + 1`; \
[ "$$n" -ge 10 ] && prefix="mod" || prefix="mod0"; \
newname="${DESTDIR}/boot/minix/.temp/$${prefix}$${n}_`basename $$i`"; \
${INSTALL} $$i $$newname; \
done
#cp ${PROGROOT}/kernel/kernel ${DESTDIR}/boot/minix/.temp/
#if [ "${MKINSTALLBOOT:Uno}" != "no" ] ; then \
${STRIP} -s ${DESTDIR}/boot/minix/.temp/* ; \
gzip ${DESTDIR}/boot/minix/.temp/mod* ; \
${HOST_SH} mkboot hdboot ${DESTDIR}; \
${HOST_SH} ../commands/update_bootcfg/update_bootcfg.sh;\
else \
${INSTALL_DIR} ${DESTDIR}/multiboot; \
${INSTALL} ${DESTDIR}/boot/minix/.temp/* ${DESTDIR}/multiboot; \
fi
install:
${MAKE} includes services hdboot
# download and update NetBSD reference sources.
nbsd_fetch:
export CVS_RSH=ssh; \
export OLDPWD=`pwd`; \
echo "retrieving hierarchies from ${NBSD_CVSROOT}"; \
IFS=,; \
cd ..; \
cat releasetools/nbsd_ports | grep -v '^#' | while read port ; \
do set $$port; \
date=$$1; minixpath=$$2; origpath=$$3; \
if [ $$# -lt 3 ]; then origpath=$$2; fi; \
echo "retrieving $$origpath .."; \
cvs -q -d ${NBSD_CVSROOT} co -N -D "$$date UTC" -d nbsdsrc "src/$$origpath" ; \
done; \
cd $${OLDPWD};
nbsd_diff:
find .. -name minix-port.patch | xargs rm
cat nbsd_ports | grep -v '^#' | \
( cd .. && awk -F, '{ minixpath=$$2; origpath=$$3; if(NF < 3) { origpath=$$2; } system("sh releasetools/nbsd_diff.sh " \
"nbsdsrc/src/"origpath" "minixpath" "minixpath"/minix-port.patch");}' )
find .. -name minix-port.patch | xargs wc -l | sort -n
# clean up compile results
clean:
$(MAKE) -C ../kernel $#
$(MAKE) -C ../servers $#
$(MAKE) -C ../drivers $#
rm -rf $(GEN_FILES)
cleandepend::
$(MAKE) -C ../kernel $#
$(MAKE) -C ../servers $#
$(MAKE) -C ../drivers $#
MINIX uses BSD make, which typically uses . to prefix its specific extensions. You installed GNU make, which has another set of extensions, not prefixed with .; furthermore you put GNU make ahead in the PATH order without renaming it. This is not going to take off.
What we usually do is to name GNU make under the name gmake or gnumake, and invoke it under that name when needed (for example, to compile packages from GNU ecosystem, or with a strong Linux bias.)
Another possibility you might consider is to install (if not already done) the bmake package, and uses that command when trying to compile programs which expect the BSD breed of make (this includes MINIX itself.)

Compiling Libical for arm64 and x86_64 for iOS

It took some time for me to compile LibiCal for arm64 and x86_64 architecture for iOS(device and simulator). Thought it may be useful for others. Here is the steps I followed to compile LibiCal-1.0. I have taken code from below link
Compiling libical
and modified a bit to suit for Xcode 5.1
1) download LibiCal from below URL
http://sourceforge.net/projects/freeassociation/
Untar and get into libCal-1.0 folder. Then run
./bootstrap
(Need to download make tools from http://www.jattcode.com/installing-autoconf-automake-libtool-on-mac-osx-mountain-lion/ )
Use below script
#!/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=arm64
# Select the desired iPhone SDK
export SDKVER="7.1"
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/usr/bin/libtool
export STRIP=$IOSROOT/Developer/usr/bin/strip
export RANLIB=$IOSROOT/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"
modify the line:11 "export ARCH=arm64" to get desired architecture, i.e. arm64, armv7, armv7s.
This should create bins for desired architecture in ../libical-build folder.
Building for x86_64.
Use following commands to run get build for x86_64.
tar -xovf libical-1.0.tar
cd libical-1.0
./bootstrap
./configure
make
This should create libical.a in folder src/libical/.libs/libical.a.
Creating a fat library
Use below command to build the fat library. (Please use appropriate lipo command).
export DEVROT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lip
$DEVROOT/usr/bin/lipo
-arch arm64 $OUTPUTDIR/armv6/libical.a
-arch i386 $OUTPUTDIR/i386/libical_Simulator.a
-arch armv7 $OUTPUTDIR/x86_64/libical.a
-arch armv7s $OUTPUTDIR/x86_64/libical.a
-arch x86_64 $OUTPUTDIR/x86_64/libical.a
-create -output $OUTPUTDIR/libical_fat_universal.a
Please set appropriate OUTPUTDIR environment variable.
I hope above will help some one who wants to quickly build Libical for iOS.
I have found a fix for the issue. The main thing I did was add the following switch
-mios-simulator-version-min=7.0
Here is my current version of the script:
#!/bin/sh
set -o xtrace
# SEE: http://www.smallsharptools.com/downloads/libical/
PATH="`xcode-select -print-path`/usr/bin:/usr/bin:/bin"
if [ ! -n "$ARCH" ]; then
export ARCH=armv7
fi
# Select the desired iPhone SDK
export SDKVER="7.1"
export DEVROOT=`xcode-select --print-path`
if [ "i386" = $ARCH ] || [ "x86_64" = $ARCH ]; then
export SDKROOT=$DEVROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk
export MIOS="-mios-simulator-version-min=7.0"
else
export SDKROOT=$DEVROOT/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk
export MIOS=""
fi;
export IOSROOT=$DEVROOT/Platforms/iPhoneOS.platform
if [ ! -d $DEVROOT ]
then
echo "Developer Root not found! - $DEVROOT"
exit 1
fi
echo "DEVROOT = $DEVROOT"
if [ ! -d $SDKROOT ]
then
echo "SDK Root not found! - $SDKROOT"
exit 1
fi
echo "SDKROOT = $SDKROOT"
if [ ! -d $IOSROOT ]
then
echo "iOS Root not found! - $IOSROOT"
exit 1
fi
echo "IOSROOT = $IOSROOT"
# Set up relevant environment variables
export CPPFLAGS="-arch $ARCH -I$SDKROOT/usr/include $MIOS --debug"
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=$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/usr/bin/libtool
export STRIP=$IOSROOT/Developer/usr/bin/strip
export RANLIB=$IOSROOT/Developer/usr/bin/ranlib
export LIPO="xcrun -sdk iphoneos lipo"
export 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 $OUTPUT_DIR/$ARCH ]
then
rm -rf $OUTPUT_DIR/$ARCH
fi
find ./src -name \*.a -exec rm {} \;
make clean
./configure --prefix="$OUTPUT_DIR" --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 $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/$ARCH
cp `find . -name \*.a` $OUTPUT_DIR/$ARCH/
cp config.log $OUTPUT_DIR/$ARCH/config.log
$LIPO -info $OUTPUT_DIR/$ARCH/*.a
echo $ARCH DONE
echo "See $OUTPUT_DIR"
I've started building out a Objective C wrapper for this library and you can see the progress at
https://github.com/ahalls/XbICalendar I the project could use some eyeballs with suggestions and even some help.
Those looking to compile the latest version of libical using cmake (from github) for iOS, please checkout my answer here:
Compiling libical for armv7 and arm64 with cmake

Resources