diff --git a/Projects/App/Info.plist b/Projects/App/Info.plist index 46770759..34c9364d 100644 --- a/Projects/App/Info.plist +++ b/Projects/App/Info.plist @@ -41,6 +41,8 @@ KAKAO_NATIVE_APP_KEY $(KAKAO_NATIVE_APP_KEY) + GOOGLE_AD_UNITID + $(GOOGLE_AD_UNITID) LSApplicationCategoryType LSApplicationQueriesSchemes diff --git a/Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift b/Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift index 5aa0400a..95fafd69 100644 --- a/Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift +++ b/Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift @@ -26,7 +26,15 @@ extension GoogleMobileAdsClient: DependencyKey { await GADMobileAds.sharedInstance().start() }, load: { - let ad = try await GADInterstitialAd.load(withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: GADRequest()) + var adUnitID: String { + #if DEBUG + return "ca-app-pub-3940256099942544/4411468910" + #else + return APIKey.googleAdUnitID + #endif + } + + let ad = try await GADInterstitialAd.load(withAdUnitID: adUnitID, request: GADRequest()) return GoogleAd(ad: ad) } diff --git a/Projects/Core/Services/Sources/SocialLogin/Util/APIKey.swift b/Projects/Core/Services/Sources/SocialLogin/Util/APIKey.swift deleted file mode 100644 index 0a9b17c7..00000000 --- a/Projects/Core/Services/Sources/SocialLogin/Util/APIKey.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// APIKey.swift -// CoreKit -// -// Created by kyuchul on 6/17/24. -// Copyright © 2024 com.jordyma.blink. All rights reserved. -// - -import Foundation - -enum APIKey { - static let kakao = { - guard let infoDictionary = Bundle.main.infoDictionary else { fatalError("Wrong Info dictionary") } - guard let key = infoDictionary["KAKAO_NATIVE_APP_KEY"] as? String else { fatalError("Wrong KAKAO_NATIVE_APP_KEY") } - return key - }() -} diff --git a/Projects/Core/Services/Sources/Util/APIKey.swift b/Projects/Core/Services/Sources/Util/APIKey.swift new file mode 100644 index 00000000..1ffdbbc3 --- /dev/null +++ b/Projects/Core/Services/Sources/Util/APIKey.swift @@ -0,0 +1,22 @@ +// +// APIKey.swift +// CoreKit +// +// Created by kyuchul on 6/17/24. +// Copyright © 2024 com.jordyma.blink. All rights reserved. +// + +import Foundation + +enum APIKey { + static let kakao = getInfoValue(for: "KAKAO_NATIVE_APP_KEY") + static let googleAdUnitID = getInfoValue(for: "GOOGLE_AD_UNITID") + + private static func getInfoValue(for key: String) -> String { + guard let infoDictionary = Bundle.main.infoDictionary, + let value = infoDictionary[key] as? String else { + fatalError("Wrong \(key)") + } + return value + } +}