Skip to content

Commit 32f2bde

Browse files
authored
Merge pull request #545 from Esri/Caleb/Fix-LicenseKeySetting
[Fix] Set license key bug
2 parents ca240b0 + 590e496 commit 32f2bde

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Documentation/ConfigureAppSecrets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Note: License strings are not required for development. Without licensing or lic
1212
touch .secrets
1313
```
1414

15-
2. Add your **License String** to the secrets file. Licensing the app will remove the 'Licensed for Developer Use Only' watermark. Licensing the app is optional in development but required for production. Add your **Extension License String** and **API Key** access token to the secrets file if needed. Learn more about how to [Get a license](https://developers.arcgis.com/swift/license-and-deployment/get-a-license/).
15+
2. Add your **License String** to the secrets file. Licensing the app will remove the 'Licensed for Developer Use Only' watermark. Licensing the app is optional in development but required for production. Add your **Extension License String** and **API Key** access token to the secrets file if needed. If the license string is set, an **Advanced Editing** extension will be required to access all the samples, such as those with utility network capabilities. Learn more about how to [Get a license](https://developers.arcgis.com/swift/license-and-deployment/get-a-license/).
1616

1717
```sh
1818
echo ARCGIS_LICENSE_KEY=your-license-key >> .secrets

Shared/SamplesApp.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,19 @@ extension SamplesApp {
3737
/// a watermark on the map view).
3838
func license() {
3939
if let licenseStringLiteral = String.licenseKey,
40-
let licenseKey = LicenseKey(licenseStringLiteral),
41-
let extensionLicenseStringLiteral = String.extensionLicenseKey,
42-
let extensionLicenseKey = LicenseKey(extensionLicenseStringLiteral) {
43-
// Set both keys to access all samples, including utility network
44-
// capability.
45-
_ = try? ArcGISEnvironment.setLicense(with: licenseKey, extensions: [extensionLicenseKey])
40+
let licenseKey = LicenseKey(licenseStringLiteral) {
41+
// Sets the license with an extension if one is included. Both are
42+
// required to access all samples, including utility network
43+
// capabilities.
44+
if let extensionLicenseStringLiteral = String.extensionLicenseKey,
45+
let extensionLicenseKey = LicenseKey(extensionLicenseStringLiteral) {
46+
_ = try? ArcGISEnvironment.setLicense(
47+
with: licenseKey,
48+
extensions: [extensionLicenseKey]
49+
)
50+
} else {
51+
_ = try? ArcGISEnvironment.setLicense(with: licenseKey)
52+
}
4653
}
4754
// Authentication with an API key or named user is required to access
4855
// basemaps and other location services.

0 commit comments

Comments
 (0)