Management of Environment Variables with YAMLs Ver.2

Management of Environment Variables with YAMLs Ver.2

7a78f23eef1b0e883ef44c229a54f0bb?s=128

417.72KI

May 15, 2019
Tweet

Transcript

  1. .BOBHFNFOUPG &OWJSPONFOU7BSJBCMFT XJUI:".-T  QPUBUPUJQT

  2. struct Me { let name = "Takuhiro Muta" let aka

    = "417.72KI" let company = "iRidge inc." let twitter = "417_72ki" let qiita = "417_72ki" let gitHub = "417-72KI" let experience = [ "iOS": "7 years?", "Android": "4 years?" ] let products = [ "BuildConfig.swift", "MockUserDefaults", ] } TFMGEFTDSJQUJPO
  3. $BVUJPO

  4. %FpOJUJPOGPS &OWJSPONFOU7BSJBCMFTJOUIJTTFTTJPO w ❌ w 130%6$5@#6/%-&@*%&/5*'*&3 w 05)&3@48*'5@'-"(4 w FUDʜ

    w ⭕ w )PTUGPS"1* w $VTUPNFS,FZ4FDSFU w FUDʜ
  5. 5PNBOBHF FOWJSPONFOUWBSJBCMFT w YDDPOpH  w 6TFS%FpOFE  w 1SFQSPDFTTPS.BDSPT

     w 0UIFS4XJGU'MBHT
  6. #

  7. 8IZOPU YDDPOpH6TFS%FpOFE w 7BSJBCMFTEFpOFEJOUIFNBSFBMTPOFFEFE UPCFEFpOFEJO*OGPQMJTU w 3JTLPGUZQPDSBTI
 w *OGPQMJTUJTUIFpMFUPNBOBHF l*OGPSNBUJPOz

    let hoge = Bundle.main.object(forInfoDictionaryKey: "Hogehoge") as! String
  8. 8JTI "1*ZNM XFC@VSMZNM DPOGZNM

  9. #VJME$POpHTXJGU

  10. #VJME$POpHTXJGU w $-*UPPMGPS"OESPJEMJLFNBOBHJOHFOWJSPONFOUWBSJBCMFT w .BOBHFWBSJBCMFTVTJOH:".-T+40/T w $BOSFQSFTFOUFOWJSPONFOUWBSJBCMFTJOBIJFSBSDIJDBM TUSVDUVSF w "VUPHFOFSBUF1MJTUBOE4XJGUpMF

    w (FUTUSPOHUZQFEBVUPDPNQMFUFE
 FOWJSPONFOUWBSJBCMFT w 3FTQFDUJOH3TXJGU Т
  11. "OESPJEMJLF

  12. "OESPJE`T#VJME$POpH w 4FUCVJME$POpH'JFMEJOCVJMEHSBEMF w $BOTFUGPSFBDICVJME5ZQFQSPEVDU'MBWPS

  13. CVJMEHSBEMF buildTypes { debug { buildConfigField 'boolean', 'ACCESS_LOG', 'false' buildConfigField

    'String', 'WEBAPI_URL', '"http://dev.example.com/api/"' } release { buildConfigField 'boolean', 'ACCESS_LOG', 'true' buildConfigField 'String', 'WEBAPI_URL', '"http://example.com/api/"' } }
  14. #VJME$POpHKBWB EFCVH public final class BuildConfig { public static final

    boolean DEBUG = Boolean.parseBoolean(“true"); ɾ ɾ ɾ // Fields from build type: debug public static final boolean ACCESS_LOG = false; public static final String WEBAPI_URL = "http://dev.example.com/api/"; }
  15. #VJME$POpHKBWB SFMFBTF public final class BuildConfig { public static final

    boolean DEBUG = false; ɾ ɾ ɾ // Fields from build type: release public static final boolean ACCESS_LOG = true; public static final String WEBAPI_URL = "http://example.com/api/"; }
  16. #VJME$POpHTXJGU "1*ZNM XFC@VSMZNM DPOGZNM #VJME$POpHQMJTU  #VJME$POpHHFOFSBUFETXJGU

  17. 4PVSDF:".-T is_debug: true cognito: provider_key: DevHogeProvider client_id: devhogeclient pool_id: ap-northeast-devhoge

    region_name: ap-northeast-1 CBTFZNM DPHOJUPZNM web_front: terms: https://dev.~ faq: https://dev.~ privacy: https://dev.~ XFC@GSPOUZNM is_debug: false cognito: provider_key: HogeProvider client_id: hogeclient pool_id: ap-northeast-hoge region_name: ap-northeast-1 web_front: terms: https://prod.~ faq: https://prod.~ privacy: https://prod.~ FOWQSPEVDUJPOZNM
  18. 3VO4DSJQU

  19. 3VO4DSJQU if [ "${CONFIGURATION}" = 'Release' ]; then ENVIRONMENT='production' elif

    [ "${CONFIGURATION}" = 'AdHoc' ]; then ENVIRONMENT='staging' else ENVIRONMENT='development' fi ${PODS_ROOT}/BuildConfig.swift/buildconfigswift -o ${SRCROOT}/Libs/BuildConfig_swift -e $ENVIRONMENT ${SRCROOT}/Resources/Config
  20. 3VO4DSJQU if [ "${CONFIGURATION}" = 'Release' ]; then ENVIRONMENT='production' elif

    [ "${CONFIGURATION}" = 'AdHoc' ]; then ENVIRONMENT='staging' else ENVIRONMENT='development' fi ${PODS_ROOT}/BuildConfig.swift/buildconfigswift -o ${SRCROOT}/Libs/BuildConfig_swift -e $ENVIRONMENT ${SRCROOT}/Resources/Config 4FUFOWJSPONFOUDPSSFTQPOEJOHUP#VJME$POpHVSBUJPO
  21. 3VO4DSJQU if [ "${CONFIGURATION}" = 'Release' ]; then ENVIRONMENT='production' elif

    [ "${CONFIGURATION}" = 'AdHoc' ]; then ENVIRONMENT='staging' else ENVIRONMENT='development' fi ${PODS_ROOT}/BuildConfig.swift/buildconfigswift -o ${SRCROOT}/Libs/BuildConfig_swift -e $ENVIRONMENT ${SRCROOT}/Resources/Config 4FUPVUQVUEJSFDUPSZ
  22. 3VO4DSJQU if [ "${CONFIGURATION}" = 'Release' ]; then ENVIRONMENT='production' elif

    [ "${CONFIGURATION}" = 'AdHoc' ]; then ENVIRONMENT='staging' else ENVIRONMENT='development' fi ${PODS_ROOT}/BuildConfig.swift/buildconfigswift -o ${SRCROOT}/Libs/BuildConfig_swift -e $ENVIRONMENT ${SRCROOT}/Resources/Config 4FUEJSFDUPSZDPOUBJOTSFTPVSDF:".-T
  23. #VJME$POpHQMJTU EFWFMPQNFOU

  24. #VJME$POpHQMJTU QSPEVDUJPO

  25. #VJME$POpHQMJTU QSPEVDUJPO w #JOBSZGPSNBUCZUFT w 9.-GPSNBUCZUFT

  26. #VJME$POpHHFOFSBUFETXJGU struct BuildConfig: Codable { static let `default`: BuildConfig =

    .load() let cognito: Cognito let isDebug: Bool let webFront: WebFront } extension BuildConfig { struct Cognito: Codable { let clientId: String let poolId: String let providerKey: String let regionName: String } } extension BuildConfig { struct WebFront: Codable { let faq: String let privacy: String let terms: String } }
  27. #FGPSF let urlString = Bundle.main .object(forInfoDictionaryKey: "WebFrontURL_FAQ") as! String let

    url = URL(string: urlString) webView.load(URLRequest(url: url))
  28. "GUFS let url = URL(string: BuildConfig.default.webFront.faq)! webView.load(URLRequest(url: url))

  29. $VSSFOUUBTL w $BOOPUQBSTFA%PVCMFA w 4VQQPSU.JOUJOTUBMMBUJPO w &TDBQFLFZTXJUISFTFSWFEXPSET w %FNP"QQ

  30. IUUQTHJUIVCDPN,*#VJME$POpHTXJGU