Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

631
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!