这是我的问题: 我正在构建一个使用一些pod(下面的podfile文件)的iOS框架(名为Router)
我正在使用带有脚本的聚合(下面的脚本)来创建通用框架(所有架构)
框架+主项目正在使用swift 3(我们现在从V2.3迁移到V3)和xcode 8.2.1。
当我创建框架时,我将其作为嵌入式框架添加到我的主项目中,但是当我运行应用程序时,我立即得到此错误:
dyld:未加载库: @ rpath / ReachabilitySwift.framework / ReachabilitySwift参考 从: /private/var/containers/Bundle/Application/556E3EBE-83B5-4965-9328-1AA61615283A/XXXX.app/Frameworks/Router.framework/Router 原因:未找到图像
因此您可以看到问题出在Router框架中。
我知道这是一个经常出现的问题,但我无法让这个工作,谢谢你的帮助。
[edit]:如果我从pod中删除ReachabilitySwift
,并手动添加“ReachabilitySwift”文件一切正常,那么问题肯定来自cocoapods构建的ReachabilitySwift框架。
Podfile文件:
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
汇总脚本:
# 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