Development
Repository
ios/the iPhone app (SwiftUI, SwiftTerm, swift-nio-ssh).mac/the Mac app (SwiftUI, a swift-nio-ssh server).shared/code used by both apps, such as the pairing link and user names.documentation/this manual. It is bundled into the Mac app.design/andweb/design files and the site.
Both apps are described by project.yml files and generated with XcodeGen. After adding or removing source files run xcodegen generate in ios/ or mac/.
How it is built
Mac
Server/TermfoldServer.swift: the SSH server, the login rules, the limits.Server/ConnectionRegistry.swift: open connections, limits, blocking, idle close, events.Server/ShellChannelHandler.swiftandPTYProcess.swift: the shell on a pseudo terminal. Pairing connections never get a shell.Server/PairingState.swift: the code and PIN.Server/DeviceStore.swift: the list of phones, stored as JSON.Server/ApprovalCenter.swift: pending approval requests.Server/ActivityLog.swift: the journal.Server/HostIdentity.swift: the key of the Mac, in the Keychain.App/AppModel.swift: the state shown by the interface.App/Notifier.swift: notifications.UI/: the window, pairing sheet, activity, settings, documentation and About views.
iPhone
SSH/SSHTransport.swiftandSSHSession.swift: the SSH client and the session.SSH/PairingClient.swift: pairing.PinnedHostKey.swiftandKnownHosts.swift: checking server keys.Security/: keys, the Keychain and the unlock gate.Terminal/: the terminal view, key bar and appearance (themes, fonts, cursor).Screens/: the interface.Models/: hosts and tabs.
Build
cd mac && xcodegen generate
xcodebuild -project TermfoldMac.xcodeproj -scheme TermfoldMac -configuration Debug -destination 'platform=macOS' build
cd ios && xcodegen generate
xcodebuild -project Termfold.xcodeproj -scheme Termfold -configuration Debug -destination 'generic/platform=iOS Simulator' build
For a real iPhone, add -destination 'platform=iOS,id=<device id>' -allowProvisioningUpdates DEVELOPMENT_TEAM=<team id>.
Release of the Mac app
mac/scripts/release.sh archives the app, exports it signed with Developer ID, builds the disk image, sends it to Apple for notarization and staples the result to mac/build/release/Termfold.dmg.
One time setup:
- An Apple Developer Program membership. Xcode creates the Developer ID certificate during the export if the account is signed in.
- An app specific password from account.apple.com, stored with:
xcrun notarytool store-credentials termfold-notary --apple-id <apple id> --team-id <team id>
Debug options
Debug builds of the Mac app read these environment variables, so a test copy can run next to the real app. They do not exist in Release builds.
| Variable | Effect |
|---|---|
TERMFOLD_PORT | Listen on another port. |
TERMFOLD_NAME | Announce another name. |
TERMFOLD_DATA_DIR | Keep the list and the journal in another folder. |
TERMFOLD_PAIR_FILE | Start pairing at launch and write the link and PIN to this file. |
TERMFOLD_IDLE_SECONDS | Idle limit in seconds. |
TERMFOLD_REQUIRE_APPROVAL | Ask before every connection. |
TERMFOLD_APPROVE_FILE | Write allow or deny into this file to answer a request. |
TERMFOLD_REVOKE_TRIGGER | Create this file to remove all phones. |
The Mac app with -renderUI <folder> saves PNG pictures of its screens. The iPhone app accepts -pairLink <link> and -pairPIN <pin> to pair at launch.
Documentation
The pages in this folder are plain Markdown. The Mac app shows them in a window, in the order of the file names. Links between pages use the file names. Keep names of buttons exactly as they appear in the apps.