{"_id":"590a04f6ed80861900cbc783","version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"category":{"_id":"590a04f3ed80861900cbc73f","version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-02T17:55:17.903Z","from_sync":false,"order":7,"slug":"builds-and-tests","title":"Builds"},"parentDoc":null,"project":"55b2d5baa74a380d00e290c4","__v":0,"user":"55b2d5626862a10d00887af9","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-02T00:32:31.354Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"You might have API keys and other secrets that your app needs to consume - either at runtime or during a build. However, you might not want to check these secrets into your source code to make them available to your app.\n\nIn order to securely propagate your credentials to your build and app, buddybuild provides two sets of variables that you can define:\n\n1. [Environment Variables](/docs/environment-variables) (made available to your build time scripts)\n2. [Device Variables](/docs/device-variables-1#section-step-1-create-device-variables-in-buddybuild) (available your App at runtime via the buddybuild SDK)\n3. [Secure Files](doc:secure-files) (files made available to your build time scripts)\n\nLet's get started with Device Variables!\n\n## Step 1: Create Device Variables in buddybuild\n\nLaunch the buddybuild dashboard and click on **App Settings**.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a36b49c-Builds_-_Settings.png\",\n        \"Builds - Settings.png\",\n        1500,\n        483,\n        \"#ecf1f2\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nIn the left navigation, select **Build settings**, then **Device Variables**.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/30402ae-Settings_-_Device_variables_-_menu.png\",\n        \"Settings - Device variables - menu.png\",\n        1500,\n        800,\n        \"#2a82d3\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nEnter a name, value and select **Create.** \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/24b6fd5-Settings_-_Device_variables.png\",\n        \"Settings - Device variables.png\",\n        1500,\n        556,\n        \"#e2e9ea\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nBuddybuild will securely embed your variable into the app when it is built next. Your variable will be consumable via the buddybuildSDK.\n\n## Step 2: Consuming the variable\n\nTo consume the variable in your build, substitute the name of your device variable where applicable (see example below).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"let accessToken = BuddyBuildSDK.valueForDeviceKey(\\\"Facebook_Token\\\")\",\n      \"language\": \"swift\"\n    },\n    {\n      \"code\": \"NSString* accessToken = [BuddyBuildSDK valueForDeviceKey::::at:::\\\"Facebook_Token\\\"];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nThat's it! For more details, refer to our [SDK API guide](doc:sdk-api).\n\nIf you want to consume your variables from within your build instead, follow the [Environment Variables](doc:environment-variables) guide.","excerpt":"","slug":"device-variables-1","type":"basic","title":"Device Variables"}
You might have API keys and other secrets that your app needs to consume - either at runtime or during a build. However, you might not want to check these secrets into your source code to make them available to your app. In order to securely propagate your credentials to your build and app, buddybuild provides two sets of variables that you can define: 1. [Environment Variables](/docs/environment-variables) (made available to your build time scripts) 2. [Device Variables](/docs/device-variables-1#section-step-1-create-device-variables-in-buddybuild) (available your App at runtime via the buddybuild SDK) 3. [Secure Files](doc:secure-files) (files made available to your build time scripts) Let's get started with Device Variables! ## Step 1: Create Device Variables in buddybuild Launch the buddybuild dashboard and click on **App Settings**. [block:image] { "images": [ { "image": [ "https://files.readme.io/a36b49c-Builds_-_Settings.png", "Builds - Settings.png", 1500, 483, "#ecf1f2" ], "sizing": "full" } ] } [/block] In the left navigation, select **Build settings**, then **Device Variables**. [block:image] { "images": [ { "image": [ "https://files.readme.io/30402ae-Settings_-_Device_variables_-_menu.png", "Settings - Device variables - menu.png", 1500, 800, "#2a82d3" ], "sizing": "full" } ] } [/block] Enter a name, value and select **Create.** [block:image] { "images": [ { "image": [ "https://files.readme.io/24b6fd5-Settings_-_Device_variables.png", "Settings - Device variables.png", 1500, 556, "#e2e9ea" ], "sizing": "full" } ] } [/block] Buddybuild will securely embed your variable into the app when it is built next. Your variable will be consumable via the buddybuildSDK. ## Step 2: Consuming the variable To consume the variable in your build, substitute the name of your device variable where applicable (see example below). [block:code] { "codes": [ { "code": "let accessToken = BuddyBuildSDK.valueForDeviceKey(\"Facebook_Token\")", "language": "swift" }, { "code": "NSString* accessToken = [BuddyBuildSDK valueForDeviceKey:@\"Facebook_Token\"];", "language": "objectivec" } ] } [/block] That's it! For more details, refer to our [SDK API guide](doc:sdk-api). If you want to consume your variables from within your build instead, follow the [Environment Variables](doc:environment-variables) guide.