From 0b3b59136864d1b1eae0c902f625223a9b4caebc Mon Sep 17 00:00:00 2001 From: Sarto Date: Sat, 9 May 2026 11:45:08 +0330 Subject: [PATCH] fix: enhance iOS update handling in web client --- .github/workflows/build.yml | 12 +++++++++++- Makefile | 17 ++++++++++++++--- internal/web/static/index.html | 8 +++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5abfb7d..0ae499f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -244,10 +244,18 @@ jobs: go mod tidy - name: Build Mobile.xcframework - run: gomobile bind -iosversion=14.0 -target=ios,iossimulator -o ios/Mobile.xcframework ./mobile + run: | + VERSION=${GITHUB_REF_NAME:-dev} + COMMIT=$(git rev-parse --short HEAD) + DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) + LDFLAGS="-X github.com/sartoopjj/thefeed/internal/version.Version=${VERSION} -X github.com/sartoopjj/thefeed/internal/version.Commit=${COMMIT} -X github.com/sartoopjj/thefeed/internal/version.Date=${DATE}" + gomobile bind -iosversion=14.0 -target=ios,iossimulator -ldflags="${LDFLAGS}" -o ios/Mobile.xcframework ./mobile - name: Archive (unsigned) run: | + VERSION=${GITHUB_REF_NAME:-dev} + MARKETING_VERSION=${VERSION#v} + BUILD_NUMBER=$(git rev-list --count HEAD) xcodebuild \ -project ios/Thefeed.xcodeproj \ -scheme Thefeed \ @@ -255,6 +263,8 @@ jobs: -destination 'generic/platform=iOS' \ -archivePath build/Thefeed.xcarchive \ archive \ + MARKETING_VERSION="${MARKETING_VERSION}" \ + CURRENT_PROJECT_VERSION="${BUILD_NUMBER}" \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGNING_ALLOWED=NO \ diff --git a/Makefile b/Makefile index c51f985..d0bf717 100644 --- a/Makefile +++ b/Makefile @@ -108,17 +108,26 @@ IOS_PROJECT = $(IOS_DIR)/Thefeed.xcodeproj # Default simulator: pick the first available iPhone (override with IOS_SIM_NAME='iPhone 17'). IOS_SIM_NAME ?= $(shell xcrun simctl list devices available 2>/dev/null | awk -F'[()]' '/-- iOS [0-9]/{ios=1;next} /^-- /{ios=0} ios && /iPhone/{print $$1; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$$//') +# Strip a leading 'v' so MARKETING_VERSION accepts e.g. v0.18.0 / 0.18.0. +IOS_MARKETING_VERSION = $(patsubst v%,%,$(VERSION)) +# Build number must be a positive integer; commit count is monotonic. +IOS_BUILD_NUMBER ?= $(shell git rev-list --count HEAD 2>/dev/null || echo 1) +IOS_LDFLAGS = -X github.com/sartoopjj/thefeed/internal/version.Version=$(VERSION) \ + -X github.com/sartoopjj/thefeed/internal/version.Commit=$(COMMIT) \ + -X github.com/sartoopjj/thefeed/internal/version.Date=$(DATE) +IOS_XCODE_VERSIONS = MARKETING_VERSION="$(IOS_MARKETING_VERSION)" CURRENT_PROJECT_VERSION="$(IOS_BUILD_NUMBER)" + ios-deps: @grep -q "golang.org/x/mobile" go.mod || go get golang.org/x/mobile/bind golang.org/x/mobile/bind/objc go mod tidy ios-bind: ios-deps @command -v gomobile >/dev/null 2>&1 || { echo "gomobile not found. Run: go install golang.org/x/mobile/cmd/gomobile@latest && gomobile init"; exit 1; } - gomobile bind -iosversion=14.0 -target=ios,iossimulator -o $(IOS_FRAMEWORK) ./mobile + gomobile bind -iosversion=14.0 -target=ios,iossimulator -ldflags='$(IOS_LDFLAGS)' -o $(IOS_FRAMEWORK) ./mobile ios-bind-catalyst: ios-deps @command -v gomobile >/dev/null 2>&1 || { echo "gomobile not found"; exit 1; } - gomobile bind -iosversion=14.0 -target=ios,iossimulator,maccatalyst -o $(IOS_FRAMEWORK) ./mobile + gomobile bind -iosversion=14.0 -target=ios,iossimulator,maccatalyst -ldflags='$(IOS_LDFLAGS)' -o $(IOS_FRAMEWORK) ./mobile ios-list-sims: xcrun simctl list devices available @@ -126,11 +135,13 @@ ios-list-sims: ios-build: $(IOS_FRAMEWORK) xcodebuild -project $(IOS_PROJECT) -scheme $(IOS_SCHEME) \ -destination 'platform=iOS Simulator,name=$(IOS_SIM_NAME)' \ + $(IOS_XCODE_VERSIONS) \ build ios-test: $(IOS_FRAMEWORK) xcodebuild test -project $(IOS_PROJECT) -scheme $(IOS_SCHEME) \ - -destination 'platform=iOS Simulator,name=$(IOS_SIM_NAME)' + -destination 'platform=iOS Simulator,name=$(IOS_SIM_NAME)' \ + $(IOS_XCODE_VERSIONS) $(IOS_FRAMEWORK): $(MAKE) ios-bind diff --git a/internal/web/static/index.html b/internal/web/static/index.html index ce79cf8..ba8a37f 100644 --- a/internal/web/static/index.html +++ b/internal/web/static/index.html @@ -4387,7 +4387,13 @@ // Quietly ask GitHub for the latest published client version. Runs in // the background so a slow github.com response can't delay startup — // if there's an update, the dialog shows up a few seconds later. - checkGitHubUpdate(false).catch(function () { }); + // Skipped on iOS: App Store / TestFlight handles updates there. + if (typeof IOS === 'undefined') { + checkGitHubUpdate(false).catch(function () { }); + } else { + var ghBtn = document.getElementById('checkGitHubBtn'); + if (ghBtn) ghBtn.style.display = 'none'; + } try { var r = await fetch('/api/status'); var st = await r.json(); await loadProfiles();