如何在 swift 框架中使用 cocoapods

How to use cocoapods inside swift framework

我正在开发一个框架,我在我的框架工作中添加了带有 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 添加到我的框架的目标应用程序中。

我通过将 $(BUILT_PRODUCTS_DIR)/Alamofire 添加到 Build Settings>Runpath Search Paths

解决了这个问题