【问题标题】:Custom Framework : dyld: Symbol not found: _$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC自定义框架:dyld:找不到符号:_$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC
【发布时间】:2021-02-15 19:48:35
【问题描述】:

我正在使用使用 3 个不同的 cocoapods 创建的自定义框架。我通过删除创建的 xc 框架在客户端应用程序中使用此自定义框架。一旦客户端应用程序启动,它就会崩溃并显示以下崩溃日志。我已经看到这个问题在苹果和 stackoverflow 上报告了许多其他地方,但我找不到适合我的正确答案。现在我已经将客户端应用程序和框架 repo 都上传到了 github,这样任何试图帮助我的人都可以真正看到设置和代码。请任何人提出解决此问题的适当方法。

框架:https://github.com/deepesh259nitk/PaymentsKit

客户端应用:https://github.com/deepesh259nitk/PaymentClient

应用启动时的崩溃日志

dyld:找不到符号:$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC 引用自:/Users/deepesh.vasthimal/Library/Developer/Xcode/DerivedData/PaymentClient-bnsircrdeaciebedmqaliyxezdqe/Build/Products/Debug-iphonesimulator/PaymentsKit.framework/PaymentsKit 预计在:/Users/deepesh.vasthimal/Library/Developer/CoreSimulator/Devices/A0876375-98D5-4215-A139-68F29E787388/data/Containers/Bundle/Application/D954732B-EDDC-478E-85C4-C5C9B14FDDEE/PaymentClient.app/框架/CryptoSwift.framework/CryptoSwift 在 /Users/deepesh.vasthimal/Library/Developer/Xcode/DerivedData/PaymentClient-bnsircrdeaciebedmqaliyxezdqe/Build/Products/Debug-iphonesimulator/PaymentsKit.framework/PaymentsKit dyld:启动,加载依赖库 DYLDSHAREDCACHEDIR=/Users/deepesh.vasthimal/Library/Developer/CoreSimulator/Caches/dyld/19H2/com.apple.CoreSimulator.SimRuntime.iOS-14-0.18A372 DYLDROOTPATH=/Users/deepesh.vasthimal/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLDLIBRARYPATH=/Users/deepesh.vasthimal/Library/Developer/Xcode/DerivedData/PaymentClient-bnsircrdeaciebedmqaliyxezdqe/Build/Products/Debug-iphonesimulator:/Users/deepesh.vasthimal/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS。平台/库/开发人员/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLDINSERTLIBRARIES=/Users/deepesh.vasthimal/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording .dylib:/Users/de

我尝试过的东西。

  1. 我尝试完全移除 CryptoSwift 以查看错误是否是由于此 pod 而发生的,但随后崩溃发生在另一个 pod 的 JOSESwift 上。
  2. 我已经意识到崩溃的发生是因为它在 CryptoSwift 和 JOSESwift 中都找不到特定的符号。还有当我使用这些库的特定方法时。

例如,如果我使用 CryptoSwift 的 AES 方法,如果您看到我的框架 repo,通过添加以下代码会发生崩溃,仅包含 pod 不会崩溃,但使用它会导致崩溃。

_$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC

guard let aesObject = try? AES(key: [UInt8](Data()),
               blockMode: CBC(iv: Array(Data())),
               padding: .pkcs7) else {   return "" }
  1. 我还在客户端应用程序中添加 pod,这样如果您看到客户端应用程序存储库,它就不会被添加两次,您会看到所有 3 个 pod 都已添加。

【问题讨论】:

    标签: ios-frameworks swift-framework xcframework swift-custom-framework


    【解决方案1】:

    将以下脚本添加到客户端应用程序的 pod 文件末尾。

    post_install do |installer|
            installer.pods_project.targets.each do |target|
              target.build_configurations.each do |config|
                config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
              end
            end
          end
    

    然后运行 ​​pod 命令

     pod deintegrate
     pod install 
    

    并修复崩溃。

    【讨论】:

      【解决方案2】:

      再次运行 pod install 即可解决问题,而无需向 pod 文件添加任何其他内容。

      但是,在每个 pod deintegrate 并且 pod install 无法正常工作后,再次进行 pod install 应该可以修复。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-05-02
        • 2020-04-18
        • 2016-06-01
        • 2021-12-30
        • 2020-07-22
        • 2019-08-18
        • 2020-02-13
        相关资源
        最近更新 更多