-
plist 분리를 통한 서버 환경 설정Language/iOS,AOS 2023. 3. 8. 15:13
정리하게된 계기
서버별 환경설정을 쉽게 하기 위해서 정리하게 되었다.
plist 분리 방법 : https://dchkang83.tistory.com/175
분리 구조
필자는 release, local, dev, stg 형태로 설정이 되었다.
plist 파일 모드 설정
plist에 설정된 ServerMode 불러오기
// 서버 모드 var serverMode: String { if let info = Bundle.main.infoDictionary, let debug = info["AppInfo"] as? [String: Any], let serverURL = debug["ServerMode"] as? String { return serverURL } return Constants.SERVER_PROD }
AppDelegate 활용
... @main class AppDelegate: UIResponder, UIApplicationDelegate { ... func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { ... // OAuth2.0 로그인 설정 setApplicationConfiguration() ... return true } } extension AppDelegate { // MARK: - OAuth2.0 로그인 설정 private func setApplicationConfiguration() { // 서버 모드 var serverMode: String { if let info = Bundle.main.infoDictionary, let debug = info["AppInfo"] as? [String: Any], let serverURL = debug["ServerMode"] as? String { return serverURL } return Constants.SERVER_PROD } AppInfo.shared.setServer(serverMode: serverMode) // MARK: 카카오 로그인 - 설정 KakaoSDK.initSDK(appKey: AppInfo.shared.server.kakao.apiKey, customScheme: "kakao\(AppInfo.shared.server.kakao.apiKey)") // MARK: 네이버 로그인 - 설정 let instance = NaverThirdPartyLoginConnection.getSharedInstance() instance?.appName = AppInfo.shared.server.naver.appName instance?.serviceUrlScheme = AppInfo.shared.server.naver.urlScheme instance?.consumerKey = AppInfo.shared.server.naver.clientId instance?.consumerSecret = AppInfo.shared.server.naver.clientSecret // MARK: 페이스북 로그인 - 설정 Settings.shared.displayName = AppInfo.shared.server.facebook.displayName Settings.shared.appID = AppInfo.shared.server.facebook.appId Settings.shared.clientToken = AppInfo.shared.server.facebook.clientToken } }
CocoaPods 쓴다면 아래 설정도 필수!
https://dchkang83.tistory.com/216
plist 여러개 일때 Podfile 설정
plist는 분리했는데 pod update 하면 메인 plist 파일에만 Embed Pods Frameworks 등이 생성되는 문제를 발견 하였다. 처음에 몰라서 복사해서 다시 생성했는데 시간이 어마무시하게 걸린다. 찾아보니 pod upda
dchkang83.tistory.com
짝짝짝!!
'Language > iOS,AOS' 카테고리의 다른 글
nsurlerrordomain code=-1022, HTTP 프로토콜 허용 (0) 2023.03.17 아이폰 UDID 확인 (0) 2023.03.08 Development로 Archive해서 ipa 파일 다운로드 (0) 2023.03.07 plist 파일 분리를 통한 빌드 환경 분리하기 (0) 2023.03.07 카카오 간편 로그인 속도 개선 (0) 2023.03.06