Skip to content

Commit 017d7a1

Browse files
authored
chore: gitignore active api keys for iOS SampleApp (#241)
1 parent 2898ed7 commit 017d7a1

7 files changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ jobs:
166166
env:
167167
NO_FLIPPER: 1
168168

169+
- name: Copy Keys.plist file from sample
170+
run: cp example/ios/SampleApp/Keys.plist.sample example/ios/SampleApp/Keys.plist
171+
169172
- name: Build example for iOS
170173
run: |
171174
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DerivedData
2929
*.xcuserstate
3030
project.xcworkspace
3131
.xcode.env.local
32+
Keys.plist
3233

3334
# Android/IJ
3435
#

example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This contains a sample application to showcase the functionality of the NavSDK l
1818

1919
`pod install`
2020

21-
4. In your Google cloud console, add the Google API key to the project. Add this newly created API key to the Info.plist file inside `example/ios/SampleApp/`.
21+
4. Copy the `Keys.plist.sample` file located in `example/ios/SampleApp/` to a new file named `Keys.plist`. This file is git ignored and won't be accidentally committed. In your Google cloud console, add the Google API key to the project and add this newly created API key to the `Keys.plist` file.
2222

2323
```xml
2424
<key>API_KEY</key>

example/ios/SampleApp.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
1313
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1414
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
15+
52D4271D2C81D3F300C7FB36 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 52D4271C2C81D3F300C7FB36 /* Keys.plist */; };
1516
7699B88040F8A987B510C191 /* libPods-SampleApp-SampleAppTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-SampleApp-SampleAppTests.a */; };
1617
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
1718
E72EC806AB287A94E8141AD5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = E049A7A79160D0D74CDA8CD1 /* PrivacyInfo.xcprivacy */; };
@@ -40,6 +41,7 @@
4041
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = SampleApp/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
4142
19F6CBCC0A4E27FBF8BF4A61 /* libPods-SampleApp-SampleAppTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SampleApp-SampleAppTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4243
3B4392A12AC88292D35C810B /* Pods-SampleApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleApp.debug.xcconfig"; path = "Target Support Files/Pods-SampleApp/Pods-SampleApp.debug.xcconfig"; sourceTree = "<group>"; };
44+
52D4271C2C81D3F300C7FB36 /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Keys.plist; path = SampleApp/Keys.plist; sourceTree = "<group>"; };
4345
5709B34CF0A7D63546082F79 /* Pods-SampleApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleApp.release.xcconfig"; path = "Target Support Files/Pods-SampleApp/Pods-SampleApp.release.xcconfig"; sourceTree = "<group>"; };
4446
5B7EB9410499542E8C5724F5 /* Pods-SampleApp-SampleAppTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleApp-SampleAppTests.debug.xcconfig"; path = "Target Support Files/Pods-SampleApp-SampleAppTests/Pods-SampleApp-SampleAppTests.debug.xcconfig"; sourceTree = "<group>"; };
4547
5DCACB8F33CDC322A6C60F78 /* libPods-SampleApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SampleApp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -93,6 +95,7 @@
9395
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
9496
13B07FB51A68108700A75B9A /* Images.xcassets */,
9597
13B07FB61A68108700A75B9A /* Info.plist */,
98+
52D4271C2C81D3F300C7FB36 /* Keys.plist */,
9699
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
97100
13B07FB71A68108700A75B9A /* main.m */,
98101
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
@@ -246,6 +249,7 @@
246249
isa = PBXResourcesBuildPhase;
247250
buildActionMask = 2147483647;
248251
files = (
252+
52D4271D2C81D3F300C7FB36 /* Keys.plist in Resources */,
249253
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
250254
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
251255
E72EC806AB287A94E8141AD5 /* PrivacyInfo.xcprivacy in Resources */,

example/ios/SampleApp/AppDelegate.mm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ - (BOOL)application:(UIApplication *)application
2626
// You can add your custom initial props in the dictionary below.
2727
// They will be passed down to the ViewController used by React Native.
2828
self.initialProps = @{};
29-
NSString *api_key =
30-
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"API_KEY"];
29+
30+
// Note: Ensure that you have copied the Keys.plist.sample to Keys.plist
31+
// and have added the correct API_KEY value to the file.
32+
//
33+
// Get the path for the Keys.plist file in the main bundle and read API_KEY.
34+
NSString *path = [[NSBundle mainBundle] pathForResource:@"Keys" ofType:@"plist"];
35+
NSDictionary *keysDictionary = [NSDictionary dictionaryWithContentsOfFile:path];
36+
NSString *api_key = [keysDictionary objectForKey:@"API_KEY"];
37+
3138
[GMSServices provideAPIKey:api_key];
3239
[GMSServices setMetalRendererEnabled:YES];
3340
return [super application:application

example/ios/SampleApp/Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>API_KEY</key>
6-
<string>[Add your key]</string>
75
<key>CFBundleDevelopmentRegion</key>
86
<string>en</string>
97
<key>CFBundleDisplayName</key>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>API_KEY</key>
6+
<string>[Add your key]</string>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)