跳到內容

應用程式商店

建置商店套件,發佈到 Google Play 和 App Store Connect,撰寫商店資訊,發佈資源包與 Steam depot。

使用 -channel store 或 updates.channel: store 會為各平台商店建置桌面與 Android 目標(由商店負責更新,藉此取代自行安裝程式與安裝腳本):

目標平台 商店封裝檔
macOS 供 Mac App Store 使用的 <name>-<version>-macos-<arch>.pkg:應用程式運行於 App 沙盒中,以描述檔的身分憑證簽署,並以團隊的 Installer 身分憑證打包
Windows 供 Microsoft Store 使用的 <name>-<version>-windows-<arch>.msix,發佈時將由商店進行簽署
Linux 可直接安裝的 <name>-<version>-linux-<arch>.flatpak,外加附帶 AppStream 資料的 .tar.gz 與適用於 Flathub 或 flatpak-builder(基於 GNOME 執行階段)的 flatpak/<id>.yml
Android <name>-<version>-android-<arch>.aab,供 Google Play 使用、以 sign.keystore 上傳金鑰簽署的 App Bundle

MSIX 會從語系目錄中的 appName 讀取各語言的顯示名稱,若無則退回使用來源語言。其「開始」功能表、工作列與 Store 標誌包含 100%、125%、150%、200% 與 400% 變體。工具可在 macOS 上直接產生資源索引,無需 Windows SDK。

在 store 渠道下指定 -target macos 會同時選取兩種 macOS 架構並輸出單一 <name>-<version>-macos-universal.pkg,效果與 -target macos_universal 相同。指定 -target android_arm64,android_x64 則會輸出同時包含 arm64-v8a 與 x86_64 的單一 <name>-<version>-android-universal.aab。其中 x86_64 切片需要 Android NDK。

macos:
category: public.app-category.productivity # LSApplicationCategoryType, which the Mac App Store requires
# entitlements: { com.apple.security.files.downloads.read-write: true } # beyond the network, the files the user picks and what apple.info explains
windows:
store: # as Partner Center's Product identity lists them
identity: 12345Example.Hello
publisher: CN=00000000-0000-0000-0000-000000000000
publisher_name: Example
# device_capabilities: [microphone, webcam] # the devices the app uses, which Windows asks the user for
linux:
summary: Says hello # one line for software centers
license: MIT # an SPDX expression; LicenseRef-proprietary by default
# flatpak_runtime: "51" # GNOME's runtime version
android:
target_sdk: 36 # the targetSdkVersion Google Play requires
sign:
macos_profile: assets/MacAppStore.provisionprofile # the Mac App Store's profile
# installer: "3rd Party Mac Developer Installer: Example (ABCDE12345)" # by default the keychain's of the profile's team

未設定 android.target_sdk 時,執行階段預設以 API 36 為目標。低於 API 36 的 Android App Bundle 建置將會失敗,因為 Google Play 要求自 2026 年 8 月 31 日起所有新行動應用程式與更新皆須符合此標準。獨立 APK 建置則僅會發出警告並繼續建置。

設定 sign.macos_profile 即可簽署供上傳使用的 Mac 封裝檔。在沒有小工具的情況下,未簽署的套件仍可在沙盒中執行,方便你測試對應用程式容器、網路以及使用者選取檔案的存取。包含小工具的商店建置則必須同時提供 <id> 的 sign.macos_profile 以及 <id>.widgets 的 macOS 版 sign.widgets_profile,兩者須屬於同一團隊並授予 apple.app_group(預設為 group.<id>)。兩個套件皆會使用該共用容器;不會新增家目錄例外權限。-installers=false 會保留沙盒與描述檔簽署,僅略過產生 .pkg 與其 Installer 身分簽署。請分別在合作夥伴中心(Partner Center)上傳 .msix,並在 Play Console 上傳 .aab。當 GitHub 發佈包含 flatpak/<id>.yml 所指名的封存檔後,即可將其提交至 Flathub。flatpak-builder 亦可在本地建置。可使用 flatpak install --user ./<name>-<version>-linux-<arch>.flatpak 安裝套件;系統必須已安裝或可從已設定的遠端取得對應的 GNOME 執行階段。工具本身僅用 Go 即可建置套件,無需 Linux 工具鏈。當缺乏圖示美術圖檔時,商店封裝檔會使用透明圖示;若未設定 linux.categories,則預設使用 Utility。若要在商店之外安裝 MSIX,請設定 sign.certificate 來簽署 MSIX;其憑證主體必須與 windows.store.publisher 相符,且接收機器必須信任該憑證。若未設定簽署資訊,上傳至商店時將由商店代為簽署。

啟用 Google Play Developer API,並授予服務帳戶將應用程式發佈至指定測試軌道的權限。將 NSGO_PLAY_SERVICE_ACCOUNT 設為該帳戶的 JSON 金鑰內容或其金鑰檔案路徑。Google Play API 設定指南

go tool nsgo build -target android -channel store
go tool nsgo publish -target android -track internal

該命令會在 build.output/releases 中尋找符合專案版本的 App Bundle。當存在多個建置檔案時,可在旗標後方傳入 .aab 路徑以指定檔案。軌道可傳入 internal、production 或封閉測試的軌道 ID。命令會從套件中讀取套件名稱與版本代碼,要求版本代碼必須高於該軌道上的所有現有發佈版本,隨後上傳套件並提交發佈。

商店中繼資料(標題、副標題、說明、關鍵字、更新說明、網址、螢幕截圖與預覽影片)以純文字 YAML 與 Markdown 形式存放在版本庫的 store/(或 nsgo.yaml 中的 store.dir)目錄下:

store/
listing.yaml # version: 1, default_locale, app_store and google_play settings
en-US/
listing.yaml # version: 1, title, subtitle, short_description, keywords, URLs, media
description.md # full description (optional file in place of YAML description)
release_notes.md # what's new (optional file in place of YAML release_notes)
promotional_text.md # App Store promotional text (optional file)
screenshots/
zh-Hans/
listing.yaml
description.md
release_notes.md
screenshots/

兩個 listing.yaml 檔案皆必須包含 version: 1 且拒絕任何未知鍵值。除非透過 app_store.locale 或 google_play.locale 針對特定商店覆寫,否則標準語系目錄(如 zh-Hans)會自動對應至各商店的語系代碼(App Store Connect 為 zh-Hans,Google Play 為 zh-CN)。

go tool nsgo publish -store all -dry-run # validate lengths, locales and media without uploading
go tool nsgo publish -store appstore,play # validate and upload to App Store Connect and Google Play
go tool nsgo publish -store play -track production # also update release notes on the named Play track

驗證會在讀取憑證或發送任何 HTTP 請求前執行,檢查必填欄位、語系代碼、網址協定、媒體檔案與數量(App Store 每個顯示類型最多 10 張螢幕截圖與 3 部預覽影片;Google Play 每個圖片類型最多 8 張螢幕截圖),以及字元長度限制(App Store:標題 30、副標題 30、關鍵字 100、宣傳文字 170、說明 4000、更新說明 4000;Google Play:標題 30、簡短說明 80、完整說明 4000、更新說明 500)。

上傳憑證僅從環境變數讀取:App Store Connect 使用 NSGO_APP_STORE_KEY、NSGO_APP_STORE_KEY_ID 與 NSGO_APP_STORE_ISSUER(若未設定則退回使用公證金鑰 NSGO_NOTARY_KEY、NSGO_NOTARY_KEY_ID 與 NSGO_NOTARY_ISSUER);Google Play 則使用 NSGO_PLAY_SERVICE_ACCOUNT(服務帳戶 JSON 檔案路徑或 JSON 純文字)。

使用 nsgo.yaml 追蹤各項發佈問卷的完成狀態。

compliance:
app_store: { age_rating: false }
google_play: { data_safety: false }
steam: { content_survey: false }

完成對應的問卷後,將項目設為 true。對應的 -channel store 或 -channel steam 建置會針對仍為 false 的項目發出提醒。若不打算在 YAML 中追蹤特定項目,可將其省略。

  • 在 App Store Connect 中完成年齡分級問卷與 App 隱私權詳細資訊。
  • 針對 Apple 的加密出口合規問卷,請將 apple.info.ITSAppUsesNonExemptEncryption 設為代表應用程式答案的 YAML 布林值。若 Apple 核發了核准代碼,請以字串形式填入 apple.info.ITSEncryptionExportComplianceCode。你也可以省略這些鍵值並在提交時手動回答。Apple 商店建置會檢查這些鍵值的型別以及套件隱私權清單的結構。
  • 在 Play Console 中完成資料安全性表單。僅於內部測試軌道發佈的應用程式可豁免。
  • 在提交遊戲審查前,於 Steamworks 完成內容問卷。

在 App Store Connect 中建立應用程式,並使用 App Store 發佈描述檔簽署 iOS 實機 IPA,或使用團隊的 Installer 身分憑證簽署 macOS 商店 PKG。在裝有 Xcode 的 Mac 上,將 NSGO_APP_STORE_KEY 設為 App Store Connect 團隊金鑰的 .p8 檔案路徑或其內容,NSGO_APP_STORE_KEY_ID 設為金鑰 ID,NSGO_APP_STORE_ISSUER 設為發行者 ID;若未設定,則會像商店上架資訊一樣使用公證金鑰(NSGO_NOTARY_KEY、NSGO_NOTARY_KEY_ID、NSGO_NOTARY_ISSUER)。請賦予該金鑰存取該應用程式及上傳建置版本的權限。

go tool nsgo publish ios path/to/Hello.ipa
go tool nsgo publish macos path/to/Hello.pkg

工具會在上傳前檢查套件的組建編號,並回報 Apple 對 TestFlight 的處理結果。下次上傳時請遞增 build_number。macOS 的組建編號必須跨所有應用程式版本持續遞增,而 iOS 在新版本時可重新開始編號序列。處理完成後,請在 App Store Connect 中另行提交進行 App 審查。Apple 發佈指南

在 macOS 與 iOS 上,捲動檢視的邊緣效果(Scroll.EdgeEffects)、未設定 IOS.BackdropMaterial 的 macOS 背景模糊,以及背景色彩濾鏡(單獨使用,或疊加於未設定 IOS.BackdropMaterial 的模糊之上)皆透過 Core Animation 的私有 CABackdropLayer 與 CAFilter 繪製(如同 AppKit 與 UIKit 自身的材質與邊緣效果一樣),因為沒有公開 API 能依半徑進行模糊、在檢視上漸變模糊半徑,或套用背景色彩矩陣。App Store 審查可能會拒絕使用私有 API 的應用程式:NSGo 僅在帶有邊緣條的捲動檢視與上述背景濾鏡時才會呼叫它們,但所有 macOS 與 iOS 建置皆會包含其符號名稱。

build 產生的每個 Apple 套件(包含主應用程式、小工具擴充功能、App Clip、Apple Watch 應用程式以及 -dynamic -embed 框架)皆附帶隱私權清單 PrivacyInfo.xcprivacy,宣告 NSGo 與 Go 執行階段所使用的必要原因 API(required-reason API):使用者預設值(CA92.1)、檔案時間戳記(C617.1)以及系統開機時間(35F9.1)。apple.privacy 可加入應用程式自身的宣告:accessed_apis(每個類別的原因代碼)、tracking、tracking_domains 與 collected_data(依 Apple 命名規則填入 NSPrivacyCollectedDataTypes 項目);若 resources/ 中已存在 PrivacyInfo.xcprivacy,則會與這些設定合併而非直接覆蓋。

build 為實機產生的每個 iOS、tvOS 與 watchOS 套件(主應用程式、小工具擴充功能與 App Clip)之 Info.plist 皆會帶入 App Store Connect 檢查的 SDK 與 Xcode DT 鍵值(取自建置所用的 Xcode),以及 UIRequiredDeviceCapabilities: [arm64];模擬器套件則省略這些鍵值,且 apple.info 所設定的鍵值會保留其原值。apple.multiple_scenes: true 會在 iOS 應用程式的場景清單中啟用 UIApplicationSupportsMultipleScenes(預設為 false):在 iPad 上使用者即可同時開啟多個應用程式視窗,每個視窗都會重新呈現應用程式主檢視並擁有各自獨立的狀態,同時共享應用程式的訊號與儲存空間,直到使用者關閉該視窗為止。

在 mobile.asset_packs 中宣告大型資源目錄。這些目錄中的檔案會與基礎 Android App Bundle 及 iOS 應用程式分開傳遞。資源包名稱必須以小寫英文字母開頭,且僅能包含小寫英文字母、數字與底線。

mobile:
asset_packs:
- {name: levels, dir: resources/levels, delivery: install-time}
- {name: voices, dir: large-assets/voices, delivery: fast-follow}

使用 go tool nsgo build -channel store -target android_arm64 建置 Android 資源包。使用 bundletool build-apks --local-testing 與 bundletool install-apks 在實機上測試套件。NSGo 支援開啟已安裝的 install-time 資源包。fast-follow 模組已包含於套件中以供 Play 傳遞,而透過 Play Asset Delivery SDK 讀取該類資源包的功能仍在待辦規劃中。

在 iOS 上,go tool nsgo build -target ios 會將 install-time 對應至 Apple 的 essential 原則,並將 fast-follow 對應至 prefetch 原則,同時適用於首次安裝與更新。需要 Xcode 26 或更新版本才能建置 Background Assets 下載器。請使用共用的 apple.app_group 或預設的 group.<id>。主應用程式的 sign.profile 與 <id>.assetdownloader 擴充功能的 sign.asset_packs_profile 兩者皆須包含該群組。請使用 App Store Connect 的資源包上傳工作流程,將 dist/releases 中的 .aar 檔案連同 IPA 一併上傳。建立受管資源包

在 goroutine 中呼叫 mobile.AssetPackReady(ctx, "levels") 檢查資源包是否就緒,並呼叫 mobile.OpenAssetPackFile("levels", "intro.map") 開啟相對於宣告目錄的檔案。使用完畢後請關閉回傳的讀取器。本機測試 Apple 資源包

go tool nsgo build -channel steam -target macos_universal,windows_x64,linux_x64

設定 updates.channel: steam 可將其設為預設渠道。選取 macOS、Windows 與 Linux 目標。將每個 dist/<name>-<version>-<target> 目錄上傳至其對應的 Steam depot,並設定啟動選項:macOS 使用應用程式套件,Windows 與 Linux arm64 使用執行檔,Linux x64 則使用 steam-launch.sh。更新由 Steam 處理。這些目錄不包含安裝程式、自我更新器或 steam_appid.txt。

Linux x64 depot 包含適用於 Steam Linux Runtime 3.0 與 4.0 的 GTK 4 及其相依函式庫。僅當系統缺少 GTK 4.14 或更新版本時,啟動器才會使用它們。請將 nsgo-gtk/ 保留在啟動器旁:其中的 licenses/ 存放這些函式庫的授權條款、建置來源原始碼資訊與建置腳本,以符合 LGPL 對 GLib、Pango 與 GTK 的授權要求。Linux arm64 則需要執行環境中已提供 GTK 4。

若要在 Steam 用戶端之外進行本機測試,請在 nsgo.yaml 中設定 steam: {app_id: 480}(將 480 替換為你的 Steamworks App ID)。go tool nsgo dev 會將該 ID 寫入原生建置目錄中的 steam_appid.txt,並以該目錄作為工作目錄啟動應用程式。Steamworks API、SteamPipe。