Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

632
Visualizações
How to use Code value in the info.plist file xcode ios

I want to use some custom constants in info.plist file to use it globally e.g

<key>FacebookAppID</key>
<string>$(my_custom_constant)</string>
  1. how to make this constant?
  2. how can I differentiate it by selecting debug and release mode.e.g. FacebookAppID is "abc" for debug mode and "xyz" for release mode.
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Set your custom variable in info.plist as shown below. I have taken "HockeyAppID" as example here.

enter image description here

Next, Add a variable in Build Settings under "User-Defined" for Debug and Release configuration in your case as shown below. Here, I have my own four different configurations.

enter image description here

As you know, different configuration values will be loaded at runtime based on the settings in scheme. In order to access HockeyAppId for Debug / Release configuration from info.plist, do the following.

 enum InfoPlistKey {
   static let hockeyappID = "HockeyAppID"
 }

 struct AppSettings {

   private static var infoDict: [String: Any] {
      if let dict = Bundle.main.infoDictionary {
          return dict
      } else {
          fatalError("Info Plist file not found")
      }
   }

   static let hockeyAppID = infoDict[InfoPlistKey.hockeyappID] as! String
 }

Now, you can access HockeyAppId value from Info.plist as ,

let identifier = AppSettings.hockeyAppID

Please let me know in case of any issues.

over 4 years ago · Santiago Trujillo Relatório

0

You can create the variable by adding it as a "User-Defined Setting" to your target, in Build Settings. You can then set the variable value to different things for each of your build configurations.

Please see attached screenshot. You can ignore my Beta Prod and Beta Test configurations, as they probably don't apply to your situation.

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda