尝试构build用于iOS的SSCrypto框架时构build失败

使用Xcode 4,我试图构build与iOS应用程序一起使用的SSCrypto框架。

在“生成设置”中,当我将基础SDK更改为Latest iOS时,出现此错误:

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

我的谷歌search已经空了,所以我觉得我失去了明显的东西…

如何让SSCrypto框架在iOS上运行?

对于iOS,只能使用静态库,而不能使用dynamic库。

而是使用CommonCrypto,它是普通的C但不是很难使用。 确保使用所有相同的设置,模式,IV(如果模式需要),填充和键。

Security.framework添加到项目

 #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; } 

对于Base64请参阅:所以答案

Xcode 4删除了很多的目标types,大概是因为苹果认为这是让人困惑。

build立一个静态库,或者只是将文件包含在你的项目中。