Skip to content

Add native Swift package, improve inverses, and document both APIs - #8

Merged
TinyQ merged 2 commits into
masterfrom
codex/swift-modernization
Sep 28, 2026
Merged

TinyQ merged 2 commits into
masterfrom
codex/swift-modernization

Conversation

@TinyQ

@TinyQ TinyQ commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

This adds a native Swift package and modernizes the existing Objective-C implementation, documentation and verification.

The original GCJ-02 inverse can select an incorrect search quadrant and silently return a distant coordinate at its iteration limit. For example, converting WGS-84 (35.25, 114.25) to GCJ-02 and back returns latitude 35.251493380238543, approximately 166 meters away. The original Objective-C functions reproduce this regression. Both implementations now use bounded residual iteration and report invalid results or non-convergence.

  • Add independent Swift and Objective-C SwiftPM products, typed coordinate systems, explicit region policies, input validation and all six conversion routes. Preserve existing Objective-C selectors and their unrestricted regional behavior.
  • Refine GCJ-02 and BD-09LL inverses; replace the mutable polygon/UIKit dependency with immutable data. Keep original forward constants and polygon coordinates, with explicit edge inclusion.
  • Add equivalent Chinese/English READMEs, usage/error/migration/FAQ guides, algorithm research, contribution guidance, DocC, a changelog, release checklist and issue/PR templates.
  • Replace the placeholder Azure pipeline with macOS and Linux CI. Prepare the Objective-C podspec for 1.0.0 across iOS, macOS, tvOS, watchOS and visionOS; no tag, GitHub release or CocoaPods trunk publication is created.

Validation:

  • GitHub CI passed on macOS and Linux (Swift 6.0 and 6.2), including Debug/Release tests, Objective-C smoke checks, iOS builds, DocC, repository hygiene, strict CocoaPods lint across all five declared Apple platforms, and independent CocoaPods consumers.

Also completed locally:

  • swift test and swift test -c release: 15 tests passed, including independent forward fixtures, 4,088 grid points across all six directions, seeded non-grid samples, longitude-105/edge cases, legacy regressions, concurrency and Swift/Objective-C parity.
  • Standalone Objective-C smoke tests passed with compiler warnings treated as errors; both products also built and ran in a separate SwiftPM consumer.
  • Both SwiftPM library schemes built against the iOS, tvOS, watchOS and visionOS SDKs; Swift DocC built without warnings.
  • Local Markdown links/anchors, Swift formatting, YAML parsing, podspec Ruby syntax and git diff --check passed. CocoaPods 1.17.0 is pinned with a Gemfile/lockfile. Independent Objective-C and Swift application consumers build and run with static-library, static-framework and dynamic-framework linkage. Local Xcode 27 smoke builds set the macOS deployment target to 12.0 and run on macOS 27; CI uses Xcode 16.4 to validate the original declared minimum targets without an override.

The reproducible Release benchmark over 8,547 deterministic samples observed a maximum numerical round-trip error of 270.95 m for the old search versus 0.000139 m for residual iteration, with about 13.5× lower runtime in that run. These are errors within the same community forward model, not real-world map accuracy or universal performance guarantees; the research documents explain this distinction and external implementation differences.

Compatibility notes: modern distribution requires Swift 6 / iOS 13 (other platform minima in the manifest); inverse results improve numerically; invalid inputs now fail explicitly. New checked APIs apply the selected region policy once to the input for every pair. Legacy methods remain unrestricted. Near polygon boundaries, callers should choose applicability explicitly.

Follow-up quality checks:

  • Remove the historical Test/.DS_Store and reject tracked OS metadata, build caches and personal IDE settings in CI, including force-added files. A temporary Git index regression check confirmed clean files pass and forced metadata/build/IDE files fail.
  • Add Scripts/test-cocoapods.rb; generated consumer projects and artifacts stay under ignored .build/cocoapods/. CocoaPods validation does not use --allow-warnings, --quick or skip-import flags.
  • A release-tag pod spec lint remains a release-time check because tag 1.0.0 has not been created. No release or trunk publication is performed by this PR.

@TinyQ
TinyQ marked this pull request as ready for review September 28, 2026 11:14
@TinyQ
TinyQ merged commit 14861aa into master Sep 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant