Kccmodegcm undeclaled в .mm File, несмотря на правильную цель и структуру связыванияIOS

Программируем под IOS
Ответить
Anonymous
 Kccmodegcm undeclaled в .mm File, несмотря на правильную цель и структуру связывания

Сообщение Anonymous »

Я сталкиваюсь с проблемой сборки, где идентификаторы CommonCrypto для режима GCM (

Код: Выделить всё

kCCModeGCM
, kccparamgcmtag , kccautherror ) не найдены при составлении файла Objective-c ++ (.mm), даже если цель развертывания моего проекта установлена на iOS 16.
Сбоя с этой ошибкой для каждой из континтов GCM:





. Undeclared Identifier < /p>
< /blockquote>
Вот моя настройка: < /p>

Код: Выделить всё

CryptoBridgingHeader.h
(Заголовок для мостового проекта)

Код: Выделить всё

#import "SecretLogicWrapper.h"
< /code>
SecretLogicWrapper.h
(публичный интерфейс для Swift)
сгенерированный 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.mm
[/b] (реализация, в которой происходит ошибка)
objectivec
#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.
And it didn't work. How can I fix this problem?

Подробнее здесь: https://stackoverflow.com/questions/797 ... rk-linking
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»