Skip to content

Commit

Permalink
Regerated API key. added GoogleCustomSearch-Info.plist in gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexookah committed Dec 1, 2020
1 parent 63a00d2 commit 35282f3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# KEEP GoogleCustomSearch-Info.plist out of version controll
GoogleCustomSearch-Info.plist

# Created by https://www.toptal.com/developers/gitignore/api/xcode
# Edit at https://www.toptal.com/developers/gitignore?templates=xcode
Expand Down Expand Up @@ -37,4 +39,4 @@ DerivedData/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings

# End of https://www.toptal.com/developers/gitignore/api/xcode
# End of https://www.toptal.com/developers/gitignore/api/xcode
22 changes: 22 additions & 0 deletions Image Multi Search.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
B4DF836125751FA100BDF6EC /* Keyword.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DF836025751FA100BDF6EC /* Keyword.swift */; };
B4DF836425751FC200BDF6EC /* KeywordsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DF836325751FC200BDF6EC /* KeywordsViewModel.swift */; };
B4F0E17125764E890046BD56 /* UIButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0E17025764E890046BD56 /* UIButton.swift */; };
B4F0E1822576B6CF0046BD56 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = B4F0E1812576B6CF0046BD56 /* .gitignore */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -51,6 +52,7 @@
B4DF836025751FA100BDF6EC /* Keyword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keyword.swift; sourceTree = "<group>"; };
B4DF836325751FC200BDF6EC /* KeywordsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordsViewModel.swift; sourceTree = "<group>"; };
B4F0E17025764E890046BD56 /* UIButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIButton.swift; sourceTree = "<group>"; };
B4F0E1812576B6CF0046BD56 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -106,6 +108,7 @@
B4A78450257026BB007CBB78 = {
isa = PBXGroup;
children = (
B4F0E1812576B6CF0046BD56 /* .gitignore */,
B4A7845B257026BB007CBB78 /* Image Multi Search */,
B4A7845A257026BB007CBB78 /* Products */,
);
Expand Down Expand Up @@ -167,6 +170,7 @@
B4A78456257026BB007CBB78 /* Frameworks */,
B4A78457257026BB007CBB78 /* Resources */,
B4D6C85E2573955700DAEFC1 /* Swiftlint */,
B4F0E1852576BA0A0046BD56 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -223,6 +227,7 @@
B4A78469257026BC007CBB78 /* LaunchScreen.storyboard in Resources */,
B4A78466257026BC007CBB78 /* Assets.xcassets in Resources */,
B4D5FE7C2572CAC90057C141 /* PreviewImageSearchCell.xib in Resources */,
B4F0E1822576B6CF0046BD56 /* .gitignore in Resources */,
B4A78464257026BB007CBB78 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -248,6 +253,23 @@
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
B4F0E1852576BA0A0046BD56 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "PLIST_FILE=\"GoogleCustomSearch-Info.plist\"\nPLIST_PATH=\"${PROJECT_DIR}/${PLIST_FILE}\"\ncp \"${PLIST_PATH}\" \"${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/GoogleCustomSearch-Info.plist\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Binary file not shown.
13 changes: 12 additions & 1 deletion Image Multi Search/Utilities/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ class APIService {

let baseURLString = "https://www.googleapis.com/customsearch/v1"

private let apikey = "AIzaSyCrZtIBCbM3VEuFpcYYuVyO3SBzKGSPoIw"
private var apikey: String {
guard let filePath = Bundle.main.path(forResource: "GoogleCustomSearch-Info", ofType: "plist") else {
fatalError("Couldn't find file 'GoogleCustomSearch-Info.plist'.")
}

let plist = NSDictionary(contentsOfFile: filePath)
guard let value = plist?.object(forKey: "API_KEY") as? String else {
fatalError("Couldn't find key 'API_KEY' in 'CustomGoogleSearch-Info.plist'.")
}
return value
}

private let searchEngine = "017901247231445677654:zwad8gw42fj"
private let searchType = "image"

Expand Down
3 changes: 3 additions & 0 deletions Image Multi Search/Views/KeywordCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class KeywordCell: UITableViewCell {
self.statusImage.image = UIImage(systemName: "checkmark.circle")
self.showOrHideActivityIndicator(shouldShow: false)
case .failed:
self.statusImage.image = UIImage(systemName: "exclamationmark.triangle")
self.showOrHideActivityIndicator(shouldShow: false)
case .noItems:
self.statusImage.image = UIImage(systemName: "xmark.circle")
self.showOrHideActivityIndicator(shouldShow: false)
}
Expand Down

0 comments on commit 35282f3

Please sign in to comment.