按照类似问题的指示在 Flutter 应用程序中从源代码控制中隐藏 Google 地图 API 密钥
AppDelegate.m
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString* mapsApiKey = [[NSProcessInfo processInfo] environment][@"FLUTTER_GMAPS_API_KEY"];
[GMSServices provideAPIKey: mapsApiKey];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
Run Code Online (Sandbox Code Playgroud)
如果我将 ProvideApiKey 更改为 @"theApiKeyImTryingToHide" 一切正常。