尝试构建SSCrypto框架以与iOS配合使用时构建失败 [英] Build failure when trying to build SSCrypto framework for use with iOS
问题描述
使用Xcode 4,我试图构建SSCrypto框架以用于iOS应用程序。
Using Xcode 4, I'm attempting to build the SSCrypto framework for use with an iOS app.
在版本设置中,当我将基本SDK更改为最新iOS时,会出现以下错误:
In Build Settings, when I change the base SDK to Latest iOS, I get this error:
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphoneos' platform
我的搜索和搜索已经变空了,所以我觉得我缺少一些明显的东西...
My googling and searching has turned up empty, so I feel I'm missing something obvious...
如何获得SSCrypto框架在iOS上的工作?
How do I get SSCrypto framework to work on iOS?
推荐答案
对于iOS只能使用静态库,库。
For iOS only static libraries can be used, not frameworks with dynamic libraries.
而是使用CommonCrypto,它是纯C,但不是真的很难使用。确保您使用所有相同的设置,模式,IV(如果必要的模式),填充和键。
Instead use CommonCrypto, it is plain C but not really hard to use. Do insure that you use all the same setting, mode, IV (if necessary for the mode), padding and key.
添加安全。框架
到项目
#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,请参阅:回答
For Base64 see: SO answer
这篇关于尝试构建SSCrypto框架以与iOS配合使用时构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!