#import extern "C" { __attribute__((visibility("default"))) const char* _GetDeviceCountryCode() { @autoreleasepool { NSLocale *currentLocale = [NSLocale currentLocale]; NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; return strdup([countryCode UTF8String]); // 使用strdup确保内存安全 } } }