Swift包加载失败,出现dyld[11588]: 未加载的库:@rpath/libinference_engine.dylib错误

移动开发 2026-07-08

我在尝试使用LeapSDK iOS Swift SDK,在设备上运行Leap。我的应用正在构建,但运行时出现了以下错误:

Library not loaded: @rpath/libinference_engine.dylib
  Referenced from: <B297B50F-C1AB-333F-A7BE-DF002AA2DCB3> /private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/LeapSDK
  Reason: tried: '/usr/lib/system/introspection/libinference_engine.dylib' (no such file, not in dyld cache), '/usr/lib/swift/libinference_engine.dylib' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/libinference_engine.dylib' (no such file), '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/libinference_engine.dylib' (no such file), '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/Frameworks/libinference_engine.dylib' (code signature invalid in <68BDF178-BCF6-304F-BC96-2409A199131A> '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/Frameworks/libin
dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/usr/lib/libViewDebuggerSupport.dylib
Library not loaded: @rpath/libinference_engine.dylib
  Referenced from: <B297B50F-C1AB-333F-A7BE-DF002AA2DCB3> /private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/LeapSDK
  Reason: tried: '/usr/lib/system/introspection/libinference_engine.dylib' (no such file, not in dyld cache), '/usr/lib/swift/libinference_engine.dylib' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/libinference_engine.dylib' (no such file), '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/libinference_engine.dylib' (no such file), '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/Frameworks/libinference_engine.dylib' (code signature invalid in <68BDF178-BCF6-304F-BC96-2409A199131A> '/private/var/containers/Bundle/Application/C73AB24E-5E9B-4765-83EC-8493F6E98C28/MemoIt.app/Frameworks/LeapSDK.framework/Frameworks/libin
dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/usr/lib/libViewDebuggerSupport.dylib

我正在使用Xcode 26.5,且没有显式嵌入并签名框架的选项。另已检查我的Runpath是:

@executable_path/Frameworks

解决方案

我通过在构建阶段添加以下Run脚本解决了这个问题

# Type a script or drag a script file from your workspace to insert its path.
FRAMEWORKS_PATH="${CODESIGNING_FOLDER_PATH}/Frameworks"
LEAP_FRAMEWORK="${FRAMEWORKS_PATH}/LeapSDK.framework"
NESTED="${LEAP_FRAMEWORK}/Frameworks"

if [ -d "$NESTED" ]; then
    for dylib in "$NESTED"/*.dylib; do
        if [ -f "$dylib" ]; then
            echo "Force re-signing: $dylib"
            codesign \
                --force \
                --sign "${EXPANDED_CODE_SIGN_IDENTITY}" \
                --timestamp=none \
                "$dylib"
        fi
    done
    echo "Re-signing LeapSDK.framework itself"
    codesign \
        --force \
        --sign "${EXPANDED_CODE_SIGN_IDENTITY}" \
        --timestamp=none \
        "$LEAP_FRAMEWORK"
fi

同时在构建设置中将user script sandboxing设置为No

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章