Skip to content

Commit 0954522

Browse files
committed
Add Secrets.xcconfig
1 parent 3817f46 commit 0954522

File tree

6 files changed

+53
-8
lines changed

6 files changed

+53
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Secret Keys
2-
Secrets.swift
2+
Secrets.xcconfig
33

44
# Files that might appear in the root of a volume
55
.DocumentRevisions-V100

ForPDA.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@
136136
B8001CDE2A1B01D000E7A8A8 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
137137
B82B2EBD2A89016300CB067C /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
138138
B82B2EC02A89059C00CB067C /* AppScheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScheme.swift; sourceTree = "<group>"; };
139+
B82B2EC62A89306000CB067C /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Secrets.xcconfig; sourceTree = "<group>"; };
140+
B82B2EFE2A8942E900CB067C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
139141
B8340351296789FE00C3CF37 /* PDABulletLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDABulletLabel.swift; sourceTree = "<group>"; };
140142
B8340354296796F600C3CF37 /* PDAPaddingLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDAPaddingLabel.swift; sourceTree = "<group>"; };
141143
B83403562967AFCA00C3CF37 /* PDATableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDATableView.swift; sourceTree = "<group>"; };
@@ -211,7 +213,6 @@
211213
B8D351FC293CABB6008A84EA /* NewsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsVC.swift; sourceTree = "<group>"; };
212214
B8D35201293CABB7008A84EA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
213215
B8D35204293CABB7008A84EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
214-
B8D35206293CABB7008A84EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
215216
B8DDFA1B294A4D22008B0156 /* NetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkService.swift; sourceTree = "<group>"; };
216217
B8DDFA1D294A5611008B0156 /* ArticleVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleVM.swift; sourceTree = "<group>"; };
217218
B8DDFA1F294A56E4008B0156 /* ParsingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsingService.swift; sourceTree = "<group>"; };
@@ -499,7 +500,8 @@
499500
children = (
500501
B8FD82092A1163EE00EB7035 /* Sources */,
501502
B8FD820E2A11681500EB7035 /* Resources */,
502-
B8D35206293CABB7008A84EA /* Info.plist */,
503+
B82B2EC62A89306000CB067C /* Secrets.xcconfig */,
504+
B82B2EFE2A8942E900CB067C /* Info.plist */,
503505
);
504506
path = ForPDA;
505507
sourceTree = "<group>";
@@ -783,7 +785,7 @@
783785
);
784786
runOnlyForDeploymentPostprocessing = 0;
785787
shellPath = /bin/sh;
786-
shellScript = "if which sentry-cli >/dev/null; then\nexport SENTRY_ORG=forpda\nexport SENTRY_PROJECT=apple-ios\nexport SENTRY_AUTH_TOKEN=5d97c30a6b9949187a351342d789754ff3d03d23e2ebd5f27c9290d804e8d44a\nERROR=$(sentry-cli debug-files upload --include-sources \"$DWARF_DSYM_FOLDER_PATH\" --force-foreground 2>&1 >/dev/null)\nif [ ! $? -eq 0 ]; then\necho \"error: sentry-cli - $ERROR\"\nfi\nelse\necho \"error: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n";
788+
shellScript = "source \"${PROJECT_DIR}/ForPDA/Secrets.xcconfig\"\nif which sentry-cli >/dev/null; then\nexport SENTRY_ORG=forpda\nexport SENTRY_PROJECT=apple-ios\nexport SENTRY_AUTH_TOKEN=$SENTRY_DSYM_TOKEN\nERROR=$(sentry-cli debug-files upload --include-sources \"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\nif [ ! $? -eq 0 ]; then\necho \"warning: sentry-cli - $ERROR\"\nfi\nelse\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n";
787789
};
788790
B8FEA1BB29675BCE002DFAA4 /* SwiftLint */ = {
789791
isa = PBXShellScriptBuildPhase;
@@ -942,6 +944,7 @@
942944
/* Begin XCBuildConfiguration section */
943945
B8D35207293CABB7008A84EA /* Debug */ = {
944946
isa = XCBuildConfiguration;
947+
baseConfigurationReference = B82B2EC62A89306000CB067C /* Secrets.xcconfig */;
945948
buildSettings = {
946949
ALWAYS_SEARCH_USER_PATHS = NO;
947950
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
@@ -1005,6 +1008,7 @@
10051008
};
10061009
B8D35208293CABB7008A84EA /* Release */ = {
10071010
isa = XCBuildConfiguration;
1011+
baseConfigurationReference = B82B2EC62A89306000CB067C /* Secrets.xcconfig */;
10081012
buildSettings = {
10091013
ALWAYS_SEARCH_USER_PATHS = NO;
10101014
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;

ForPDA/Info.plist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
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>SECRET_KEYS</key>
6+
<dict>
7+
<key>SENTRY_DSN</key>
8+
<string>$(SENTRY_DSN)</string>
9+
<key>SENTRY_DSYM_TOKEN</key>
10+
<string>$(SENTRY_DSYM_TOKEN)</string>
11+
<key>AMPLITUDE_TOKEN</key>
12+
<string>$(AMPLITUDE_TOKEN)</string>
13+
<key>TELEGRAM_TOKEN</key>
14+
<string>$(TELEGRAM_TOKEN)</string>
15+
<key>TELEGRAM_CHAT_ID</key>
16+
<string>$(TELEGRAM_CHAT_ID)</string>
17+
</dict>
518
<key>ITSAppUsesNonExemptEncryption</key>
619
<false/>
720
<key>UIApplicationSceneManifest</key>

ForPDA/Sources/Application/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2020
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2121

2222
SentrySDK.start { options in
23-
options.dsn = Secrets.sentry
23+
options.dsn = Secrets.for(key: .SENTRY_DSN)
2424
options.debug = AppScheme.isDebug
2525
options.tracesSampleRate = 1.0
2626
options.diagnosticLevel = .warning
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Secrets.swift
3+
// ForPDA
4+
//
5+
// Created by Subvert on 13.08.2023.
6+
//
7+
// swiftlint:disable identifier_name
8+
9+
import Foundation
10+
11+
struct Secrets {
12+
13+
enum Keys: String {
14+
case SENTRY_DSN
15+
case SENTRY_DSYM_TOKEN
16+
case AMPLITUDE_TOKEN
17+
case TELEGRAM_TOKEN
18+
case TELEGRAM_CHAT_ID
19+
}
20+
21+
static func `for`(key: Keys) -> String {
22+
if let dictionary = Bundle.main.object(forInfoDictionaryKey: "SECRET_KEYS") as? [String: String] {
23+
return dictionary[key.rawValue] ?? ""
24+
} else {
25+
return ""
26+
}
27+
}
28+
}

ForPDA/Sources/Services/Analytics/AnalyticsService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class AnalyticsService {
1414
typealias EventDictionary = [String: String]
1515

1616
private let amplitude = Amplitude(configuration: Configuration(
17-
apiKey: Secrets.amplitude,
17+
apiKey: Secrets.for(key: .AMPLITUDE_TOKEN),
1818
logLevel: .WARN,
1919
serverZone: .EU
2020
))
@@ -132,7 +132,7 @@ extension AnalyticsService {
132132
}
133133

134134
func reportArticle(_ reportUrl: String) {
135-
guard let url = URL(string: "https://api.telegram.org/bot\(Secrets.telegramToken)/sendMessage") else { return }
135+
guard let url = URL(string: "https://api.telegram.org/bot\(Secrets.for(key: .TELEGRAM_TOKEN))/sendMessage") else { return }
136136

137137
var request = URLRequest(url: url)
138138
request.httpMethod = "POST"
@@ -145,7 +145,7 @@ extension AnalyticsService {
145145

146146
let jsonBody = """
147147
{
148-
"chat_id": \(Secrets.telegramChatID),
148+
"chat_id": \(Secrets.for(key: .TELEGRAM_CHAT_ID)),
149149
"text": "[\(user?.id ?? "-"):\(user?.nickname ?? "-")]\n\(reportUrl)"
150150
}
151151
"""

0 commit comments

Comments
 (0)