Custom Framework : dyld: Symbol not found: _$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC
Asked Answered
A

2

10

I am using a custom framework created using 3 different cocoapods. I am using this custom framework in a client app by dropping the xc framework created. As soon as the client app launches it crashes with below crash logs. I have seen this issue reported many other places on apple and stackoverflow but i could not find a proper answer which worked for me. Now i have uploaded both the client app and the framework repo to github so that anyone trying to help me can actually see the set up and code. Please can any one suggest a proper solution to this issue.

Framework : https://github.com/deepesh259nitk/PaymentsKit

Client App : https://github.com/deepesh259nitk/PaymentClient

Crash Logs on app launch

dyld: Symbol not found: $s11CryptoSwift7PaddingO5pkcs7yA2CmFWC Referenced from: /Users/deepesh.vasthimal/Library/Developer/Xcode/DerivedData/PaymentClient-bnsircrdeaciebedmqaliyxezdqe/Build/Products/Debug-iphonesimulator/PaymentsKit.framework/PaymentsKit Expected in: /Users/deepesh.vasthimal/Library/Developer/CoreSimulator/Devices/A0876375-98D5-4215-A139-68F29E787388/data/Containers/Bundle/Application/D954732B-EDDC-478E-85C4-C5C9B14FDDEE/PaymentClient.app/Frameworks/CryptoSwift.framework/CryptoSwift in /Users/deepesh.vasthimal/Library/Developer/Xcode/DerivedData/PaymentClient-bnsircrdeaciebedmqaliyxezdqe/Build/Products/Debug-iphonesimulator/PaymentsKit.framework/PaymentsKit dyld: launch, loading dependent libraries 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.platform/Library/Developer/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

Things which I have tried.

  1. I tried removing the CryptoSwift completely to see if the error happens due to this pod, but the crash then comes to JOSESwift which is another pod.
  2. I have realised the crash happens as it cannot find specific symbols both in CryptoSwift and JOSESwift. And also when i use specific methods of these libraries.

for example if i use the AES method of CryptoSwift if you see my repo for framework, by adding the below code the crash happens, Just including the pod does not crash but usage of it produces the crash.

_$s11CryptoSwift7PaddingO5pkcs7yA2CmFWC

guard let aesObject = try? AES(key: [UInt8](Data()),
               blockMode: CBC(iv: Array(Data())),
               padding: .pkcs7) else {   return "" }
  1. I am also adding the pods in the client app so that it does not get added twice if you see Client App repo you will see all the 3 pods are added.
Autry answered 3/11, 2020 at 6:17 Comment(0)
A
31

Adding below script to end of pod file of the client app.

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

and then run the pod commands

 pod deintegrate
 pod install 

and fixes the crash.

Autry answered 5/11, 2020 at 12:41 Comment(0)
A
1

Running pod install again fixes the issue without adding anything additional to the pod file.

However after each pod deintegrate and pod install would not work doing a pod install again should fix.

Autry answered 9/8, 2021 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.