Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cryptoswift Framework is not being accessed

I am using Cryptoswift framework for encryption and decryption. I am using an Xcode project inside another Xcode project.The subproject is not able to access the framework Cryptoswift in spite of using pods for the main project. In addition to that, I have also added the framework to the "Linked Frameworks and Libraries".The Project works fine in the simulator but is not working on the device.When I run it on the device I get the error

  var enc = try AES(key: FirstStepEncryptionKey, iv: "", blockMode:.CBC, padding: NoPadding()).encrypt(firstStepArray)

ERROR:"Use of unresolved identifier 'AES'"

Though the import statement does not show any errors.I am the only developer in my company and there is no one to guide me.Please help me clear this.

UPDATE: I added the files to embed binary and still it crashes saying "dyld: Library not loaded: @rpath/CryptoSwift.framework/CryptoSwift Referenced from: /var/containers/Bundle/Application/48894FB2-0CDB-4B8D-A763-1C57B3EDAE41/Vaya_Tracker.app/Vaya_Tracker Reason: image not found"

Fix: I had to add the CryptoSwift.xcodeproj file into my Xcode project instead of adding it through pods or Carthage.

like image 504
tamizhachi_ Avatar asked May 09 '26 15:05

tamizhachi_


1 Answers

I am also using CryptoSwift with Cocoapods and Swift version is Swift 4.0. Below is my podfile.

platform :ios, '8.0'
use_frameworks!

target 'MyAProjectName' do
 pod 'CryptoSwift', '0.8.3'
end

You have to import CryptoSwift to make use of AES.

import CryptoSwift

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        do {
            let aes = try AES(key: "passwordpassword", iv: "drowssapdrowssap") // aes128
            let ciphertext = try aes.encrypt(Array("Nullam quis risus eget urna mollis ornare vel eu leo.".utf8))
            print(ciphertext)
        } catch { }

    }
}

Update for crash issue as per comment :

enter image description here

Then clean the build and build again. If still it not work than try to set status in Linked framework and Libraries as required for both frameworks.

like image 74
technerd Avatar answered May 12 '26 06:05

technerd