asc-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

asc init — Project Context Initialisation

asc init — 项目上下文初始化

Saves the app ID, name, and bundle ID to
.asc/project.json
in the current directory. Future commands and agents read this file instead of calling
asc apps list
every session.
将App ID、应用名称和Bundle ID保存到当前目录下的
.asc/project.json
文件中。后续的命令和Agent会读取该文件,无需每次会话都调用
asc apps list

Commands

命令

init — pin project context

init — 固定项目上下文

bash
undefined
bash
undefined

Direct (no API list call)

直接指定(无需调用API列表)

asc init --app-id <id> [--pretty]
asc init --app-id <id> [--pretty]

By name (case-insensitive search)

通过名称搜索(不区分大小写)

asc init --name "My App" [--pretty]
asc init --name "My App" [--pretty]

Auto-detect from *.xcodeproj/project.pbxproj in cwd

自动检测当前目录下的*.xcodeproj/project.pbxproj文件

asc init [--pretty]

Priority: `--app-id` > `--name` > auto-detect.
asc init [--pretty]

优先级:`--app-id` > `--name` > 自动检测。

What Gets Saved

保存的内容

./.asc/project.json
:
json
{
  "appId":    "1234567890",
  "appName":  "My App",
  "bundleId": "com.example.myapp"
}
./.asc/project.json
:
json
{
  "appId":    "1234567890",
  "appName":  "My App",
  "bundleId": "com.example.myapp"
}

JSON Output

JSON输出

json
{
  "data": [
    {
      "affordances": {
        "checkReadiness": "asc versions check-readiness --version-id <id>",
        "listAppInfos":   "asc app-infos list --app-id 1234567890",
        "listBuilds":     "asc builds list --app-id 1234567890",
        "listVersions":   "asc versions list --app-id 1234567890"
      },
      "appId":    "1234567890",
      "appName":  "My App",
      "bundleId": "com.example.myapp"
    }
  ]
}
json
{
  "data": [
    {
      "affordances": {
        "checkReadiness": "asc versions check-readiness --version-id <id>",
        "listAppInfos":   "asc app-infos list --app-id 1234567890",
        "listBuilds":     "asc builds list --app-id 1234567890",
        "listVersions":   "asc versions list --app-id 1234567890"
      },
      "appId":    "1234567890",
      "appName":  "My App",
      "bundleId": "com.example.myapp"
    }
  ]
}

Typical Workflow

典型工作流程

bash
undefined
bash
undefined

1. Run once per project directory

1. 每个项目目录仅需运行一次

cd /path/to/MyApp asc init --pretty
cd /path/to/MyApp asc init --pretty

2. In subsequent sessions, read the saved context

2. 在后续会话中,读取已保存的上下文

APP_ID=$(jq -r '.appId' .asc/project.json)
APP_ID=$(jq -r '.appId' .asc/project.json)

3. Use normally — no need for asc apps list

3. 正常使用,无需运行asc apps list

asc versions list --app-id "$APP_ID" asc builds list --app-id "$APP_ID"
undefined
asc versions list --app-id "$APP_ID" asc builds list --app-id "$APP_ID"
undefined

Auto-detect Logic

自动检测逻辑

When no flags are given,
asc init
scans
*.xcodeproj/project.pbxproj
files in the current directory and extracts
PRODUCT_BUNDLE_IDENTIFIER
values. It then matches those bundle IDs against your App Store Connect apps.
Variable references like
$(PRODUCT_BUNDLE_IDENTIFIER)
are skipped — only literal values are matched.
当未指定任何参数时,
asc init
会扫描当前目录下的
*.xcodeproj/project.pbxproj
文件,提取
PRODUCT_BUNDLE_IDENTIFIER
的值。然后将这些Bundle ID与你的App Store Connect应用进行匹配。
会跳过
$(PRODUCT_BUNDLE_IDENTIFIER)
这类变量引用,仅匹配字面量值。

Error Cases

错误场景

SituationError
--name
given but no app matches
No app named '…'. Run asc apps list to see available apps.
Auto-detect: no
.xcodeproj
found
No Xcode project found. Use --app-id or --name.
Auto-detect: bundle IDs don't match any ASC app
No ASC app matched bundle IDs: com.example.app
场景错误信息
指定
--name
但未找到匹配的应用
未找到名为'…'的应用。请运行asc apps list查看可用应用。
自动检测:未找到
.xcodeproj
文件
未找到Xcode项目。请使用--app-id或--name参数。
自动检测:Bundle ID未匹配到任何ASC应用没有ASC应用匹配以下Bundle ID:com.example.app

See Also

另请参阅

  • Full feature doc:
    docs/features/init.md
  • Follow affordances from the output to list versions, builds, or app infos without knowing the app ID
  • 完整功能文档:
    docs/features/init.md
  • 可根据输出中的affordances,在不了解App ID的情况下列出版本、构建版本或应用信息