Updated LibSession to be sourced via Swift Package Manager

• Using a pre-built version of libSession as a SPM dependency for default builds
• Added a new scheme which will try to build libSession from source (update the `LIB_SESSION_SOURCE_DIR` User-Defined build setting to change the location - currently set to '${SRC_ROOT}/../LibSession-Util')
• Removed the libSession submodule
pull/1061/head
Morgan Pretty 7 months ago
parent c5086981b9
commit 04b3a64f6b

3
.gitmodules vendored

@ -1,3 +0,0 @@
[submodule "LibSession-Util"]
path = LibSession-Util
url = https://github.com/session-foundation/libsession-util.git

@ -1 +0,0 @@
Subproject commit 20d7275ba52b044cf144da71cf6141c3987680dc

@ -1,39 +1,62 @@
#!/bin/bash
# XCode will error during it's dependency graph construction (which happens before the build
# stage starts and any target "Run Script" phases are triggered)
#
# In order to avoid this error we need to build the framework before actually getting to the
# build stage so XCode is able to build the dependency graph
#
# XCode's Pre-action scripts don't output anything into XCode so the only way to emit a useful
# error is to **return a success status** and have the project detect and log the error itself
# then log it, stopping the build at that point
#
# The other step to get this to work properly is to ensure the framework in "Link Binary with
# Libraries" isn't using a relative directory, unfortunately there doesn't seem to be a good
# way to do this directly so we need to modify the '.pbxproj' file directly, updating the
# framework entry to have the following (on a single line):
# {
# isa = PBXFileReference;
# explicitFileType = wrapper.xcframework;
# includeInIndex = 0;
# path = "{FRAMEWORK NAME GOES HERE}";
# sourceTree = BUILD_DIR;
# };
#
# Note: We might one day be able to replace this with a local podspec if this GitHub feature
# request ever gets implemented: https://github.com/CocoaPods/CocoaPods/issues/8464
# Need to set the path or we won't find cmake
PATH=${PATH}:/usr/local/bin:/opt/local/bin:/opt/homebrew/bin:/opt/homebrew/opt/m4/bin:/sbin/md5
required_packages=("cmake" "m4" "pkg-config")
DERIVED_DATA_PATH=$(echo "${BUILD_DIR}" | sed -n 's/\(.*DerivedData\/[^\/]*\).*/\1/p')
PRE_BUILT_FRAMEWORK_DIR="${DERIVED_DATA_PATH}/SourcePackages/artifacts/libsession-util/SessionUtil"
FRAMEWORK_DIR="libsession-util.xcframework"
exec 3>&1 # Save original stdout
# Ensure the build directory exists (in case we need it before XCode creates it)
mkdir -p "${TARGET_BUILD_DIR}/libSessionUtil"
# Determine whether we want to build from source
TARGET_ARCH_DIR=""
if [ -z $PLATFORM_NAME ] || [ $PLATFORM_NAME = "iphonesimulator" ]; then
TARGET_ARCH_DIR="ios-arm64_x86_64-simulator"
elif [ $PLATFORM_NAME = "iphoneos" ]; then
TARGET_ARCH_DIR="ios-arm64"
else
echo "error: Unable to find pre-packaged library for the current platform ($PLATFORM_NAME)."
exit 1
fi
if [ "${COMPILE_LIB_SESSION}" != "YES" ]; then
STATIC_LIB_PATH="${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}/${TARGET_ARCH_DIR}/libsession-util.a"
if [ ! -f "${STATIC_LIB_PATH}" ]; then
echo "error: Pre-packaged library doesn't exist in the expected location: ${STATIC_LIB_PATH}."
exit 1
fi
# If we'd replaced the framework with our compiled version then change it back
if [ -d "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}_Old" ]; then
rm -rf "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}"
mv "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}_Old" "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}"
fi
# If we previously built from source then we should copy the pre-built package across
# just to make sure we don't unintentionally use the wrong build
if [ -d "${TARGET_BUILD_DIR}/LibSessionUtil" ]; then
echo "Removing old compiled build data"
if [ -d "${TARGET_BUILD_DIR}/include" ]; then
rm -r "${TARGET_BUILD_DIR}/include"
fi
if [ -f "${TARGET_BUILD_DIR}/libsession-util.a" ]; then
rm -r "${TARGET_BUILD_DIR}/libsession-util.a"
fi
cp "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}/${TARGET_ARCH_DIR}/libsession-util.a" "${TARGET_BUILD_DIR}/libsession-util.a"
cp -r "${PRE_BUILT_FRAMEWORK_DIR}/${FRAMEWORK_DIR}/${TARGET_ARCH_DIR}/Headers" "${TARGET_BUILD_DIR}"
fi
echo "Using pre-packaged SessionUtil"
exit 0
fi
# Ensure the machine has the build dependencies installed
echo "Validating build requirements"
missing_packages=()
@ -50,180 +73,195 @@ if [ ${#missing_packages[@]} -ne 0 ]; then
fi
# Ensure the build directory exists (in case we need it before XCode creates it)
mkdir -p "${TARGET_BUILD_DIR}"
COMPILE_DIR="${TARGET_BUILD_DIR}/LibSessionUtil"
mkdir -p "${COMPILE_DIR}"
# Check if we have the `LibSession-Util` submodule checked out and if not (depending on the 'SHOULD_AUTO_INIT_SUBMODULES' argument) perform the checkout
if [ ! -d "${SRCROOT}/LibSession-Util" ] || [ ! -d "${SRCROOT}/LibSession-Util/src" ] || [ ! "$(ls -A "${SRCROOT}/LibSession-Util")" ]; then
echo "error: Need to fetch LibSession-Util submodule (git submodule update --init --recursive)."
exit 0
else
are_submodules_valid() {
local PARENT_PATH=$1
local RELATIVE_PATH=$2
# Change into the path to check for it's submodules
cd "${PARENT_PATH}"
local SUB_MODULE_PATHS=($(git config --file .gitmodules --get-regexp path | awk '{ print $2 }'))
# If there are no submodules then return success based on whether the folder has any content
if [ ${#SUB_MODULE_PATHS[@]} -eq 0 ]; then
if [[ ! -z "$(ls -A "${PARENT_PATH}")" ]]; then
return 0
else
return 1
fi
if [ ! -d "${LIB_SESSION_SOURCE_DIR}" ] || [ ! -d "${LIB_SESSION_SOURCE_DIR}/src" ]; then
echo "error: Could not find LibSession source in 'LIB_SESSION_SOURCE_DIR' directory: ${LIB_SESSION_SOURCE_DIR}."
exit 1
fi
# Validate the submodules in 'LIB_SESSION_SOURCE_DIR'
are_submodules_valid() {
local PARENT_PATH=$1
# Change into the path to check for it's submodules
cd "${PARENT_PATH}"
local SUB_MODULE_PATHS=($(git config --file .gitmodules --get-regexp path | awk '{ print $2 }'))
# If there are no submodules then return success based on whether the folder has any content
if [ ${#SUB_MODULE_PATHS[@]} -eq 0 ]; then
if [[ ! -z "$(ls -A "${PARENT_PATH}")" ]]; then
return 0
else
return 1
fi
fi
# Loop through the child submodules and check if they are valid
for i in "${!SUB_MODULE_PATHS[@]}"; do
local CHILD_PATH="${SUB_MODULE_PATHS[$i]}"
# If the child path doesn't exist then it's invalid
if [ ! -d "${PARENT_PATH}/${CHILD_PATH}" ]; then
echo "Submodule '${RELATIVE_PATH}/${CHILD_PATH}' doesn't exist."
return 1
fi
# Loop through the child submodules and check if they are valid
for i in "${!SUB_MODULE_PATHS[@]}"; do
local CHILD_PATH="${SUB_MODULE_PATHS[$i]}"
# If the child path doesn't exist then it's invalid
if [ ! -d "${PARENT_PATH}/${CHILD_PATH}" ]; then
echo "Submodule '${CHILD_PATH}' doesn't exist."
return 1
fi
are_submodules_valid "${PARENT_PATH}/${CHILD_PATH}" "${RELATIVE_PATH}/${CHILD_PATH}"
local RESULT=$?
are_submodules_valid "${PARENT_PATH}/${CHILD_PATH}"
local RESULT=$?
if [ "${RESULT}" -eq 1 ]; then
echo "Submodule '${RELATIVE_PATH}/${CHILD_PATH}' is in an invalid state."
return 1
fi
done
if [ "${RESULT}" -eq 1 ]; then
echo "Submodule '${CHILD_PATH}' is in an invalid state."
return 1
fi
done
return 0
}
return 0
}
# Validate the state of the submodules
are_submodules_valid "${SRCROOT}/LibSession-Util" "LibSession-Util"
# Validate the state of the submodules
are_submodules_valid "${LIB_SESSION_SOURCE_DIR}" "LibSession-Util"
HAS_INVALID_SUBMODULE=$?
HAS_INVALID_SUBMODULE=$?
if [ "${HAS_INVALID_SUBMODULE}" -eq 1 ]; then
echo "error: Submodules are in an invalid state, please delete 'LibSession-Util' and run 'git submodule update --init --recursive'."
exit 0
fi
if [ "${HAS_INVALID_SUBMODULE}" -eq 1 ]; then
echo "error: Submodules are in an invalid state, please run 'git submodule update --init --recursive' in ${LIB_SESSION_SOURCE_DIR}."
exit 1
fi
# Generate a hash of the libSession-util source files and check if they differ from the last hash
echo "Checking for changes to source"
NEW_SOURCE_HASH=$(find "${SRCROOT}/LibSession-Util/src" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
NEW_HEADER_HASH=$(find "${SRCROOT}/LibSession-Util/include" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
NEW_EXTERNAL_HASH=$(find "${SRCROOT}/LibSession-Util/external" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
NEW_SOURCE_HASH=$(find "${LIB_SESSION_SOURCE_DIR}/src" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
NEW_HEADER_HASH=$(find "${LIB_SESSION_SOURCE_DIR}/include" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
NEW_EXTERNAL_HASH=$(find "${LIB_SESSION_SOURCE_DIR}/external" -type f -exec md5 {} + | awk '{print $NF}' | sort | md5 | awk '{print $NF}')
if [ -f "${COMPILE_DIR}/libsession_util_source_dir.log" ]; then
read -r OLD_SOURCE_DIR < "${COMPILE_DIR}/libsession_util_source_dir.log"
fi
if [ -f "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_source_hash.log" ]; then
read -r OLD_SOURCE_HASH < "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_source_hash.log"
if [ -f "${COMPILE_DIR}/libsession_util_source_hash.log" ]; then
read -r OLD_SOURCE_HASH < "${COMPILE_DIR}/libsession_util_source_hash.log"
fi
if [ -f "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_header_hash.log" ]; then
read -r OLD_HEADER_HASH < "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_header_hash.log"
if [ -f "${COMPILE_DIR}/libsession_util_header_hash.log" ]; then
read -r OLD_HEADER_HASH < "${COMPILE_DIR}/libsession_util_header_hash.log"
fi
if [ -f "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_external_hash.log" ]; then
read -r OLD_EXTERNAL_HASH < "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_external_hash.log"
if [ -f "${COMPILE_DIR}/libsession_util_external_hash.log" ]; then
read -r OLD_EXTERNAL_HASH < "${COMPILE_DIR}/libsession_util_external_hash.log"
fi
if [ -f "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_archs.log" ]; then
read -r OLD_ARCHS < "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_archs.log"
if [ -f "${COMPILE_DIR}/libsession_util_archs.log" ]; then
read -r OLD_ARCHS < "${COMPILE_DIR}/libsession_util_archs.log"
fi
# Check the current state of the build (comparing hashes to determine if there was a source change)
if [ "${NEW_SOURCE_HASH}" != "${OLD_SOURCE_HASH}" ]; then
echo "Build is not up-to-date (source change) - creating new build"
REQUIRES_BUILD=0
if [ "${LIB_SESSION_SOURCE_DIR}" != "${OLD_SOURCE_DIR}" ]; then
echo "Build is not up-to-date (source dir change) - removing old build and rebuilding"
rm -rf "${COMPILE_DIR}"
REQUIRES_BUILD=1
elif [ "${NEW_SOURCE_HASH}" != "${OLD_SOURCE_HASH}" ]; then
echo "Build is not up-to-date (source change) - creating new build"
REQUIRES_BUILD=1
elif [ "${NEW_HEADER_HASH}" != "${OLD_HEADER_HASH}" ]; then
echo "Build is not up-to-date (header change) - creating new build"
echo "Build is not up-to-date (header change) - creating new build"
REQUIRES_BUILD=1
elif [ "${NEW_EXTERNAL_HASH}" != "${OLD_EXTERNAL_HASH}" ]; then
echo "Build is not up-to-date (external lib change) - creating new build"
echo "Build is not up-to-date (external lib change) - creating new build"
REQUIRES_BUILD=1
elif [ "${ARCHS[*]}" != "${OLD_ARCHS}" ]; then
echo "Build is not up-to-date (build architectures changed) - creating new build"
elif [ ! -f "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a" ]; then
echo "Build is not up-to-date (no static lib) - creating new build"
echo "Build is not up-to-date (build architectures changed) - creating new build"
REQUIRES_BUILD=1
elif [ ! -f "${COMPILE_DIR}/libsession-util.a" ]; then
echo "Build is not up-to-date (no static lib) - creating new build"
REQUIRES_BUILD=1
else
echo "Build is up-to-date"
exit 0
echo "Build is up-to-date"
fi
# Import settings from XCode (defaulting values if not present)
VALID_SIM_ARCHS=(arm64 x86_64)
VALID_DEVICE_ARCHS=(arm64)
VALID_SIM_ARCH_PLATFORMS=(SIMULATORARM64 SIMULATOR64)
VALID_DEVICE_ARCH_PLATFORMS=(OS64)
if [ "${REQUIRES_BUILD}" == 1 ]; then
# Import settings from XCode (defaulting values if not present)
VALID_SIM_ARCHS=(arm64 x86_64)
VALID_DEVICE_ARCHS=(arm64)
VALID_SIM_ARCH_PLATFORMS=(SIMULATORARM64 SIMULATOR64)
VALID_DEVICE_ARCH_PLATFORMS=(OS64)
OUTPUT_DIR="${TARGET_BUILD_DIR}"
IPHONEOS_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET}
ENABLE_BITCODE=${ENABLE_BITCODE}
OUTPUT_DIR="${TARGET_BUILD_DIR}"
IPHONEOS_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET}
ENABLE_BITCODE=${ENABLE_BITCODE}
# Generate the target architectures we want to build for
TARGET_ARCHS=()
TARGET_PLATFORMS=()
TARGET_SIM_ARCHS=()
TARGET_DEVICE_ARCHS=()
# Generate the target architectures we want to build for
TARGET_ARCHS=()
TARGET_PLATFORMS=()
TARGET_SIM_ARCHS=()
TARGET_DEVICE_ARCHS=()
if [ -z $PLATFORM_NAME ] || [ $PLATFORM_NAME = "iphonesimulator" ]; then
if [ -z $PLATFORM_NAME ] || [ $PLATFORM_NAME = "iphonesimulator" ]; then
for i in "${!VALID_SIM_ARCHS[@]}"; do
ARCH="${VALID_SIM_ARCHS[$i]}"
ARCH_PLATFORM="${VALID_SIM_ARCH_PLATFORMS[$i]}"
ARCH="${VALID_SIM_ARCHS[$i]}"
ARCH_PLATFORM="${VALID_SIM_ARCH_PLATFORMS[$i]}"
if [[ " ${ARCHS[*]} " =~ " ${ARCH} " ]]; then
TARGET_ARCHS+=("sim-${ARCH}")
TARGET_PLATFORMS+=("${ARCH_PLATFORM}")
TARGET_SIM_ARCHS+=("sim-${ARCH}")
fi
if [[ " ${ARCHS[*]} " =~ " ${ARCH} " ]]; then
TARGET_ARCHS+=("sim-${ARCH}")
TARGET_PLATFORMS+=("${ARCH_PLATFORM}")
TARGET_SIM_ARCHS+=("sim-${ARCH}")
fi
done
fi
fi
if [ -z $PLATFORM_NAME ] || [ $PLATFORM_NAME = "iphoneos" ]; then
if [ -z $PLATFORM_NAME ] || [ $PLATFORM_NAME = "iphoneos" ]; then
for i in "${!VALID_DEVICE_ARCHS[@]}"; do
ARCH="${VALID_DEVICE_ARCHS[$i]}"
ARCH_PLATFORM="${VALID_DEVICE_ARCH_PLATFORMS[$i]}"
ARCH="${VALID_DEVICE_ARCHS[$i]}"
ARCH_PLATFORM="${VALID_DEVICE_ARCH_PLATFORMS[$i]}"
if [[ " ${ARCHS[*]} " =~ " ${ARCH} " ]]; then
TARGET_ARCHS+=("ios-${ARCH}")
TARGET_PLATFORMS+=("${ARCH_PLATFORM}")
TARGET_DEVICE_ARCHS+=("ios-${ARCH}")
fi
if [[ " ${ARCHS[*]} " =~ " ${ARCH} " ]]; then
TARGET_ARCHS+=("ios-${ARCH}")
TARGET_PLATFORMS+=("${ARCH_PLATFORM}")
TARGET_DEVICE_ARCHS+=("ios-${ARCH}")
fi
done
fi
fi
# Remove any old build logs (since we are doing a new build)
rm -rf "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_output.log"
# Remove any old build logs (since we are doing a new build)
rm -rf "${COMPILE_DIR}/libsession_util_output.log"
touch "${COMPILE_DIR}/libsession_util_output.log"
echo "CMake build logs: ${COMPILE_DIR}/libsession_util_output.log"
submodule_check=ON
build_type="Release"
submodule_check=ON
build_type="Release"
if [ "$CONFIGURATION" == "Debug" ]; then
if [ "$CONFIGURATION" == "Debug" ]; then
submodule_check=OFF
build_type="Debug"
fi
echo "CMake build logs: ${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_output.log"
fi
# Build the individual architectures
for i in "${!TARGET_ARCHS[@]}"; do
build="${TARGET_BUILD_DIR}/libSessionUtil/${TARGET_ARCHS[$i]}"
# Build the individual architectures
for i in "${!TARGET_ARCHS[@]}"; do
build="${COMPILE_DIR}/${TARGET_ARCHS[$i]}"
platform="${TARGET_PLATFORMS[$i]}"
log_file="${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_output.log"
log_file="${COMPILE_DIR}/libsession_util_output.log"
echo "Building ${TARGET_ARCHS[$i]} for $platform in $build"
# Redirect the build output to a log file and only include the progress lines in the XCode output
exec > >(tee "$log_file" | grep --line-buffered '^\[.*%\]') 2>&1
cd "${SRCROOT}/LibSession-Util"
cd "${LIB_SESSION_SOURCE_DIR}"
env -i PATH="$PATH" SDKROOT="$(xcrun --sdk macosx --show-sdk-path)" \
./utils/static-bundle.sh "$build" "" \
-DCMAKE_TOOLCHAIN_FILE="${SRCROOT}/LibSession-Util/external/ios-cmake/ios.toolchain.cmake" \
-DPLATFORM=$platform \
-DDEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-DENABLE_BITCODE=$ENABLE_BITCODE \
-DBUILD_TESTS=OFF \
-DBUILD_STATIC_DEPS=ON \
-DENABLE_VISIBILITY=ON \
-DSUBMODULE_CHECK=$submodule_check \
-DCMAKE_BUILD_TYPE=$build_type \
-DLOCAL_MIRROR=https://oxen.rocks/deps
./utils/static-bundle.sh "$build" "" \
-DCMAKE_TOOLCHAIN_FILE="${LIB_SESSION_SOURCE_DIR}/external/ios-cmake/ios.toolchain.cmake" \
-DPLATFORM=$platform \
-DDEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-DENABLE_BITCODE=$ENABLE_BITCODE \
-DBUILD_TESTS=OFF \
-DBUILD_STATIC_DEPS=ON \
-DENABLE_VISIBILITY=ON \
-DSUBMODULE_CHECK=$submodule_check \
-DCMAKE_BUILD_TYPE=$build_type \
-DLOCAL_MIRROR=https://oxen.rocks/deps
# Capture the exit status of the ./utils/static-bundle.sh command
EXIT_STATUS=$?
@ -272,52 +310,66 @@ for i in "${!TARGET_ARCHS[@]}"; do
done
exit 1
fi
done
done
# Remove the old static library file
rm -rf "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a"
rm -rf "${TARGET_BUILD_DIR}/libSessionUtil/Headers"
# Remove the old static library file
rm -rf "${COMPILE_DIR}/libsession-util.a"
rm -rf "${COMPILE_DIR}/Headers"
# If needed combine simulator builds into a multi-arch lib
if [ "${#TARGET_SIM_ARCHS[@]}" -eq "1" ]; then
# If needed combine simulator builds into a multi-arch lib
if [ "${#TARGET_SIM_ARCHS[@]}" -eq "1" ]; then
# Single device build
cp "${TARGET_BUILD_DIR}/libSessionUtil/${TARGET_SIM_ARCHS[0]}/libsession-util.a" "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a"
elif [ "${#TARGET_SIM_ARCHS[@]}" -gt "1" ]; then
cp "${COMPILE_DIR}/${TARGET_SIM_ARCHS[0]}/libsession-util.a" "${COMPILE_DIR}/libsession-util.a"
elif [ "${#TARGET_SIM_ARCHS[@]}" -gt "1" ]; then
# Combine multiple device builds into a multi-arch lib
echo "Built multiple architectures, merging into single static library"
lipo -create "${TARGET_BUILD_DIR}/libSessionUtil"/sim-*/libsession-util.a -output "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a"
fi
lipo -create "${COMPILE_DIR}"/sim-*/libsession-util.a -output "${COMPILE_DIR}/libsession-util.a"
fi
# If needed combine device builds into a multi-arch lib
if [ "${#TARGET_DEVICE_ARCHS[@]}" -eq "1" ]; then
cp "${TARGET_BUILD_DIR}/libSessionUtil/${TARGET_DEVICE_ARCHS[0]}/libsession-util.a" "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a"
elif [ "${#TARGET_DEVICE_ARCHS[@]}" -gt "1" ]; then
# If needed combine device builds into a multi-arch lib
if [ "${#TARGET_DEVICE_ARCHS[@]}" -eq "1" ]; then
cp "${COMPILE_DIR}/${TARGET_DEVICE_ARCHS[0]}/libsession-util.a" "${COMPILE_DIR}/libsession-util.a"
elif [ "${#TARGET_DEVICE_ARCHS[@]}" -gt "1" ]; then
# Combine multiple device builds into a multi-arch lib
echo "Built multiple architectures, merging into single static library"
lipo -create "${TARGET_BUILD_DIR}/libSessionUtil"/ios-*/libsession-util.a -output "${TARGET_BUILD_DIR}/libSessionUtil/libSessionUtil.a"
lipo -create "${COMPILE_DIR}"/ios-*/libsession-util.a -output "${COMPILE_DIR}/libsession-util.a"
fi
# Save the updated build info to disk to prevent rebuilds when there were no changes
echo "${LIB_SESSION_SOURCE_DIR}" > "${COMPILE_DIR}/libsession_util_source_dir.log"
echo "${NEW_SOURCE_HASH}" > "${COMPILE_DIR}/libsession_util_source_hash.log"
echo "${NEW_HEADER_HASH}" > "${COMPILE_DIR}/libsession_util_header_hash.log"
echo "${NEW_EXTERNAL_HASH}" > "${COMPILE_DIR}/libsession_util_external_hash.log"
echo "${ARCHS[*]}" > "${COMPILE_DIR}/libsession_util_archs.log"
# Copy the headers across
echo "Copy headers"
mkdir -p "${COMPILE_DIR}/Headers"
cp -r "${LIB_SESSION_SOURCE_DIR}/include/session" "${COMPILE_DIR}/Headers"
echo "Build complete"
fi
# Save the updated hashes to disk to prevent rebuilds when there were no changes
echo "${NEW_SOURCE_HASH}" > "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_source_hash.log"
echo "${NEW_HEADER_HASH}" > "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_header_hash.log"
echo "${NEW_EXTERNAL_HASH}" > "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_external_hash.log"
echo "${ARCHS[*]}" > "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_archs.log"
echo "Build complete"
# Remove any previous versions (in case there is a discrepancy anywhere
rm -rf "${BUILT_PRODUCTS_DIR}/include"
rm -rf "${BUILT_PRODUCTS_DIR}/libsession-util.a"
# Copy the headers across
echo "Copy headers and prepare modulemap"
mkdir -p "${TARGET_BUILD_DIR}/libSessionUtil/Headers"
cp -r "${SRCROOT}/LibSession-Util/include/session" "${TARGET_BUILD_DIR}/libSessionUtil/Headers"
cp -r "${COMPILE_DIR}/Headers" "${BUILT_PRODUCTS_DIR}/include"
cp "${COMPILE_DIR}/libsession-util.a" "${BUILT_PRODUCTS_DIR}"
# The 'module.modulemap' is needed for XCode to be able to find the headers
modmap="${TARGET_BUILD_DIR}/libSessionUtil/Headers/module.modulemap"
# Generate the 'module.modulemap' (needed for XCode to be able to find the headers)
#
# Note: We do this last and don't include the `COMPILE_DIR` because, if we do, Xcode
# sees both files and considers the module redefined
echo "Generate modulemap"
modmap="${BUILT_PRODUCTS_DIR}/include/module.modulemap"
echo "module SessionUtil {" >"$modmap"
echo " module capi {" >>"$modmap"
for x in $(cd "${TARGET_BUILD_DIR}/libSessionUtil/Headers" && find session -name '*.h'); do
echo " header \"$x\"" >>"$modmap"
for x in $(cd "${COMPILE_DIR}/Headers" && find session -name '*.h'); do
echo " header \"$x\"" >>"$modmap"
done
echo -e " export *\n }" >>"$modmap"
echo "}" >>"$modmap"
# Output to XCode just so the output is good
echo "libSession is Ready"
echo "LibSession is Ready"

File diff suppressed because it is too large Load Diff

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&#10;">
</ActionContent>
</ExecutionAction>
</PreActions>
<PostActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&#10;">
</ActionContent>
</ExecutionAction>
</PostActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
BuildableName = "Session.app"
BlueprintName = "Session"
ReferencedContainer = "container:Session.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug_Compile_LibSession"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug_Compile_LibSession"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
BuildableName = "Session.app"
BlueprintName = "Session"
ReferencedContainer = "container:Session.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "IDEPreferLogStreaming"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "App_Store_Release_Compile_LibSession"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
BuildableName = "Session.app"
BlueprintName = "Session"
ReferencedContainer = "container:Session.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug_Compile_LibSession">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "App_Store_Release_Compile_LibSession"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -3,7 +3,6 @@
// stringlint:disable
import Foundation
import SessionUtil
// MARK: - String

Loading…
Cancel
Save