Код: Выделить всё
kCCModeGCMСбоя с этой ошибкой для каждой из континтов GCM:
. Undeclared Identifier < /p>
< /blockquote>
Вот моя настройка: < /p>
Код: Выделить всё
CryptoBridgingHeader.hКод: Выделить всё
#import "SecretLogicWrapper.h"
< /code>
SecretLogicWrapper.hсгенерированный Objectivec
Код: Выделить всё
#import
NS_ASSUME_NONNULL_BEGIN
@interface SecretLogicWrapper : NSObject
- (NSData * _Nullable)encryptWithAesGcm:(NSData *)plaintext key:(NSData *)key;
@end
NS_ASSUME_NONNULL_END
< /code>
[b]SecretLogicWrapper.mmobjectivec
#import "SecretLogicWrapper.h"
// All required headers are included.
#import
#import
#import
@implementation SecretLogicWrapper
- (NSData *)encryptWithAesGcm:(NSData *)plaintext key:(NSData *)key {
// A minimal example to demonstrate the GCM call.
// Generate a secure random 12-byte nonce (IV)
NSMutableData* iv = [NSMutableData dataWithLength:12];
if (CCRandomGenerateBytes(iv.mutableBytes, iv.length) != kCCSuccess) {
NSLog(@"[Wrapper Error] Failed to generate random IV for GCM.");
return nil;
}
// Prepare buffers
NSMutableData* ciphertext = [NSMutableData dataWithLength:plaintext.length];
size_t ciphertext_bytes_written = 0;
CCCryptorRef cryptor = NULL;
// THE ERROR OCCURS ON THE LINE BELOW for `kCCModeGCM`
CCCryptorStatus status = CCCryptorCreateWithMode(kCCEncrypt,
kCCModeGCM, //
The errors I receive are:
Use of undeclared identifier 'kCCModeGCM'
Use of undeclared identifier 'kCCParamGCMTag'
(in subsequent code)
Use of undeclared identifier 'kCCAuthError'
(in subsequent code)
This seems to indicate that the compiler is not using the correct iOS 16 SDK headers when compiling this .mm file, but I can't figure out why. It feels like a project configuration issue, but I've checked all the standard settings.
What else could cause the compiler to not find these standard CommonCrypto identifiers in an Objective-C++ file when the deployment target is set correctly?
I've already tried:
- My iOS deployment target is iOS 16.0.
- I have explicitly added #include .
- I have explicitly linked Security.framework in the "Link Binary With Libraries" build phase.
- The file type for the .mm file is correctly set to "Objective-C++ Source" in the File Inspector.
Подробнее здесь: https://stackoverflow.com/questions/797 ... rk-linking
Мобильная версия