MHPlatform is an internal Apple-platform foundation delivered as a Swift package workspace. It centralizes reusable, app-agnostic infrastructure proven through Incomes and Cookle while keeping app-specific domain behavior in the adopting apps.
The package ships three main adoption pillars:
MHPlatform: full app-facing convenience umbrella.MHPlatformCore: shared-library-safe umbrella for core primitives.MHAppRuntime: advanced app-root runtime/bootstrap surface for explicit composition.
The current baseline focuses on runtime startup, deep-link handoff, route execution, deterministic notification planning, notification payload routing, post-mutation side-effect orchestration, logging, preferences, persistence maintenance, review policy, and opt-in UI/workflow shells.
Minimum supported platforms:
- iOS 18.0+
- macOS 15.0+
- watchOS 11.0+
Releases use MAJOR.MINOR.PATCH. Pushes to main automatically publish the
next minor version with the patch reset to zero. A manual release can select an
explicit major or patch version. Legacy MAJOR.MINOR tags are treated as
MAJOR.MINOR.0; rerunning an already tagged commit does not create another release.
From this transition onward, incompatible public API changes require a major version, compatible features a minor version, and fixes a patch version. Version 1.14.0 is an explicit transition exception: it replaces the beta native ad size API while retaining the requested minor version increment. Version 1.18.0 is another explicit transition exception: it replaces the scheduled remote-update API, wire format, and retained cache before operational adoption. See the 1.17.0 migration notes before upgrading an experimental scheduled-update integration.
Version 1.24.0 is an explicit minor-release exception for remote update
configuration. Publish features.remoteUpdate.schemaVersion: 1 at each
endpoint before upgrading. Adding the key preserves the update policy revision.
See the wire and cache formats.
Replace MHNativeAdSize.small / .medium with
MHNativeAdLayout.compact / .media, and change the argument label:
// Before
runtime.nativeAdView(size: .small)
runtime.nativeAdView(size: .medium)
// After
runtime.nativeAdView(layout: .compact)
runtime.nativeAdView(layout: .media)Custom MHRuntimeNativeAdViewFactory closures now receive MHNativeAdLayout;
its makeView(size:) method becomes makeView(layout:). The factory callback
and makeView(layout:) run on MainActor, matching SwiftUI view creation.
The removed types and labels have no compatibility aliases.
If an app persists the old enum raw values, migrate "small" to "compact"
and "medium" to "media" before decoding the new enum. MHPlatform does not
automatically rewrite app-owned preferences.
Ads use the available width and their natural height. Apply app-owned padding,
background, and optional .frame constraints at the call site; recheck any
fixed heights previously chosen for Small or Medium.
GoogleMobileAdsWrapper 2.0.0 and Google Mobile Ads 13.10.0 provide the new code-built native ad views. SDK initialization completes before the adapter creates an ad request. 1.14.0 itself adds no consent orchestration; see Consent-managed Ads for the opt-in lifecycle.
Set adsConsent to let the runtime run Google's User Messaging Platform before
it starts advertising:
MHAppConfiguration(
subscriptionProductIDs: ["premium.monthly"],
nativeAdUnitID: adUnitID,
adsConsent: .init()
)- The runtime waits for premium status. Premium users see no consent form and trigger no ads SDK work.
- For other users it requests fresh consent information, presents a form only when the SDK requires one, and starts ads only when the SDK reports that ads can be requested. Consent from an earlier session starts ads while the update runs. Fresh eligibility is applied before a required form finishes. If premium becomes active during the update, the form is deferred until premium ends. Cancelled evaluations stop further work and can be retried explicitly.
- Reserve ad placements with
canDisplayAdsrather thanadsAvailability;adsConsentStatusreports the consent side. - When
adsPrivacyOptionsRequirement == .required, show a control that callspresentAdsPrivacyOptions(). - A failed update falls back to the SDK's stored state. Call
refreshAdsConsent()to retry; the runtime does not retry on its own. - If the app removes unknown keys from its standard defaults domain, add
MHAdsConsentStorage.currentDescriptors()fromMHAppRuntimeAdsto the cleanup allowlist. Otherwise stored consent is erased on every launch.
Apps keep ownership of AdMob Privacy & messaging, regional policy, the under-age
tag, ATT, and disclosures. Use debugGeography only in debug builds.
Read these first when choosing products or integrating a consumer:
- Consumer Boundaries: normative consumer matrix.
- Consumer Adoption: product-selection rationale and current shell preferences.
- Minimal App Setup: compact app bootstrap path.
- Integration Contracts: module-by-module public contracts.
- Preference Migration: descriptor-first adoption, startup ordering, and explicit defaults overrides.
Use these when changing architecture or reviewing durable decisions:
- Architecture Guide:
platform-in-package, app-as-adapterpolicy. - Architecture: module and dependency boundaries.
- Integration Cookbook: detailed integration examples.
- Runtime-start Design: runtime bootstrap design.
- North Star: long-term extraction direction.
- Design Decisions: ADR index.
- Platform Status: current adoption status.
- Verification History: durable verification contract and run artifact layout.
- Backlog: extraction history and current backlog posture.
This README is intentionally an adoption map. Keep detailed API walkthroughs in the architecture documents above so the entry point stays readable.
- Keep the top-level package layout stable:
Sources/,Tests/,Fixtures/,Example/,Designs/, andci_scripts/. - Organize
Sources/<Target>/with shallow responsibility-based folders such asConfiguration,Runtime,Routing,Workflow,Store, andSwiftUI. - Keep small targets flat when subdirectories do not improve discoverability.
- Put test-only helpers under
Tests/<Target>/Support/. - Use
Fixtures/Consumers/for compile-backed adoption references by consumer type. - Keep the example app shell in
Example/MHPlatformExample/App/and place module demos underExample/MHPlatformExample/Demos/<Area>/.
Use Consumer Boundaries as the source of truth before adding package dependencies.
- Full-platform app targets should use
MHPlatformwhen they intentionally want the default runtime, core primitives, optional UI bridges, mutation shell, logging bridge, and review shells from one import. - Advanced app-runtime targets should use
MHAppRuntimewhen they want runtime/bootstrap mechanics without the full umbrella. - Shared logic packages and shared libraries should use
MHPlatformCoreor granular core-safe modules. - Widget, App Intent, watch, and extension adapters should call app-owned
shared APIs first. If they need direct MHPlatform primitives, use
MHPlatformCoreor granular core-safe modules. - Optional route, mutation, and review shells should be added only to targets that own those concerns.
Avoid MHPlatform, MHAppRuntime, split runtime bundles, ads, license, and
review dependencies in surface adapters unless the target intentionally owns an
app-root runtime surface.
Remote updates are available through MHPlatformCore and MHPlatform, with a
standalone MHRemoteUpdate product for focused consumers. Standard App Store
adoption needs an app configuration URL and Store ID; the package assembles
lookup, persistence,
lifetimes, and confirmation-first operation checks. The shared static policy
needs no periodic publisher renewal; only validated fetches renew bounded offline
evidence. MHRemoteConfig owns the shared HTTPS transport and typed app
configuration envelope; update revisions and retained evidence remain in
MHRemoteUpdate. The endpoint is app-selected, with no hosting account or
repository embedded in the package. See the
remote update adoption guide.
An active update minimum can coexist with additional timed plans; the package
selects the strictest active minimum without extra app-side selection logic.
Typed MHRemoteConfigSection values isolate feature failures in a shared response.
The standard endpoint/Store-ID initializer and operation checks remain unchanged.
First operation checks restore retained evidence automatically, including outside
a UI lifecycle. Read-only evaluations explain decisions and evidence freshness
without fetching or renewing configuration.
In-app announcements use the same app configuration. The optional
MHAnnouncements product selects localized, currently visible notices by date
and installed version. App Store update adopters can receive both sections in
one refresh. See In-app announcements.
Default adoption pillars:
MHPlatformMHPlatformCore
Advanced app-root surface:
MHAppRuntime
Advanced runtime composition bundles:
MHAppRuntimeDefaultsMHAppRuntimeAdsMHAppRuntimeLicenses
Granular core-safe products, optional UI bridges, and optional shells:
MHAnnouncementsMHRemoteUpdateMHRemoteConfigMHDeepLinkingMHLoggingMHLoggingUIMHNotificationPlansMHNotificationPayloadsMHNotificationDeepLinkingMHRouteExecutionMHPersistenceMaintenanceMHPreferencesMHPreferencesUIMHUserNotificationsMHMutationFlowMHMutationLoggingMHReviewPolicyMHReviewRequestingMHReviewFlow
Test support:
MHPlatformTesting
MHPlatformremains a thin convenience umbrella over concrete modules.MHPlatformCoremust not pull inMHAppRuntime, app-root runtime adapters, SwiftUI/UI bridge targets, StoreKit, ads, licenses, mutation workflow, or review policy.MHAppRuntimeowns reusable runtime/bootstrap mechanics, not StoreKit, ads, license, or app-specific side-effect policy.MHPreferencesandMHLoggingown core primitives;MHPreferencesUIandMHLoggingUIown optional SwiftUI/UI bridge surfaces.MHNotificationPayloadsowns platform-agnostic payload codecs and route resolution;MHUserNotificationsowns UserNotifications adapters;MHNotificationDeepLinkingowns notification-to-deep-link delivery helpers.MHReviewPolicyowns pure review policy;MHReviewRequestingowns direct platform requesting;MHReviewFlowowns runtime/mutation workflow wiring.- Route enum meaning, navigation destination meaning, notification copy, preference key meaning, persistence schema meaning, mutation result schemas, and concrete side effects stay app-owned.
- App-specific
*Operationsfacades belong in adopting app shared libraries, not in MHPlatform. MHPlatformTestingis a separate test-support product and must not be re-exported by production umbrellas.
Direct third-party dependency rule:
MHPlatformdoes not re-export third-party symbols fromStoreKitWrapper,GoogleMobileAdsWrapper, orLicenseList.- If consumer code uses those APIs directly, add the third-party package as a
direct dependency and
importthat module explicitly.
Compile-backed reference adopters live under Fixtures/Consumers/.
SharedLibraryConsumerproves theMHPlatformCoreshared-library path.RuntimeOnlyConsumerproves theMHAppRuntimeruntime/bootstrap-only path.SplitRuntimeConsumerproves explicit runtime-bundle composition.OptionalShellConsumerproves review/mutation shells stay opt-in.SurfaceAdapterConsumerproves the widget, App Intent, watch, and extension adapter path using only granular products without app-runtime dependencies.
Package tests and integration tests cover the module behavior behind those
consumer paths. Example/MHPlatformExample/ remains the full-umbrella demo app.
- Incomes and Cookle currently adopt MHPlatform primarily through the umbrella
MHPlatformproduct in app composition targets. MHAppRuntimeis the shared runtime/startup surface used by app targets.MHRouteExecution,MHDeepLinking,MHNotificationPlans,MHNotificationPayloads,MHUserNotifications,MHNotificationDeepLinking,MHPreferences,MHLogging,MHMutationFlow,MHReviewPolicy,MHReviewRequesting, andMHReviewFlowprovide reusable infrastructure while route meanings, mutation effects, notification copy, review timing, and platform side effects stay app-owned.- Shared-library and surface-adapter consumers should follow the consumer matrix instead of mirroring an app target's umbrella imports.
MHPlatformExample demonstrates the full MHPlatform umbrella with app-local
sample data in Example/.
It includes cross-module demos for:
- Deep-link inbox and route-lifecycle pipelines.
- Low-level route execution.
- Notification planning and notification payload routing.
- Mutation workflow and review policy integration.
- Structured logging and last-session diagnostics.
- Mutation adapter composition with ordered follow-up steps.
Consumer-specific minimal adopters live in Fixtures/Consumers/ instead of
duplicating narrower paths inside the demo app.
The shared MHPlatformExample scheme enables the local
Example/MHPlatformExample/Configuration/Products.storekit catalog for its Run
action. Run the example from Xcode to load the sample monthly subscription and
explore premium status and ad suppression with StoreKit Testing. The catalog
uses local test transactions; it does not require App Store Connect products.
The native ad demo uses Google's official test ad unit. Its app ID and
SKAdNetworkItems are configured in Example/MHPlatformExample-Info.plist
following
Google's setup guide.
Adopting apps must supply their own app IDs and ad configuration.
- An Xcode toolchain with Swift 6.2 support and SDKs for the target platforms.
- Minimum deployment targets: iOS 18, macOS 15, and watchOS 11.
- SwiftPM package resolution for the repository-managed SwiftLint plugin used by retained rule scripts.
- Clone the repository and open the project directory.
- Open
Package.swiftin Xcode if you want package browsing and test support. - Open
Example/MHPlatformExample.xcodeprojif you want to run the demo app shell. - Use the helper scripts in
ci_scripts/tasks/for repeatable local verification.
Use Xcode and the Xcode-native integration available in the agent environment for build, test, run, runtime-log, Preview, live UI, and screenshot evidence.
Before changing Xcode selection, record the original scheme and destination, switch only to discovered values, and end sessions or runs started solely for verification. Restore the original scheme first, rediscover its destinations, restore the original destination, and confirm the selection. Report failed restoration.
For MHPlatform package compile and test checks, select
.swiftpm/xcode/package.xcworkspace, the MHPlatform-Package scheme, and a
discovered iPhone Simulator destination, then use the available Xcode-native
build or test capability.
For example app compile or runtime checks, select
Example/MHPlatformExample.xcodeproj, the MHPlatformExample scheme, and a
discovered iPhone Simulator destination, then use the available Xcode-native
build or run capability. For package umbrella compile checks, use
.swiftpm/xcode/package.xcworkspace, the MHPlatform scheme, and a
discovered compatible iOS or watchOS Simulator destination.
Choose evidence by the changed boundary. Package source or product changes need package build/test evidence. Consumer-boundary changes also need retained repository rules and their consumer fixtures. App-runtime or adopter-facing integration changes also need the example-app build. Visible example behavior needs a targeted run and runtime-log review, plus Preview, live UI, or screenshot evidence appropriate to the change. These capabilities remain separate. Read the normative Consumer Boundaries before changing product dependencies; adopting apps continue to own domain behavior and adapter policy.
Follow the repository SwiftLint configuration and existing Swift source style. Markdown follows the markdownlint rules.
The remaining helper scripts in ci_scripts/ are retained for repository
rules and compatibility wrappers that are not naturally covered by the
available Xcode-native integration.
The retained scripts resolve SwiftLint from the SwiftLintPlugins package
declared in Package.swift; they do not require a separately installed
swiftlint binary on PATH.
Before running retained script checks, diagnose local prerequisites:
bash ci_scripts/tasks/check_environment.sh --profile rulesAfter Swift edits, run the explicit autofix step:
bash ci_scripts/tasks/format_swift.shFor retained repository rule checks:
bash ci_scripts/tasks/check_repository_rules.shThis retained rule entry point runs SwiftLint, consumer fixture checks, and the package-backed remote configuration publisher validator tests. The validator compiles only the owning configuration, update, and announcement modules with Apple's Swift compiler; it adds no app product or third-party dependency.
If you prefer to run SwiftLint directly through the repository wrapper:
bash ci_scripts/tasks/format_swift.sh
bash ci_scripts/tasks/lint_swift.shCompatibility wrappers remain available for older local habits and push hooks:
bash ci_scripts/tasks/verify_task_completion.sh
bash ci_scripts/tasks/verify_repository_state.sh
bash ci_scripts/tasks/verify_pre_push.sh
bash ci_scripts/tasks/verify.shThe aggregate shell build and package-test wrappers are kept for fallback use when the Xcode-native integration is unavailable or does not cover a required check:
bash ci_scripts/tasks/build_app.sh
bash ci_scripts/tasks/test_shared_library.sh
bash ci_scripts/tasks/run_required_builds.shCompatibility aggregate scripts write generated artifacts under .build/ci/.
Run-scoped outputs are stored in .build/ci/runs/<RUN_ID>/ (summary.md,
commands.txt, meta.json, logs/, results/, work/) when a wrapper uses
the run artifact helper. Shared caches and build state live in
.build/ci/shared/ (cache/, DerivedData/, tmp/, home/).