コンテンツにスキップ

nsgo.yaml

すべてのビルドが読むプロジェクトファイル:ターゲット、ビルドフラグとタグ、最小システムバージョン、アイコン、起動画面。

name: Hello
id: dev.example.hello # the bundle ID; without it, dev.nsgo. and the name's letters and digits
version: 0.1.0
build_number: 1 # CFBundleVersion and Android's versionCode; else from version
# copyright: © 2026 Example # the Windows executable's details and installer, and the macOS About panel
# appearance: dark # light or dark whatever the system's
# i18n: { dir: locales, source: en } # the app's catalogs and the language they are written in
icon:
apple: assets/AppIcon.icon # macOS, iOS and watchOS, or an .icns for macOS
windows: assets/IconWindows.png # optional Windows artwork
linux: assets/IconLinux.png # optional Linux artwork
png: assets/Icon.png # every other target
tvos: assets/AppIconTV.brandassets # the Apple TV's layered icon and top shelf art, or a wide PNG
watchos: assets/AppIconWatch.icon # the Apple Watch's own, drawn in circles, or a square PNG
android:
png: assets/IconAndroid.png # optional bitmap; valid without adaptive layers
foreground: assets/IconForeground.png # Android's adaptive icon: 432 px, the logo within the center 264 px
background: "#1F1F1F" # a color or a square PNG
monochrome: assets/IconMonochrome.png # optional: the shape Android 13's themed icons tint
dev:
target: native # native, web, ios, ios_simulator, tvos, tvos_simulator, watchos, watchos_simulator, android, harmonyos or miniprogram_<platform>
hot_reload: true # false builds once, watching no files
# icon: { png: assets/Icon-dev.png } # replaces icon's files in dev's builds; defaults to assets/*-dev.*
build:
output: dist
tags: [] # Go build tags every build, test and check of the app takes, such as timetzdata
ldflags: [] # the app's own linker flags, such as -X main.releaseDate=2026-11-17
open: false # true opens the output directory after building
installers: true # false leaves out the disk image, the Windows installer and the Linux packages
jobs: 0 # how many targets build at once; 0 is half the CPUs, 1 one after another
targets: [macos_arm64, macos_x64, windows_arm64, windows_x64, linux_arm64, linux_x64, ios, ios_simulator, tvos, tvos_simulator, watchos, watchos_simulator, android_arm64, web]
# apple: { sign_in_with_apple: true } # the Sign in with Apple entitlement, for iOS, tvOS and Mac App Store builds
# apple: { purchases: true } # StoreKit's library, which in-app purchases go through, in macOS, iOS and tvOS packages
# apple: { privacy: { accessed_apis: { NSPrivacyAccessedAPICategoryDiskSpace: [E174.1] }, tracking: false } } # add required-reason APIs and tracking declarations to PrivacyInfo.xcprivacy
# apple: { requires_full_screen: false } # let an iPad run the app in Split View, Slide Over and Stage Manager, in all four orientations
# apple: { orientations: [portrait, landscape_left] } # the orientations a full-screen app takes on an iPad
# apple: { multiple_scenes: true } # let an iPad open more than one window of the app, each showing the main view with its own state
# apple: { info: { UIBackgroundModes: [audio] } } # background playback for iOS Picture in Picture
# android: { permissions: [REQUEST_INSTALL_PACKAGES] } # manifest permissions beyond the runtime's
# android: { recording: true } # the microphone service microphone.RecordWAV records in, with RECORD_AUDIO, the foreground-service permissions and POST_NOTIFICATIONS, which RecordWAV asks for so its notification shows from Android 13; a refusal still records
# android: { uses_cleartext_traffic: true } # allow plain HTTP to any host in the APK and App Bundle
# android: { background_downloads: true } # dataSync foreground service for cx.Download
# android: { background_motion: true } # explicit finite motion shortService; streams also need a notification title
# android: { loopback_cleartext: true } # allow plain HTTP to loopback in the APK and App Bundle
# commands: [{ name: hello-cli, package: ./cmd/hello-cli }] # command-line programs the desktop packages ship beside the app: see Commands
# windows: { command_line: true } # add <name>.com, a console companion that forwards arguments and streams to <name>.exe; not in store builds
# windows: { path: true } # the installer puts the app's folder on the user's Path, so consoles find its commands
# windows: { publisher: Example Ltd } # the company the Windows executable's details, its installer and the uninstall entry name; else windows.store.publisher_name
# linux: { maintainer: "Jane Doe <jane@example.com>" } # the Linux packages' maintainer, else the app's name
# linux: { categories: [Office, Dictionary] } # the freedesktop menu categories of the app's desktop entry, at least one a main category such as Office, Utility or Game, else menus file it under Other; your own start with X-
# linux: { share: packaging/share } # files the .deb and Arch package install under /usr/share and the AppImage in its usr/share, such as metainfo/<id>.metainfo.xml or bash-completion/completions/<command>
# linux: { depends: { deb: [gstreamer1.0-plugins-good], arch: [gst-plugins-good] }, recommends: { deb: [gstreamer1.0-libav], arch: ["gst-libav: H.264 and AAC video"] } } # packages the .deb and Arch package also depend on and recommend, after GTK 4 and WebKitGTK 6, each as dpkg or pacman writes it
# release: { github: me/hello } # the GitHub repository the install scripts and updates install from, else the Git remote origin's; tag_prefix: v by default
# updates: { key: <public key> } # how the app updates, by platform and channel: see Updates
# store: { dir: store } # store listings directory (YAML and Markdown per language)
# miniprogram: { appid: { wechat: wx0123456789abcdef, alipay: "2021000000000000" }, custom_navigation: false } # the mini programs'

targets や nsgo build -target、nsgo check -target にアーキテクチャなしの OS 名を指定すると、その OS の各アーキテクチャを意味します(windows は windows_arm64 と windows_x64、x86_64 ビルドに NDK が必要な android は android_arm64 のみ)。macos と all には含まれない macos_universal は、両方の macOS アーキテクチャをビルドしてライブラリやウィジェットを含めた 1 つのアプリに結合します。Steam チャンネルはこのユニバーサルアプリバンドルを使用します。インストーラービルドはそれを 1 つのディスクイメージにまとめ、direct チャンネルでは 1 つの Sparkle フィードになります。nsgo test -target もテストを実行するアーキテクチャ名を受け取ります(デスクトップ OS は実行中マシンのアーキテクチャ、Android は arm64)。たとえば x64 Windows マシンで windows_x64 を指定すると windows ターゲットが実行され、実行できないアーキテクチャを指定すると使用すべき名前を添えて拒否されます。

フラグ、タグ、リンカーフラグ

Section titled “フラグ、タグ、リンカーフラグ”

-target、-version、-output などのフラグは対応する設定値を上書きします。-h で全フラグを確認できます。

build.ldflags にはアプリ独自のリンカーフラグを go build の -ldflags と同じ形式で指定します(-X main.releaseDate=2026-11-17 や -X 'main.channel=beta builds' など)。アプリをリンクするすべてのビルド(dev とそのリロード、-embed を含む build、-target を含む test)が全ターゲットでこれらを受け取ります。build や test に -ldflags を指定すると上書きではなく追加になり、複数回指定できます。これらはツール自身の -X フラグより前に渡され、リンカーは変数ごとに最後の指定を採用するため、core.App 内の名前・ID・バージョンは nsgo.yaml の値が維持されます。ツールは Go に独自の -ldflags を渡すため GOFLAGS 内の指定は上書きされるので、リンカーフラグはここへ記載してください。ディレクトリ指定の後ろに付けるヘッドレス test の -ldflags は go test 側のフラグであり、すべてを置き換えます。

build.tags は、ツールがアプリに対して実行するすべての go コマンド(dev とリロード、-embed を含む build、-target を含む test、check)で全ターゲットに適用されます。dev での nsgodev やターゲットテストでの nsgotest など NSGo 自身のタグも追加され、通常は上書きされてしまう GOFLAGS の -tags も引き継がれます。GOFLAGS のその他の指定はそのまま適用されます。

すべてのビルドでは起動時に --nsgo-fps など NSGo 自身のフラグも受け取ります(実行とデバッグ)。nsgo dev では、開いているどのウィンドウからでも Command/Control+R でリロードでき、別のウィンドウでアプリ関数が動き続けている限りメインビューを閉じた後も利用できます。

apple.info.LSMinimumSystemVersion は macOS パッケージの最小 OS バージョンを引き上げ、apple.info.MinimumOSVersion は選択した iOS、tvOS、または watchOS パッケージの最小 OS バージョンを引き上げます。"14.2" や "18.0" のように 1〜3 個の数値パートからなるクォートされたバージョン文字列で指定してください。ランタイムの下限は macOS 13.0(Go 1.27)、iOS 15.0、tvOS 17.0、watchOS 26.0 であり、これより低い値や不正な形式はエラーになります。モバイル用キーは選択したすべてのモバイルターゲットの下限を満たす必要があります。App Clips は独自の app_clip.minimum を持ちます。これらの値はパッケージメタデータ、アセットコンパイル、署名プロジェクト、アプリのリンカーに渡されます。組み込み iOS フレームワークでも使用され、Mac Catalyst では Go の macOS 13 ランタイムのために最低 16.0 となります。

icon.windows と icon.linux には、各アプリパッケージ、インストーラー用画像、ストアロゴに使用する正方形 PNG を指定します。デフォルトは assets/IconWindows.png と assets/IconLinux.png で、存在しない場合は icon.png にフォールバックします。dev.icon も同じ設定と -dev サフィックス付きのデフォルトファイルを受け取ります。icon.android.png はアダプティブレイヤーを設定していない場合も含め、Android 用ビットマップを独立して指定します。その他のターゲットでは共通の icon.png フォールバックが使われます。

Apple TV のアイコンは正方形ではなくレイヤー構造のカードです。tvos には Xcode の .brandassets(App Icon スタックとトップシェルフ画像を含む)または 1280×768 などの横長画像を指定でき、後者の場合はエッジ色で塗りつぶしたカードに合わせて描画し、トップシェルフ画像の中央に配置します。どちらも指定しない場合は、PNG がカードの高さの 4 分の 3 のサイズで配置されます。Apple Watch はアイコンを円形にマスクするため、watchos には watchOS の円向けに描かれた .icon または正方形 PNG を指定します。指定しない場合は apple、次に png が使われます。どちらも apple や png と同様に assets/AppIconTV.* と assets/AppIconWatch.* にフォールバックします。

Android では、icon.android.foreground と background によってランチャーアイコンがアダプティブになり、ランチャーが png を独自のプレート上に縮小配置するのではなく、任意の形状にマスクして動かせるようになります。各レイヤーは 108 dp 四方(432 px にスケーリングされた PNG)です。ランチャーは中央の 72 dp(288 px)を表示し、中央 66 dp(264 px)の外側を切り取る可能性のある形状でマスクするため、ロゴはその円内に収め、背景は正方形全体を満たすようにしてください。background には PNG または "#1F1F1F" のような色を指定します。monochrome はアルファ値のみが意味を持つ形状で、ユーザーがテーマアイコンを有効にした際に Android 13 以降が着色します。指定しない場合、アイコンはその場でも元の色を保ちます。パッケージには通常のビットマップアイコンとして icon.android.png(なければ icon.png)も保持されますが、NSGo が動作する最小バージョンの Android 9 以降のランチャーではアダプティブアイコンより優先されることはありません。png がない場合は、ツールが背景の上にフォアグラウンドを描画して生成します。アダプティブレイヤーがない場合、ランチャーは Android ビットマップまたは共有の png を表示します。

iOS および Android 12 以降で不透明な背景、中央配置の PNG、またはその両方を表示するには launch_screen を設定します。画像パスは nsgo.yaml からの相対パスです。画像は 128 × 128 ポイントまたは dp の範囲内に縦横比を保って収められます。長辺が 512 ピクセル以上の透過 PNG にすると高密度画面でも鮮明に表示されます。

launch_screen:
background: "#F5F1EA"
image: assets/Launch.png
dark:
background: "#201C26"
image: assets/LaunchDark.png

appearance で固定していない限り、システムが外観を選択します。dark 側のいずれかのフィールドを省略すると通常側の値が再利用されます。背景や画像を省略するとプラットフォームのデフォルトが維持されます。組み込みアプリはホスト側から起動画面を取得します。

android.uses_cleartext_traffic: true を指定すると、APK と App Bundle で任意のホストへの平文 HTTP 通信を許可し、マニフェストフラグとネットワークセキュリティポリシーの両方を設定します。このオプトインがない場合でも、android.loopback_cleartext: true を設定すると、アプリ自身が配信する動画などの用途向けに localhost、127.0.0.1、::1 からの平文 HTTP のみを許可します。ループバック限定ポリシーは他のホストへの平文通信を拒否し、両方が true の場合は全ホスト許可の設定が優先されます。組み込み AAR の場合は、ホストアプリの Android ネットワークセキュリティポリシーを設定してください。

core.Native からカスタム View を使用するには、アプリの nsgo.yaml にコンパイル済み Android クラスを列挙します。

android:
classes: [java/BadgeView.jar, java/Helpers.dex]

パスは絶対パスでない限り nsgo.yaml からの相対パスです。各パスには .dex ファイル、または D8 が出力したルートの classes.dex、classes2.dex 以降のシャードを含む JAR を指定します。これらのファイルは D8 で --min-api 28 を指定して準備してください。arm64 向けには、NSGo がこれらのコンパイル済みファイルから Go 単体で APK または App Bundle をビルドします。Android の開発セッションでは、リストされたファイルが変更されると再ビルドが行われます。組み込み AAR の場合は、ホストの Android ビルド側で Java 依存関係を提供します。D8 ドキュメント

Android ネイティブサンプルでは、パブリックな Context コンストラクターを持つクラスを登録し、Go の prop で設定する例を示しています。