Build failed while trying to create SSCrypto infrastructure for use with iOS

Using Xcode 4, I am trying to create an SSCrypto framework for use with an iOS application.

In the build settings, when I change the base SDK to the latest version of iOS, I get this error:

target specifies product type 'com.apple.product-type.framework', but there no such product type for the 'iphoneos' platform 

My search engine and search turned out to be empty, so I feel like I'm missing something obvious ...

How can I make SSCrypto work on iOS?

+1
source share
2 answers

For iOS, only static libraries can be used, not frameworks with dynamic libraries.

Use CommonCrypto instead, it's just C, but not very difficult to use. Make sure that you use the same settings, mode, IV (if necessary for the mode), indents and the key.

Add Security.framework to the project

 #import <CommonCrypto/CommonCryptor.h> + (NSData *)doCipher:(NSData *)dataIn iv:(NSData *)iv key:(NSData *)symmetricKey context:(CCOperation)encryptOrDecrypt { CCCryptorStatus ccStatus = kCCSuccess; size_t cryptBytes = 0; // Number of bytes moved to buffer. NSMutableData *dataOut = [NSMutableData dataWithLength:dataIn.length + kCCBlockSizeAES256]; ccStatus = CCCrypt( encryptOrDecrypt, kCCAlgorithmAES256, kCCOptionPKCS7Padding, symmetricKey.bytes, kCCKeySizeAES256, iv.bytes, dataIn.bytes, dataIn.length, dataOut.mutableBytes, dataOut.length, &cryptBytes); if (ccStatus != kCCSuccess) { // Handle error NSLog(@"CCCrypt status: %d", ccStatus); } dataOut.length = cryptBytes; return dataOut; } 

For Base64 see SO answer

+2
source

Xcode 4 removed many target types, apparently because Apple thought this was confusing people.

Create a static library instead, or simply include files in your project.

0
source

All Articles