VirgilSecurity / virgil-sdk-x

Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more.
https://virgilsecurity.com/
Other
27 stars 5 forks source link

XCode 14.X Library not loaded error #59

Open dgalitsyn opened 1 year ago

dgalitsyn commented 1 year ago

Hi @SergeySeroshtan,

I'm not sure if this is the correct repo to raise the issue.

I am getting a library not found error when compiling our app on XCode 14.2 or 14.3, please see below:

dyld[83764]: Library not loaded: @rpath/VirgilCrypto.framework/VirgilCrypto
  Referenced from: <1DA6F60D-DCD2-3BEA-A398-6AC15CA41760> /Users/denisgalitsyn/Library/Developer/CoreSimulator/Devices/7BC75890-E0B9-4EDA-8623-124807D54429/data/Containers/Bundle/Application/F97D0BD9-E516-4DA7-9E14-F522CDB2E5B4/guestApp.app/Frameworks/ClaySDK.framework/ClaySDK
  Reason: tried: '/Users/denisgalitsyn/Library/Developer/Xcode/DerivedData/guestApp-glsgagohkradmoellyszixviczpi/Build/Products/Debug-iphonesimulator/VirgilCrypto.framework/VirgilCrypto' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/VirgilCrypto.framework/VirgilCrypto' (no such file), '/usr/lib/swift/VirgilCrypto.framework/VirgilCrypto' (no such file, not in dyld cache), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/VirgilCrypto.framework/VirgilCrypto' (no such file), '/usr/lib/swift/VirgilCrypto.framework/VirgilCrypto' (no such file, not in dyld cache), '/Users/denisgalitsyn/Library/Developer/CoreSimulator/Devices/7BC75890-E0B9-4EDA-8623-124807D54429/data/Containers/Bundle/Application/F97D0BD9-E516-4DA7-9E14-F522CDB2E5B4/guestApp.app/Frameworks/VirgilCrypto.framework/VirgilCrypto' (no such file), '/Users/denisgalitsyn/Library/Developer/CoreSimulator/Devices/7BC75890-E0B9-4EDA-8623-124807D54429/data/Containers/Bundle/Application/F97D0BD9-E516-4DA7-9E14-F522CDB2E5B4/guestApp.app/Frameworks/ClaySDK.framework/Frameworks/VirgilCrypto.framework/VirgilCrypto' (no s

etc

This library is included by another dependency we use. However, not matter what I try, I am always get this error. However when I check the derived data folder, there is a VirgilCrypto folder with the following files in there: 96 24 May 13:09 Swift Compatibility Header 316 24 May 10:09 VirgilCrypto-umbrella.h 356 24 May 13:09 VirgilCrypto.modulemap 192 24 May 13:09 VirgilCrypto.swiftmodule 644696 24 May 13:09 libVirgilCrypto.a

This is a react native project, so not sure if this is something to go by. I am not an ios dev so not sure how to proceed here. Do you have any idea?

Regards, Denis.

SergeySeroshtan commented 1 year ago

Hi @dgalitsyn. Can you provide next information:

  1. output of command file /path/to/libVirgilCrypto.a
  2. package manager that is used in the project: spm, cathage, cocoapods
  3. version of the ClaySDK
  4. ideally provide example xcodeproject that reproduce this error
dgalitsyn commented 1 year ago

Hi @SergeySeroshtan,

Thank you for your reply.

  1. output of command file /path/to/libVirgilCrypto.a

-rw-r--r-- 1 denisgalitsyn staff 644696 24 May 16:52 libVirgilCrypto.a denisgalitsyn@Deniss-MacBook-Pro VirgilCrypto % file libVirgilCrypto.a libVirgilCrypto.a: current ar archive

  1. package manager that is used in the project: spm, cathage, cocoapods

I use cocoapods

  1. version of the ClaySDK

We have access to their newer version of the their SDK from their gitlab. Version 2.0.1. I think one of the devs from clay said they have a dependency on VirgilCrypto 6.1.0

  1. ideally provide example xcodeproject that reproduce this error

Unfortunately I cannot provide our version of the project. However there is a sample claysdk demo ios app from their gitlab, which has a simple podfile as follows, but you need gitlab username/password from clay to get access, which I am not sure if you do have.

source 'https://github.com/CocoaPods/Specs.git'
source 'https://{YOUR_REPO_USER}:{YOUR_TOKEN}@gitlab.com/claysolutions/public/clay-sdk-artefacts'
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

target 'Demo' do
  platform :ios, '13.0'
  pod 'ClaySDK', :git => 'https://gitlab.com/claysolutions/public/clay-sdk-artefacts', :tag => '2.0.1'
  pod 'AppAuth'
end

target 'DemoWatchOS WatchKit Extension' do
  platform :watchos, '7.0'
  pod 'ClaySDK', :git => 'https://gitlab.com/claysolutions/public/clay-sdk-artefacts', :tag => '2.0.1'
end

Thanks. πŸ‡ΊπŸ‡¦πŸ‡ΊπŸ‡¦πŸ‡ΊπŸ‡¦

dgalitsyn commented 1 year ago

Just an addition to the above, if its any help. I had to set the Build Libraries for Distribution to NO for all of our pods as setting this to YES breaks the build and never compiles. Not sure if thats any help or not.

And our minimum target ios version is 13.

dgalitsyn commented 1 year ago

Hi @SergeySeroshtan, any update?

SergeySeroshtan commented 1 year ago

I'm a volunteer on this project. So responses and solving will be delayed for sure. Please, wait for a while. Thank you for understanding.

SergeySeroshtan commented 1 year ago

Hi @dgalitsyn. I've created a demo project based on VirgilSDK only, and it compiles and runs on iOS simulator. Please to reproduce this demo locally.

  1. Create empty IOS app project with name 'VirgilSDKdemo'.
  2. Add Podfile to the root with content
    
    platform :ios, '13.0'

target 'VirgilSDKdemo' do use_frameworks! pod 'VirgilSDK', '~> 8.2' end

3. Put next content to `ContentView.swift` 
```swift
import SwiftUI
import VirgilCrypto

extension Data {
    struct HexEncodingOptions: OptionSet {
        let rawValue: Int
        static let upperCase = HexEncodingOptions(rawValue: 1 << 0)
    }

    func hexEncodedString(options: HexEncodingOptions = []) -> String {
        let format = options.contains(.upperCase) ? "%02hhX" : "%02hhx"
        return self.map { String(format: format, $0) }.joined()
    }
}

struct ContentView: View {
    func getHash() -> String {
        do {
            let greating = "hello"
            let data = greating.data(using: .ascii)
            let crypto = try VirgilCrypto()
            let digest = crypto.computeHash(for: data!, using: .sha512);
            return "sha512('\(greating)') = \(digest.hexEncodedString())"
        } catch {
            return "crypto error: \(error)"
        }
    }

    var body: some View {
        VStack {
            Text("πŸ‡ΊπŸ‡¦πŸ‡ΊπŸ‡¦πŸ‡ΊπŸ‡¦");
            Text(getHash())

        }
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
  1. Run pod install
  2. Run project on simulator
dgalitsyn commented 1 year ago

Hi @SergeySeroshtan,

I think I have raised the issue on the wrong repo.

Can you try Xcode 14.3 and VirgilCrypto ~> 6.1.0 building for ios 13+ and without useframeworks?

This is the setup we use and I am getting the result I first described.

Thanks.