here's my problem: i'm building an iOS framework (named Router) that use some pods (podfile file below)
i'm using an aggregate with a script(script below) to create an universal framework (all architectures)
framework + main project are using swift 3 (we are now migrating from V2.3 to V3) and xcode 8.2.1.
When i create the framework i add it to my main project as an Embedded framework, but when i run the app i get immediately this error :
dyld: Library not loaded: @rpath/ReachabilitySwift.framework/ReachabilitySwift Referenced from: /private/var/containers/Bundle/Application/556E3EBE-83B5-4965-9328-1AA61615283A/XXXX.app/Frameworks/Router.framework/Router Reason: image not found
so as you can see the problem is in the Router framework.
i know that this is a recurrent question but i can't get this to work, thank you for your help.
[edit]: if i remove ReachabilitySwift
from pods, and add the "ReachabilitySwift" files manually all works fine, so for sure the problem is from ReachabilitySwift framework built by cocoapods.
Podfile file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.0"
use_frameworks!
inhibit_all_warnings!
#target 'Router' do
target :'Router', :exclusive => true do link_with ['Target1']
pod 'ReachabilitySwift'
pod 'Alamofire'
pod 'KeychainAccess'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
end
target 'RouterTests' do
end
aggregate script:
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
STAR_PATH="*"
#MUST_CLEAN=true
MUST_CLEAN=false
CLEAN_BUILD=""
if [ ${MUST_CLEAN} = true ]; then
CLEAN_BUILD="clean build"
fi
CONFIGURATION_IS_RELEASE=false
if [ "${CONFIGURATION}" = "Release" ]; then
CONFIGURATION_IS_RELEASE=true
fi
CONFIGURATION_IS_RELEASE=true ### We force configuration to be Release
REVEAL_ARCHIVE_IN_FINDER=true
FRAMEWORK_NAME="${PROJECT_NAME}"
FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework"
WORKSPACE_NAME="Router.xcworkspace"
#WORKSPACE_PATH="../${WORKSPACE_NAME}"
WORKSPACE_PATH="${WORKSPACE_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_DIR}"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_DIR}"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_DIR}"
if [ ${CONFIGURATION_IS_RELEASE} = true ]; then
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/Release-iphonesimulator/${FRAMEWORK_DIR}"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/Release-iphoneos/${FRAMEWORK_DIR}"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/Release-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_DIR}"
fi
# 3
# If remnants from a previous build exist, delete them.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
# 4
# Build the framework for device and for simulator (using
# all needed architectures).
#### Current Configuration Build (if different than Release)
if [ ${CONFIGURATION_IS_RELEASE} = false ]; then
xcodebuild -workspace ${WORKSPACE_PATH} -scheme ${PROJECT_NAME} -sdk "iphonesimulator" -configuration ${CONFIGURATION} ${CLEAN_BUILD} CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 2>&1
xcodebuild -workspace ${WORKSPACE_PATH} -scheme ${PROJECT_NAME} -sdk "iphoneos" -configuration ${CONFIGURATION} ${CLEAN_BUILD} CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos 2>&1
fi
#### Release Build (Simulator)
xcodebuild -workspace ${WORKSPACE_PATH} -scheme ${PROJECT_NAME} -sdk "iphonesimulator" -configuration Release ${CLEAN_BUILD} -arch x86_64 -arch i386 only_active_arch=no defines_module=yes
#### Release Build (Device)
xcodebuild -workspace ${WORKSPACE_PATH} -scheme ${PROJECT_NAME} -sdk "iphoneos" -configuration Release ${CLEAN_BUILD} -arch arm64 -arch armv7 -arch armv7s only_active_arch=no defines_module=yes
#exit;
# 5
# Remove .framework file if exists on Desktop from previous run.
rm -rf "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
# 6
# Copy the device version of framework.
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
# 7
# Replace the framework executable within the framework with
# a new version created by merging the device and simulator
# frameworks' executables with lipo.
lipo -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}"
# 8
# Copy the Swift module mappings for the simulator into the
# framework. The device mappings already exist from step 6.
# For Swift framework, Swiftmodule needs to be copied in the universal framework
if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/${STAR_PATH} "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
fi
#if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
# cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
#fi
# 9
# Delete the most recent build.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
######################
# On Release, copy the result to release directory
######################
OUTPUT_DIR="${PROJECT_DIR}/Output/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
if [ ${CONFIGURATION_IS_RELEASE} = true ]; then
OUTPUT_DIR="${HOME}/Desktop"
rm -rf "${OUTPUT_DIR}/${FRAMEWORK_DIR}"
else
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
fi
cp -r "${FRAMEWORK}" "$OUTPUT_DIR"
# 10
# Convenience step
if [ ${REVEAL_ARCHIVE_IN_FINDER} = true ]; then
open "${OUTPUT_DIR}/"
fi