> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-mobile/using-autify-nocode-mobile/scenario-creation-and-maintenance/environment-variables.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# 環境変数

## 環境変数とは

**注意：この機能を利用する前に、起動時引数を処理するコードの定義を開発者の方に実施していただく必要があります。**

環境変数とはiOSでは起動時変数のことを指します。この機能の振る舞いは、アプリ内にあらかじめ定義されたコードによって変化します。コード側を変更後、この機能を用いて特定の値をアプリに渡すことができます。環境変数の利用例としては以下のものがあります。

* サーバのエンドポイントをそれぞれのシナリオごとに変更する
* アプリの状態をシナリオ毎に変更する

## アプリ側への変更

この機能を利用するためには、アプリ側で起動時変数を処理できるようになっている必要があります。以下Swiftでのサンプルコードです。サンプルコードの`<Key>`の値はAutifyで登録するKeyと同じである必要があります。

```
#if DEBUG 
    if ProcessInfo.processInfo.environment["<Key>"] != nil { 
        // Do something 
    } 
#endif
```

SwiftのProcessInfoクラスの詳細な情報はAppleの公式ドキュメントを参照してください。

* [ProcessInfo | Apple Developer](https://developer.apple.com/documentation/foundation/processinfo)

## 環境変数の作成

### iOS

1. 左サイドバー内の **環境変数** をクリック

![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-1f433664c3683852fad48b935dba5843e6732322%2Fenvironment_variables_ja\(1\).png?alt=media)

2. **"iOS"** タブをクリック
3. **"環境変数作成"** をクリックし、必要なデータを指定します

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-75af7cc3f3e78ec5ca4dc4c8c7552a9fa960b10a%2Fios_ev.png?alt=media)

それぞれの入力項目の説明は以下の通りです。

* 名称
  * 設定する環境変数を識別するための、ユニークな値
* Key
  * 変数名
* Value
  * 変数値
* 説明（任意）
  * 環境変数の説明

3. **"作成"** をクリック

### Android

{% hint style="warning" %}
Androidの環境変数を利用する際は、**"appPackage” と “appActivity” の指定が必須です。**
{% endhint %}

1. 左サイドバー内の **環境変数** をクリック
2. **“Androidタブ”** を押下
3. **“スタートアクティビティ作成”** を押下

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-5b47f6ba746fba277cfaefaf46442efb98356654%2FAndroid_environment_variables.png?alt=media)
4. 必要データを指定します ※ 上述しておりますように、Androidで環境変数を利用する場合、**"appPackage” と “appActivity” の指定** が必須です。Keyから選択し、それぞれ作成してください。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-22c876090359ae8c1aad9e9e45aa2064494683fb%2Fkey_ja\(1\).png?alt=media)

   よく利用するキーと値の説明：

   * **appPackage（必須）**
     * Package名
     * 値の例：

       `com.example.app`
   * **appActivity（必須）**
     * Activity名
     * 値の例：

       `.ExampleActivity`
   * **optionalIntentArguments (任意）**

     * インテント引数。このキーを利用する場合にその値は、[公式ドキュメント “インテント引数の指定”](https://developer.android.com/studio/command-line/adb#IntentSpec) にあるようにオプションを含めたものを指定してください。
     * 値の例：

     | Name      | Key                     | Value                     |
     | --------- | ----------------------- | ------------------------- |
     | Example 1 | optionalIntentArguments | --es API\_URL example.com |
     | Example 2 | optionalIntentArguments | --el USER\_ID 127         |
5. **"作成"** をクリック

## 環境変数の編集、削除

環境変数の編集と削除は環境変数一覧よりご利用いただけます。

![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-13014ae45abec6976bf0d570a0c5fc5bfedce6da%2FCleanShot_2022-04-12_at_16.51.53.png?alt=media)

## シナリオで環境変数を利用する

新規および既存のシナリオもしくはステップグループ作成する時に、ビルドファイル選択画面にて環境変数を利用することができます。

1. 対象のビルドファイルを選択
2. **環境変数を設定する** を選択

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-09258833717b652a81909a6fdb2920f84a6ba1c2%2FCleanShot_2022-04-12_at_16.53.23.png?alt=media)
3. 使用する環境変数を選択

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-0c260a0d45345a4e9d97e0dd864aeab6f6f65ce3%2FCleanShot_2022-04-12_at_16.54.05.png?alt=media)
4. **決定** を選択

## その他

* 環境変数の登録上限数はありません。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-mobile/using-autify-nocode-mobile/scenario-creation-and-maintenance/environment-variables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
