首页 > 解决方案 > 如何在 swift 框架中使用 cocoapods

问题描述

我正在开发一个框架,我在框架中添加了带有 cocoapods 的 alamofire,但是当我将框架添加到目标应用程序时,它会因以下错误而崩溃:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /Users/apple/Library/Developer/CoreSimulator/Devices/A9426EAA-64AA-4A24-A50E-24CA9781ED02/data/Containers/Bundle/Application/D068D428-93BA-4224-A673-4456C8A67B41/hovitaSignSdkTest.app/Frameworks/cryptography.framework/cryptography
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/apple/Library/Developer/CoreSimulator/Caches/dyld/20C69/com.apple.CoreSimulator.SimRuntime.iOS-14-4.18D46
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/apple/Library/Developer/Xcode/DerivedData/hovitaSignSdkTest-fktcpojeagezfbacyzycszboqcfd/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/Cor

我确实将Embed&Sign添加到我的框架的目标应用程序中。

标签: iosswiftxcodeframeworkscocoapods

解决方案


我通过添加$(BUILT_PRODUCTS_DIR)/AlamofireBuild Settings>Runpath Search Paths解决了这个问题

在此处输入图像描述


推荐阅读