Build, test and release (Mac version)
- Source layout
- Build, test and release (this page)
- UI languages and help
Requirements
- A Mac with Xcode or its command line tools (Swift 5.5 or later;
Package.swiftuses swift-tools-version 5.5) - The resulting app runs on macOS 11 or later (the platforms in
Package.swift, and LSMinimumSystemVersion 11.0 in Info.plist). - Sparkle is kept at 2.9.x so the app still runs on macOS 11 (2.10 requires macOS 12). The TeraMac target also defines
NS_SWIFT_SENDABLEas empty for SDKs that lack it (it is only an annotation, so behavior does not change). - You need the whole repository, including the upstream files outside
macos/:scripts/bundle.shreads../installer/releaseand../teraterm/common/helpid.h.
Building and running
Run all commands in macos/.
cd macos swift build # debug build (.build/debug/TeraMac) ./scripts/bundle.sh # makes "build/Tera Term Mac.app" (for this Mac only; fast) open "build/Tera Term Mac.app" ./scripts/bundle.sh --universal # Apple Silicon and Intel ./scripts/bundle.sh --dmg # universal build, distribution DMG, notarization
When you run a plain swift build binary, UI languages and help are read from the source tree (macos/Resources and upstream installer/release/lang_utf8). Automatic updates only start when Info.plist has SUFeedURL (that is, in an app made by bundle.sh).
What bundle.sh does
- Builds with
swift build -c release(with--arch arm64 --arch x86_64for--universal/--dmg) and shrinks the executable withstrip -x. - Creates
build/Tera Term Mac.appand copies in:- Sparkle.framework (without headers and XPC services)
- the icon (Resources/AppIcon.icns) and LICENSE
- upstream
installer/release/TERATERM.INI(default settings) - upstream
installer/release/lang_utf8/*.lngandResources/lang/mac_*.lng(UI languages) - upstream
installer/release/theme(sample themes) - the help in
Resources/help-mac/{ja,en}(html/, teraterm.hhp, modern-toc.json) and upstreamteraterm/common/helpid.h. Images (*.png) are left out (see help images)
- Writes Info.plist. The version is
VERSIONin bundle.sh (it can also be set with theVERSIONenvironment variable); the bundle ID can be changed withBUNDLE_ID. The .ttl document type and the Sparkle settings (SUFeedURL, public key and so on) are written here too. - Signs the app. If the keychain has a "Developer ID Application" certificate, it is used (Sparkle's parts first, with hardened runtime and timestamp); otherwise the app is ad-hoc signed. The
SIGN_IDenvironment variable selects a certificate. - With
--dmg, creates a DMG (build/TeraTermMac-<version>.dmg) containing the app and a link to Applications. The background is drawn byscripts/make_dmg_bg.swift, and Finder is scripted to set the window size and icon positions. - When signed with Developer ID, the DMG is signed as well, notarized with
xcrun notarytooland stapled. Store notarytool credentials in the keychain beforehand withxcrun notarytool store-credentialsand pass the profile name in theNOTARY_PROFILEenvironment variable. Notarization is skipped if no stored credentials are found orSKIP_NOTARY=1is set.
Tests
swift test # all tests swift test --filter TTLTests # one test class swift test --filter TerminalTests/testXxx # one test
The tests are in Tests/TeraCoreTests and cover TeraCore (terminal emulator, TTL macros, file transfer, TEK, key maps, INI files, connection settings and more).
TTLUpstreamTestsruns upstreamtests/*.ttlwithout a window and lists which line failed with which error. Many of those macros need interaction or a connection, so it only runs whenTERAMAC_UPSTREAM_REPORTnames a report file.TERAMAC_UPSTREAM_REPORT=report.txt swift test --filter TTLUpstreamTests
TTLBenchTestsmeasures macro speed. It is skipped in debug builds; run it with a release build.swift build -c release -Xswiftc -enable-testing --build-tests
Self-test environment variables
Starting the app executable ("build/Tera Term Mac.app/Contents/MacOS/TeraMac") with these environment variables makes it check its own appearance or behavior.
| Variable | Behavior |
|---|---|
| TERAMAC_SNAPSHOT=<folder> | Writes windows and dialogs as PNG files and quits (term.png, about.png, credits.png, connect.png, setup.png, schemes.png, menu_editor.png, menu_details.png and others). Along the way it runs a macro (test.ttl) that connects to the local shell and writes the screen text to shell.txt. The TeraTerm Menu windows are captured with sample entries, and the user's entries are restored at the end. Automatic updates and the offer to move to Applications are suppressed |
| TERAMAC_TCPPORT=<port> | In the TERAMAC_SNAPSHOT macro, connects to that port on 127.0.0.1 as raw TCP and checks that the sent text comes back (provide an echo server) |
| TERAMAC_SERIAL=<device> | In the TERAMAC_SNAPSHOT macro, opens that serial port at 115200 bps, sends serial-ping and waits for serial-pong |
| TERAMAC_LOGINPORT=<port> | With TERAMAC_SNAPSHOT, actually runs a TeraTerm Menu auto login (connects to that port on 127.0.0.1 with /T=0) and writes the screen text to menu_login.txt |
| TERAMAC_TABSNAP=1 | Used with TERAMAC_SNAPSHOT. Opens two tabs and captures the whole window (tabs.png), the setup sheet, a live font preview and whether Cancel restores it |
| TERAMAC_SETUP_SNAPSHOT=<folder> | When the Additional settings sheet opens, writes every tab as setup-<number>-<name>.png, plus the TTSSH / TTProxy dialogs |
| TERAMAC_DEBUG_WINDOWS=<file> | Two seconds after launch, writes the visible windows (class, title, size) and the application menu items to the file |
| TERAMAC_MENUBAR_TEST=<log> | Opens the in-window menu bar, moves the mouse to the next title and logs whether the menu switches |
| TERAMAC_INI_DRYRUN=<ini> | Writes the result of importing a TERATERM.INI (applied and skipped settings, hosts, font and more) and quits, without changing settings. Output goes to TERAMAC_INI_OUT (default: standard output) |
| TERAMAC_TTMENU_TEST=<ttpmenu.ini> | Reads ttpmenu.ini, writes it back (<ini>.written.ini), reads it again, writes the result to <ini>.out.txt and quits. Nothing is saved |
| TERAMAC_FEED_URL=<URL> | Changes the appcast.xml that automatic updates check (file:// URLs work) |
| TERAMAC_UPDATE_TEST=<log> | Without UI, checks for an update, downloads it and installs it, logging the steps |
In addition, TERAMAC_PROXY_* variables are how the app passes proxy settings to its ssh ProxyCommand (TeraMac --proxy-connect <host> <port>). --purge-keychain is an argument used by the uninstaller; it deletes saved passwords and quits.
Generators
| Script | Output |
|---|---|
| scripts/gen_charwidth_tables.py | Generates Sources/TeraCore/CharWidthTables.swift from upstream unicode_asian_width.tbl, unicode_combine.tbl and unicode_emoji.tbl in teraterm/teraterm.python3 scripts/gen_charwidth_tables.py [teraterm/teraterm folder] |
| scripts/gen_sbcs_tables.py | Generates Sources/TeraCore/SBCSTables.swift from upstream teraterm/teraterm/mapping/*.map.python3 scripts/gen_sbcs_tables.py [mapping folder] |
| scripts/notes2html.py | Converts release notes (the same Markdown as on GitHub Releases) into HTML for Sparkle's update window. Only paragraphs, headings, bullet lists, code, bold and links are supported. Called by appcast.sh.python3 scripts/notes2html.py notes.md > notes.html |
| scripts/make_icon.swift | Makes AppIcon.iconset from the upstream icon (teraterm/common/teraterm.ico) |
| scripts/make_dmg_bg.swift | Draws the DMG background (called by bundle.sh) |
Do not edit the generated .swift files by hand; run the scripts again instead.
Release flow
- Bump
VERSIONinscripts/bundle.sh. - Build the DMG with
./scripts/bundle.sh --dmg(signed and notarized). - Create
v<version>on GitHub Releases and uploadTeraTermMac-<version>.dmg. - Run
./scripts/appcast.sh <version> build/TeraTermMac-<version>.dmg [notes.md]to rewritemacos/appcast.xml, and push it to main. The app watches this appcast.xml (SUFeedURL in Info.plist) to find new versions.
appcast.sh signs the DMG with an EdDSA (ed25519) signature using Sparkle's sign_update (default tools/sparkle/sign_update, taken from bin/ of a Sparkle release; override with SIGN_UPDATE). The private key is read from a key file rather than the keychain; its location can be set with the SPARKLE_KEY environment variable. The matching public key is SUPublicEDKey in Info.plist, so losing the private key means updates can no longer be delivered to existing installs. Keep a safe backup.
appcast.xml lists only the latest version. If release notes are given, they appear as the update's notes in the update window (.md is converted with notes2html.py; .html is used as is).