Skip to content
quicksketchPublic

About

iOS app for posting microblog content to self-hosted CMS platforms.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Moby for iOS

An iOS app for posting to a Backdrop CMS site running the Moby (moby) module. It follows SPECIFICATIONS.md, so it works the same as the Android app.

It's built on Ubuntu with xtool, which builds, signs and installs iOS apps without a Mac.

Layout

  • Sources/MobyCore: the API client, models, and the rules that must match Android exactly (hashtags, HTML descriptions, dates, site addresses, media checks, video compression maths). Foundation only.
  • Sources/Moby: the SwiftUI app.
    • App/: the app's state (AppModel), Keychain tokens, the URLSession transport, and navigation.
    • Screens/: Sites, Log in, Feed, Post page, Editor, Settings.
  • Tests/MobyCoreTests: the same cases as the Android unit tests.
  • tools/: UI automation through WebDriverAgent (wda.sh, ui.py).

Building

MOBY_CORE_ONLY=1 swift test   # MobyCore's tests, on Linux
xtool dev build               # build the app
./run.sh                      # build, install, launch and screenshot (phone unlocked)

MOBY_CORE_ONLY leaves the iOS app out of the package, since it can't build on Linux without xtool's iOS SDK.

xtool registers the app as XTL-69A6DE71.org.mobyapp.ios. run.sh adds the prefix itself.

API version

Sources/MobyCore/ApiVersion.swift holds the API version the app is built for, which it sends as ?api= on every request, and the list of changes it uses. See "Versioning" in SPECIFICATIONS.md.

After changing it, do a clean build (rm -rf .build, then ./run.sh). Incremental xtool builds kept the old values compiled into the app.

Testing on the phone

Reaching a local DDEV site. The phone can't use *.ddev.site, which resolves to the phone itself, and there's no USB port forwarding for iPhones. Instead, it reaches the site over Wi-Fi at this computer's address, with nothing outside the local network involved:

  1. Add the address as a DDEV hostname, in a separate file in the site's .ddev folder (delete it and restart DDEV when done):
    # .ddev/config.moby-ios.yaml
    additional_fqdns:
      - 192.168.1.189
    
  2. Run tools/lan-proxy.py 192.168.1.189 8080, which forwards that port to DDEV until stopped.
  3. In the app, add the site as http://192.168.1.189:8080. iOS asks once to allow access to the local network.

Driving the UI. On iOS 27 and later, tools/hid.sh taps, drags and types directly, without WebDriverAgent. Coordinates are in points, taken from tools/hid.sh shot FILE screenshots:

tools/hid.sh tap 196 460
tools/hid.sh type "http://192.168.1.189:8080"
tools/hid.sh shot /tmp/screen.png

Its key command fails for Enter and Backspace, so tap on-screen buttons and keys instead.

hid.sh taps need UI Automation. Settings → Developer → Enable UI Automation must be on, which asks for the phone's passcode. With it off, taps are silently ignored, while screenshots still work. Take coordinates from a fresh, uncropped hid.sh shot, since layouts move when screens change.

On older iOS versions, or to tap elements by name, use WebDriverAgent (tools/wda.sh start, tools/ui.py, then tools/wda.sh stop), and turn off Settings → Developer → Enable UI Automation when done.

Releasing

Publishing a release on GitHub runs .github/workflows/release.yml on a macOS runner. App Store builds need Xcode, so it doesn't use xtool:

  1. It runs the MobyCore tests.
  2. release/prepare.py writes the release build's inputs to release/build/:
    • Info.plist, without the plain-HTTP exceptions for local sites;
    • the app icon as an asset catalog;
    • the version and signing settings.
  3. XcodeGen turns release/project.yml into an Xcode project.
  4. It archives the app and exports a signed .ipa, attached to the release as moby-ios-{version}.ipa.
  5. It uploads the build to App Store Connect for TestFlight and App Review. The run's summary says what to do next.

Running the workflow by hand (Actions → Release → Run workflow) builds an unsigned copy, which checks the app compiles with Xcode without any secrets.

  • Tag: like Android, it must look like v1.2.3. The build number is major × 1,000,000 + minor × 1,000 + patch.
  • Privacy manifest: release/PrivacyInfo.xcprivacy declares the "required reason" APIs the app uses. Update it when the app starts using another, such as file timestamps.
  • Signing: an Apple Distribution certificate and an App Store provisioning profile, both renewed yearly. The secrets are listed at the top of the workflow, and the steps to make them are below.

Setting up signing

These run on Linux, with no Mac needed.

  1. Make a key and certificate request, and keep the key safe:

    openssl genrsa -out moby-distribution.key 2048
    openssl req -new -key moby-distribution.key -out moby-distribution.csr -subj "/CN=Moby Distribution/C=US"
    
  2. Get the certificate. In Certificates, add an Apple Distribution certificate with the .csr, and download distribution.cer.

  3. Make the .p12 the workflow imports. -legacy keeps it readable by macOS's security tool. It asks for a password.

    openssl x509 -inform DER -in distribution.cer -out distribution.pem
    openssl pkcs12 -export -legacy -inkey moby-distribution.key -in distribution.pem -out distribution.p12
    
  4. Register the App ID. In Identifiers, add an explicit App ID for org.mobyapp.ios. xtool's development builds use their own XTL-… IDs, so this is separate.

  5. Make the profile. In Profiles, add an App Store Connect profile for org.mobyapp.ios with the certificate, and download it.

  6. Create the app record. In App Store Connect, add a new iOS app with the bundle ID org.mobyapp.ios. Uploads fail without it.

  7. Get an API key. In App Store Connect → Users and Access → Integrations, make a team key with the App Manager role, and download its .p8 file, which you can only download once. Note its key ID and the issuer ID.

  8. Add the secrets to the repository:

    Secret Value
    IOS_DISTRIBUTION_CERT_P12_BASE64 base64 -w0 distribution.p12
    IOS_DISTRIBUTION_CERT_PASSWORD The .p12 password
    IOS_PROVISIONING_PROFILE_BASE64 base64 -w0 Moby_App_Store.mobileprovision
    APP_STORE_CONNECT_KEY_ID The API key's ID
    APP_STORE_CONNECT_ISSUER_ID The issuer ID
    APP_STORE_CONNECT_KEY_BASE64 base64 -w0 AuthKey_XXXXXXXXXX.p8

Keep the key, .p12 and .p8 out of the repository; .gitignore covers them. When the certificate expires, repeat steps 1–3 and 5, and update the first three secrets.

Status against the specification

Tested on an iPhone 15 Plus with iOS 27.2.1 (adding a site, the feed, posting with tags and location, editing, deleting, settings). Photos and videos were not tested on the device.

  • Sites: list, favicons with a letter fallback, login status, settings, log out and remove (with their confirmations), name and favicon refresh.
  • Log in: address normalization, setup issues, the form built from auth.fields, the password reset link. Tokens are stored in the Keychain (after first unlock, this device only).
  • Feed: paging, pull to refresh, draft badges, thumbnails, and keeping the feed right after posts are added, edited or deleted. A 401 logs out.
  • Post page: the site's page in a WKWebView, with moby_view, the token only sent to the same site (including after redirects), links opened in the browser, and edit and delete in a floating toolbar. The toolbar is hosted in its own UIKit view (App/FloatingActions.swift), because SwiftUI buttons drawn over the web view didn't receive taps.
  • Editor:
    • The description, with HTML encoding, and raw HTML editing for posts with markup.
    • Media from the system photo picker, loaded as files. It's checked and named by type, HEIC is converted to JPEG without metadata, video thumbnails are made, and uploads show progress and can be retried or removed (pending uploads are deleted on the site).
    • Video compression with AVAssetWriter (H.264 and AAC MP4 at the planned size and bitrate, up to 3 attempts), and the offer for videos over 200 MB. Not yet tried on a real video.
    • Alt text, the full-screen viewer, and moving items earlier or later (menu and VoiceOver actions).
    • Tags, with suggestions, commas, hashtag chips and limits.
    • Date and time, location (with the automatic fill), status, and saving in the specified order, with client_id.
  • Settings: the site title, and the Include Location and Publish by Default toggles.

Not done yet:

  • Sharing from other apps. Needs a share extension and an App Group. xtool supports extensions in xtool.yml.
  • Drag to reorder. Items can only be moved with the menu or VoiceOver actions.
  • SVG favicons. AsyncImage can't show them, so the letter shows instead.
  • Device names. Login sends the hardware identifier, such as "iPhone (iPhone15,4)", rather than "iPhone 15 Plus".
  • Plain HTTP. Info.plist allows plain HTTP to *.ddev.site, localhost and local addresses in xtool builds. App Store builds leave it out (see Releasing).

About

iOS app for posting microblog content to self-hosted CMS platforms.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages