Flutter_Library not loaded: @rpath/App.framework/App
问题描述
更新了FlutterSDK,模拟器运行无问题,真机运行崩溃
报错结果如下:
dyld[15588]: Library not loaded: @rpath/App.framework/AppReferenced from:
/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/MerchantReason: tried:
'/usr/lib/swift/App.framework/App' (no such file),
'/usr/lib/swift/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/usr/lib/swift/App.framework/App' (no such file),
'/usr/lib/swift/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/private/var/containers/Bundle/Application/42B64C9D-DDC4-4DF3-9287-068E4EE2EBDB/Merchant.app/Frameworks/App.framework/App' (no such file),
'/System/Library/Frameworks/App.framework/App' (no such file)
原因分析:
经过排查,发现是Flutter的App.framework没有导入
解决方案1:
打开 Pods-xx-frameworks.sh,然后添加以下代码
install_framework "${PODS_ROOT}/../merchant_flutter/.ios/Flutter/App.framework"
-
../merchant_flutter这段路径可以复制Podfile内flutter_application_path值 -
xx:工程名称
-
参考链接
-
此种解决方式存在弊端:每次工程进行
pod install以后Pods-xx-frameworks.sh文件将会被重置,添加的代码会被删除。可以采用解决方案2
解决方案2:
- 打开
TARGETS->Build Phases->+->New Run Script Phase - 添加指令
install_framework()
{if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; thenlocal source="${BUILT_PRODUCTS_DIR}/$1"elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; thenlocal source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"elif [ -r "$1" ]; thenlocal source="$1"filocal destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"if [ -L "${source}" ]; thenecho "Symlinked..."source="$(readlink "${source}")"fiif [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then# Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copiedfind "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; doecho "Installing $f"install_bcsymbolmap "$f" "$destination"rm "$f"donermdir "${source}/${BCSYMBOLMAP_DIR}"fi# Use filter instead of exclude so missing patterns don't throw errors.echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"local basenamebasename="$(basename -s .framework "$1")"binary="${destination}/${basename}.framework/${basename}"if ! [ -r "$binary" ]; thenbinary="${destination}/${basename}"elif [ -L "${binary}" ]; thenecho "Destination binary is symlinked..."dirname="$(dirname "${binary}")"binary="${dirname}/$(readlink "${binary}")"fi# Strip invalid architectures so "fat" simulator / device frameworks work on deviceif [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; thenstrip_invalid_archs "$binary"fi# Resign the code if required by the build settings to avoid unstable appscode_sign_if_enabled "${destination}/$(basename "$1")"# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; thenlocal swift_runtime_libsswift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u)for lib in $swift_runtime_libs; doecho "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"code_sign_if_enabled "${destination}/${lib}"donefi
}install_framework "../merchant_flutter/.ios/Flutter/App.framework"
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
