I create an encryption c file, header file, .modulemap file and also swift file.
I don't really understand how this works. But, the expectation is i can call c function inside swift file.
Some post said to make it happen you need to use Bridging header or module map.
I unable to use bridging header since i'm using framework
-Project
-Project
-Module
-encryption.c
-encryption.h
-Enc.modulemap
-Encryption.swift
encryption.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* retrieveEncryptionKeyFromC(void) {
char* key = malloc(7); // Allocate memory for a 16-character key + null terminator
strcpy(key, "key"); // Example key (replace with your key retrieval logic)
return key;
}
encryption.h
#ifndef encryption_h
#define encryption_h
#include <stdio.h>
char* retrieveEncryptionKeyFromC(void);
#endif /* encryption_h */
Enc.modulemap
framework module Enc {
umbrella header "encryption.h"
export *
module * { export * }
}
Encryption Swift
import Enc //No such module Enc
Try to add encryption.c, .h and also module map to compile target build phase. But still not working
How can .modulemap getting call correctly in swift file ?