From ce2a0542341f43516a0d81f418a41e1358f586f6 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 2 Sep 2026 21:32:18 +0200 Subject: [PATCH 1/7] chore: move the project to Unity 6.6 and raise the package floor to 6.0 Editor 6000.6.0f1 with its resaved project settings and package bumps (pipeline 0.5.0-exp.1, project-auditor-rules, test-framework 1.8, ugui 2.6, inputsystem 1.20). The package now declares unity 6000.0; the raise is unreleased and noted under Unreleased in the changelog. --- AGENTS.md | 4 +- Packages/com.adapty.unity-sdk/CHANGELOG.md | 8 + Packages/com.adapty.unity-sdk/package.json | 2 +- Packages/manifest.json | 16 +- Packages/packages-lock.json | 61 +++++- ProjectSettings/PackageManagerSettings.asset | 13 +- .../PhysicsCoreProjectSettings2D.asset | 6 + ProjectSettings/ProjectAuditorSettings.asset | 51 ----- ProjectSettings/ProjectSettings.asset | 35 ++-- ProjectSettings/ProjectVersion.txt | 4 +- ProjectSettings/QualitySettings.asset | 188 ++++++++++++++++-- README.md | 2 +- 12 files changed, 282 insertions(+), 108 deletions(-) create mode 100644 ProjectSettings/PhysicsCoreProjectSettings2D.asset diff --git a/AGENTS.md b/AGENTS.md index 0990ca0e..a570b24c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,9 +11,9 @@ Adapty Unity SDK — a C# wrapper around native [Adapty iOS SDK](https://github. This is a **Unity project** (Unity 6000.x) — the player is built and tested through the Unity Editor. The JSON layer is the exception: `tests/` links the SDK sources into a plain .NET project, so it needs neither the Editor nor a licence. -The package declares **Unity 2022.3 and newer** as `unity` in `package.json`, and that floor is what Editor-facing code may assume: `AdaptyDependencies` uses `Client.AddAndRemove` and `PackageInfo.FindForAssembly`, neither of which exists all the way back (`AddAndRemove` arrived after 2020.3). +The package declares **Unity 6.0 (6000.0) and newer** as `unity` in `package.json` — raised from 2022.3 on 2026-09-01 so the package may use UI Toolkit runtime bindings (2023.2+) for the Editor mock UI — and that floor is what all package code may assume. Demo-only code under `Assets/` may go further (the project itself runs 6.6). -The install path is verified on the floor — `.unitypackage` import into a clean project, then `Adapty SDK > Install Dependencies`, then a compile, all on 2022.3.62f3. Everything else runs on Unity 6. Keep the changelog and `MIGRATION-v3.17-to-v4.1.md` wording matching that split; do not widen it to claim device or build coverage on 2022.3. One trap when re-verifying: recent 2022.3 builds are Extended LTS and refuse to launch without an Industry or Enterprise licence, so pick a build below that cutoff (62f3 works). +The floor raise is unreleased: 4.1.x shipped on 2022.3, and its install path — `.unitypackage` import into a clean project, then `Adapty SDK > Install Dependencies`, then a compile — was verified on 2022.3.62f3. Before the release that carries the raise, verify that path on a 6000.0.x build and say so in the changelog entry (there is one under Unreleased); do not widen it to claim device or build coverage on 6000.0. `MIGRATION-v3.17-to-v4.1.md` describes 4.1 as it shipped and is not edited for later floors. **Run the JSON layer tests:** ```bash diff --git a/Packages/com.adapty.unity-sdk/CHANGELOG.md b/Packages/com.adapty.unity-sdk/CHANGELOG.md index 06a680ed..8bba5075 100644 --- a/Packages/com.adapty.unity-sdk/CHANGELOG.md +++ b/Packages/com.adapty.unity-sdk/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Breaking Changes + +- **The minimum supported Unity version is raised from 2022.3 to 6.0 (6000.0)**, declared as + `unity` in `package.json`. The package will rely on UI Toolkit runtime bindings (2023.2+) for + its Editor-side mock UI; projects on 2022.3 stay on 4.1.x. + ## [4.1.2] - 2026-09-14 ### Fixed diff --git a/Packages/com.adapty.unity-sdk/package.json b/Packages/com.adapty.unity-sdk/package.json index 5217f81c..276bd142 100644 --- a/Packages/com.adapty.unity-sdk/package.json +++ b/Packages/com.adapty.unity-sdk/package.json @@ -3,7 +3,7 @@ "version": "4.1.2", "displayName": "Adapty Unity SDK", "description": "Unity SDK for Adapty in-app purchases, subscriptions, paywalls, and onboarding flows.", - "unity": "2022.3", + "unity": "6000.0", "_upm": { "changelog": "### Fixed\n\n- [iOS] Flow analytics events reported numeric parameters valued 0 or 1 as booleans.\n- [Android] Various bugfixes and stability improvements." }, diff --git a/Packages/manifest.json b/Packages/manifest.json index 86c34d43..0e118329 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -3,12 +3,14 @@ "com.adapty.unity-sdk": "file:com.adapty.unity-sdk", "com.google.external-dependency-manager": "1.2.188", "com.unity.ide.rider": "3.0.40", - "com.unity.ide.visualstudio": "2.0.27", - "com.unity.inputsystem": "1.19.0", + "com.unity.ide.visualstudio": "2.0.28", + "com.unity.inputsystem": "1.20.0", "com.unity.mobile.android-logcat": "1.4.7", "com.unity.nuget.newtonsoft-json": "3.2.2", - "com.unity.test-framework": "1.6.0", - "com.unity.ugui": "2.0.0", + "com.unity.pipeline": "0.5.0-exp.1", + "com.unity.project-auditor-rules": "2.0.0", + "com.unity.test-framework": "1.8.0", + "com.unity.ugui": "2.6.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", @@ -16,7 +18,10 @@ "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physicscore2d": "1.0.0", "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.tetgen": "1.0.0", + "com.unity.modules.timelinefoundation": "1.0.0", "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", "com.unity.modules.umbra": "1.0.0", @@ -27,8 +32,7 @@ "com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0", "com.unity.modules.vectorgraphics": "1.0.0", - "com.unity.modules.video": "1.0.0", - "com.unity.pipeline": "0.4.0-exp.1" + "com.unity.modules.video": "1.0.0" }, "scopedRegistries": [ { diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 8caba235..d281f933 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -16,7 +16,7 @@ "url": "https://package.openupm.com" }, "com.unity.ext.nunit": { - "version": "2.0.5", + "version": "2.1.0", "depth": 1, "source": "builtin", "dependencies": {} @@ -31,7 +31,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.27", + "version": "2.0.28", "depth": 0, "source": "registry", "dependencies": { @@ -40,7 +40,7 @@ "url": "https://packages.unity.com" }, "com.unity.inputsystem": { - "version": "1.19.0", + "version": "1.20.0", "depth": 0, "source": "registry", "dependencies": { @@ -70,7 +70,7 @@ "url": "https://packages.unity.com" }, "com.unity.pipeline": { - "version": "0.4.0-exp.1", + "version": "0.5.0-exp.1", "depth": 0, "source": "registry", "dependencies": { @@ -83,30 +83,42 @@ }, "url": "https://packages.unity.com" }, + "com.unity.project-auditor-rules": { + "version": "2.0.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { - "version": "1.6.0", + "version": "1.8.0", "depth": 0, "source": "builtin", "dependencies": { - "com.unity.ext.nunit": "2.0.3", + "com.unity.ext.nunit": "2.1.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" } }, "com.unity.ugui": { - "version": "2.0.0", + "version": "2.6.0", "depth": 0, "source": "builtin", "dependencies": { "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0" + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.physics": "1.0.0" } }, "com.unity.modules.androidjni": { "version": "1.0.0", "depth": 0, "source": "builtin", - "dependencies": {} + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } }, "com.unity.modules.animation": { "version": "1.0.0", @@ -156,6 +168,20 @@ "source": "builtin", "dependencies": {} }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.physicscore2d": "1.0.0" + } + }, + "com.unity.modules.physicscore2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.screencapture": { "version": "1.0.0", "depth": 0, @@ -164,6 +190,20 @@ "com.unity.modules.imageconversion": "1.0.0" } }, + "com.unity.modules.tetgen": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.timelinefoundation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, "com.unity.modules.ui": { "version": "1.0.0", "depth": 0, @@ -179,7 +219,8 @@ "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.hierarchycore": "1.0.0", - "com.unity.modules.physics": "1.0.0" + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.animation": "1.0.0" } }, "com.unity.modules.umbra": { diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset index c91ee3b5..410ccc1b 100644 --- a/ProjectSettings/PackageManagerSettings.asset +++ b/ProjectSettings/PackageManagerSettings.asset @@ -19,23 +19,26 @@ MonoBehaviour: m_DismissPreviewPackagesInUse: 0 oneTimeWarningShown: 0 oneTimePackageErrorsPopUpShown: 0 - m_Registries: - - m_Id: main + m_MainRegistry: + m_Id: main m_Name: m_Url: https://packages.unity.com m_Scopes: [] m_IsDefault: 1 + m_IsUnityRegistry: 1 m_Capabilities: 7 m_ConfigSource: 0 m_Compliance: m_Status: 0 m_Violations: [] + m_ScopedRegistries: - m_Id: scoped:project:package.openupm.com m_Name: package.openupm.com m_Url: https://package.openupm.com m_Scopes: - com.google m_IsDefault: 0 + m_IsUnityRegistry: 0 m_Capabilities: 0 m_ConfigSource: 4 m_Compliance: @@ -46,6 +49,8 @@ MonoBehaviour: m_RegistryInfoDraft: m_Modified: 0 m_ErrorMessage: - m_UserModificationsInstanceId: -918 - m_OriginalInstanceId: -920 + m_UserModificationsEntityId: + m_rawData: 1099511639452 + m_OriginalEntityId: + m_rawData: 1099511639453 m_LoadAssets: 0 diff --git a/ProjectSettings/PhysicsCoreProjectSettings2D.asset b/ProjectSettings/PhysicsCoreProjectSettings2D.asset new file mode 100644 index 00000000..049c7454 --- /dev/null +++ b/ProjectSettings/PhysicsCoreProjectSettings2D.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!176606843 &1 +PhysicsCoreProjectSettings2D: + m_ObjectHideFlags: 0 + m_PhysicsCoreSettings: {fileID: 0} diff --git a/ProjectSettings/ProjectAuditorSettings.asset b/ProjectSettings/ProjectAuditorSettings.asset index eb48dce1..1dae2b36 100644 --- a/ProjectSettings/ProjectAuditorSettings.asset +++ b/ProjectSettings/ProjectAuditorSettings.asset @@ -19,12 +19,6 @@ MonoBehaviour: - PlatformGroup: m_String: Unknown m_SerializedParams: - - Key: StreamingAssetsFolderSizeLimit - Value: 50 - - Key: SpriteAtlasEmptySpaceLimit - Value: 50 - - Key: TextureStreamingMipmapsSizeLimit - Value: 4000 - Key: StreamingClipThresholdBytes Value: 218294 - Key: LongDecompressedClipThresholdBytes @@ -33,55 +27,10 @@ MonoBehaviour: Value: 204800 - Key: LoadInBackGroundClipSizeThresholdBytes Value: 204800 - - PlatformGroup: - m_String: Android - m_SerializedParams: - - Key: StreamingAssetsFolderSizeLimit - Value: 50 - - Key: SpriteAtlasEmptySpaceLimit - Value: 50 - Key: TextureStreamingMipmapsSizeLimit Value: 4000 - - Key: StreamingClipThresholdBytes - Value: 218294 - - Key: LongDecompressedClipThresholdBytes - Value: 204800 - - Key: LongCompressedMobileClipThresholdBytes - Value: 204800 - - Key: LoadInBackGroundClipSizeThresholdBytes - Value: 204800 - - PlatformGroup: - m_String: Standalone - m_SerializedParams: - - Key: StreamingAssetsFolderSizeLimit - Value: 50 - Key: SpriteAtlasEmptySpaceLimit Value: 50 - - Key: TextureStreamingMipmapsSizeLimit - Value: 4000 - - Key: StreamingClipThresholdBytes - Value: 218294 - - Key: LongDecompressedClipThresholdBytes - Value: 204800 - - Key: LongCompressedMobileClipThresholdBytes - Value: 204800 - - Key: LoadInBackGroundClipSizeThresholdBytes - Value: 204800 - - PlatformGroup: - m_String: iPhone - m_SerializedParams: - Key: StreamingAssetsFolderSizeLimit Value: 50 - - Key: SpriteAtlasEmptySpaceLimit - Value: 50 - - Key: TextureStreamingMipmapsSizeLimit - Value: 4000 - - Key: StreamingClipThresholdBytes - Value: 218294 - - Key: LongDecompressedClipThresholdBytes - Value: 204800 - - Key: LongCompressedMobileClipThresholdBytes - Value: 204800 - - Key: LoadInBackGroundClipSizeThresholdBytes - Value: 204800 CurrentParamsIndex: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 6ea19891..0a08c2e4 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 28 + serializedVersion: 30 productGUID: f8138c1c0c6ef44ddb57013d7672b7bc AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -54,7 +54,7 @@ PlayerSettings: mipStripping: 0 numberOfMipsStripped: 0 numberOfMipsStrippedPerMipmapLimitGroup: {} - m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000i iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 iosUseCustomAppBackgroundBehavior: 0 @@ -65,10 +65,15 @@ PlayerSettings: useOSAutorotation: 1 use32BitDisplayBuffer: 1 preserveFramebufferAlpha: 0 + adjustIOSFPSUsingThermalState: 1 + thermalStateSeriousIOSFPS: 30 + thermalStateCriticalIOSFPS: 15 disableDepthAndStencilBuffers: 0 androidStartInFullscreen: 1 androidRenderOutsideSafeArea: 1 androidUseSwappy: 0 + androidRequestedVisibleInsets: 0 + androidSystemBarsBehavior: 2 androidDisplayOptions: 1 androidBlitType: 0 androidResizeableActivity: 0 @@ -83,6 +88,7 @@ PlayerSettings: defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 + callOnDisableOnAssetBundleUnload: 1 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 @@ -156,7 +162,7 @@ PlayerSettings: allowHDRDisplaySupport: 0 useHDRDisplay: 0 hdrBitDepth: 0 - m_ColorGamuts: 00000000 + m_ColorGamuts: 00000000i targetPixelDensity: 30 resolutionScalingMode: 0 resetResolutionOnWindowResize: 0 @@ -173,7 +179,7 @@ PlayerSettings: tvOS: 0 overrideDefaultApplicationIdentifier: 1 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 25 + AndroidMinSdkVersion: 26 AndroidTargetSdkVersion: 35 AndroidPreferredInstallLocation: 1 AndroidPreferredDataLocation: 1 @@ -198,6 +204,7 @@ PlayerSettings: tvOSTargetOSVersionString: 15.0 VisionOSSdkVersion: 0 VisionOSTargetOSVersionString: 1.0 + xcodeProjectType: 0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -265,7 +272,6 @@ PlayerSettings: useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 AndroidTargetArchitectures: 3 - AndroidAllowedArchitectures: -1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: @@ -539,12 +545,11 @@ PlayerSettings: m_GraphicsJobMode: 0 m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer - m_APIs: 0b000000 + m_APIs: 0b000000i m_Automatic: 0 - m_BuildTarget: iOSSupport - m_APIs: 10000000 + m_APIs: 10000000i m_Automatic: 1 - m_BuildTargetVRSettings: [] m_DefaultShaderChunkSizeInMB: 16 m_DefaultShaderChunkCount: 0 openGLRequireES31: 0 @@ -563,10 +568,10 @@ PlayerSettings: m_BuildTargetDefaultTextureCompressionFormat: - serializedVersion: 3 m_BuildTarget: iOS - m_Formats: 03000000 + m_Formats: 03000000i - serializedVersion: 3 m_BuildTarget: Android - m_Formats: 01000000 + m_Formats: 01000000i playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 @@ -724,6 +729,8 @@ PlayerSettings: switchMicroSleepForYieldTime: 25 switchRamDiskSpaceSize: 12 switchUpgradedPlayerSettingsToNMETA: 0 + switchCaStoreSource: 0 + switchCaStoreFilePath: ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -832,6 +839,7 @@ PlayerSettings: webGLCloseOnQuit: 0 webWasm2023: 0 webEnableSubmoduleStrippingCompatibility: 0 + webProgressiveAssetLoading: 0 scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} @@ -839,6 +847,7 @@ PlayerSettings: Android: 1 il2cppCompilerConfiguration: {} il2cppCodeGeneration: {} + il2cppLTOMode: {} il2cppStacktraceInformation: {} managedStrippingLevel: EmbeddedLinux: 1 @@ -862,6 +871,7 @@ PlayerSettings: scriptingRuntimeVersion: 1 gcIncremental: 0 gcWBarrierValidation: 0 + managedCodeVariant: {} apiCompatibilityLevelPerPlatform: iPhone: 6 editorAssembliesCompatibilityLevel: 1 @@ -886,8 +896,7 @@ PlayerSettings: metroDefaultTileSize: 1 metroTileForegroundText: 2 metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} - metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, - a: 1} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} metroSplashScreenUseBackgroundColor: 0 syncCapabilities: 0 platformCapabilities: {} @@ -923,7 +932,6 @@ PlayerSettings: XboxOneXTitleMemory: 8 XboxOneOverrideIdentityName: XboxOneOverrideIdentityPublisher: - vrEditorSettings: {} cloudServicesEnabled: Build: 0 Game Performance: 0 @@ -969,4 +977,5 @@ PlayerSettings: androidVulkanAllowFilterList: [] androidVulkanDeviceFilterListAsset: {fileID: 0} d3d12DeviceFilterListAsset: {fileID: 0} + webGPUDeviceFilterListAsset: {fileID: 0} allowedHttpConnections: 3 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 36d312e4..20bd4c3b 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.4.5f1 -m_EditorVersionWithRevision: 6000.4.5f1 (cc83ebd631f8) +m_EditorVersion: 6000.6.0f1 +m_EditorVersionWithRevision: 6000.6.0f1 (f7f8ed4d1e24) diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 84c16101..0b213e74 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -6,7 +6,7 @@ QualitySettings: serializedVersion: 5 m_CurrentQuality: 3 m_QualitySettings: - - serializedVersion: 2 + - serializedVersion: 5 name: Very Low pixelLightCount: 0 shadows: 0 @@ -18,23 +18,48 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 1 - textureQuality: 1 + skinWeights: 1 + globalTextureMipmapLimit: 1 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 0 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 0 + realtimeGICPUUsage: 25 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 0.3 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 4 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] - - serializedVersion: 2 + - serializedVersion: 5 name: Low pixelLightCount: 0 shadows: 0 @@ -46,23 +71,48 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 + skinWeights: 2 + globalTextureMipmapLimit: 0 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 0 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 0 + realtimeGICPUUsage: 25 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 0.4 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 16 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] - - serializedVersion: 2 + - serializedVersion: 5 name: Medium pixelLightCount: 1 shadows: 0 @@ -74,23 +124,48 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 + skinWeights: 2 + globalTextureMipmapLimit: 0 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 0 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 1 + realtimeGICPUUsage: 25 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 0.7 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 64 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] - - serializedVersion: 2 + - serializedVersion: 5 name: High pixelLightCount: 2 shadows: 0 @@ -102,23 +177,48 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 2 - textureQuality: 0 + skinWeights: 2 + globalTextureMipmapLimit: 0 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 1 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 1 + realtimeGICPUUsage: 50 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 1 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 256 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] - - serializedVersion: 2 + - serializedVersion: 5 name: Very High pixelLightCount: 3 shadows: 0 @@ -130,23 +230,48 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 + skinWeights: 4 + globalTextureMipmapLimit: 0 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 1 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 1 + realtimeGICPUUsage: 50 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 1.5 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 1024 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] - - serializedVersion: 2 + - serializedVersion: 5 name: Ultra pixelLightCount: 4 shadows: 0 @@ -158,26 +283,53 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 + skinWeights: 4 + globalTextureMipmapLimit: 0 + textureMipmapLimitSettings: [] anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 softVegetation: 1 realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 + useLegacyDetailDistribution: 1 + adaptiveVsync: 0 vSyncCount: 1 + realtimeGICPUUsage: 100 + adaptiveVsyncExtraA: 0 + adaptiveVsyncExtraB: 0 lodBias: 2 + meshLodThreshold: 1 maximumLODLevel: 0 + enableLODCrossFade: 1 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 4096 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} + terrainQualityOverrides: 0 + terrainPixelError: 1 + terrainDetailDensityScale: 1 + terrainBasemapDistance: 1000 + terrainDetailDistance: 80 + terrainTreeDistance: 5000 + terrainBillboardStart: 50 + terrainFadeLength: 5 + terrainMaxTrees: 50 excludedTargetPlatforms: [] + m_TextureMipmapLimitGroupNames: [] m_PerPlatformDefaultQuality: Android: 2 Nintendo 3DS: 5 Nintendo Switch: 5 + Nintendo Switch 2: 5 PS4: 5 PSM: 5 PSP2: 2 diff --git a/README.md b/README.md index dd52305d..5b8dcb8b 100755 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Adapty Unity SDK is a native wrapper around [Adapty iOS SDK](https://github.com/adaptyteam/AdaptySDK-iOS) and [Adapty Android SDK](https://github.com/adaptyteam/AdaptySDK-Android). Both SDKs are written in pure Swift/Kotlin, all wrapped into a C# lib. -Requires Unity 2022.3 or newer and Android API 21 or newer. iOS builds require **Xcode 26 or newer** +Requires Unity 6.0 (6000.0) or newer and Android API 21 or newer. iOS builds require **Xcode 26 or newer** and a deployment target of 15.0 or newer: AdaptySDK-iOS 4.x is a `swift-tools-version: 6.2` package, and an older toolchain refuses to resolve it. Open the exported project as **`Unity-iPhone.xcworkspace`** — building `Unity-iPhone.xcodeproj` directly fails at link time with From 29e0816eda4ea6c0017e864c93ac8af9364093d6 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:49:27 +0200 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20SDK=20harness=20=E2=80=94=20drive?= =?UTF-8?q?=20the=20real=20SDK=20on=20the=20iOS=20simulator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A player with nothing in it but the pipeline runtime server and AdaptySdkHarness, which exposes the public Adapty/AdaptyUI API as harness_* commands: activate, call any method by name with JSON arguments (returned models are passed back as $Method handles, request-only models through their Builder), read the events the listeners received. A UI Toolkit ledger on screen shows every request, reply, late reply and event. harness_build builds the scene for the simulator SDK and files AdaptyDemo.storekit in the Xcode project and scheme; running it from Xcode makes purchases local. The ios-storekit-purchase skill drives the purchase sheet and alerts from the simulator's log. Recipe and limits in Assets/SdkHarness/AGENTS.md. --- .claude/skills/ios-storekit-purchase/SKILL.md | 87 ++ .gitignore | 1 + AGENTS.md | 2 + Assets/SdkHarness.meta | 8 + Assets/SdkHarness/AGENTS.md | 30 + Assets/SdkHarness/AGENTS.md.meta | 7 + .../SdkHarness}/AdaptyDemo.storekit | 0 Assets/SdkHarness/AdaptyDemo.storekit.meta | 7 + Assets/SdkHarness/AdaptySdkHarness.cs | 808 ++++++++++++++++++ Assets/SdkHarness/AdaptySdkHarness.cs.meta | 2 + Assets/SdkHarness/Editor.meta | 8 + Assets/SdkHarness/Editor/SdkHarnessBuild.cs | 112 +++ .../SdkHarness/Editor/SdkHarnessBuild.cs.meta | 2 + Assets/SdkHarness/SdkHarness.unity | 191 +++++ Assets/SdkHarness/SdkHarness.unity.meta | 7 + Assets/SdkHarness/SdkHarnessPanel.asset | 54 ++ Assets/SdkHarness/SdkHarnessPanel.asset.meta | 8 + Assets/SdkHarness/SdkHarnessTheme.tss | 1 + Assets/SdkHarness/SdkHarnessTheme.tss.meta | 12 + Assets/SdkHarness/link.xml | 7 + Assets/SdkHarness/link.xml.meta | 7 + ProjectSettings/ProjectSettings.asset | 4 +- 22 files changed, 1363 insertions(+), 2 deletions(-) create mode 100644 .claude/skills/ios-storekit-purchase/SKILL.md create mode 100644 Assets/SdkHarness.meta create mode 100644 Assets/SdkHarness/AGENTS.md create mode 100644 Assets/SdkHarness/AGENTS.md.meta rename {deploy => Assets/SdkHarness}/AdaptyDemo.storekit (100%) create mode 100644 Assets/SdkHarness/AdaptyDemo.storekit.meta create mode 100644 Assets/SdkHarness/AdaptySdkHarness.cs create mode 100644 Assets/SdkHarness/AdaptySdkHarness.cs.meta create mode 100644 Assets/SdkHarness/Editor.meta create mode 100644 Assets/SdkHarness/Editor/SdkHarnessBuild.cs create mode 100644 Assets/SdkHarness/Editor/SdkHarnessBuild.cs.meta create mode 100644 Assets/SdkHarness/SdkHarness.unity create mode 100644 Assets/SdkHarness/SdkHarness.unity.meta create mode 100644 Assets/SdkHarness/SdkHarnessPanel.asset create mode 100644 Assets/SdkHarness/SdkHarnessPanel.asset.meta create mode 100644 Assets/SdkHarness/SdkHarnessTheme.tss create mode 100644 Assets/SdkHarness/SdkHarnessTheme.tss.meta create mode 100644 Assets/SdkHarness/link.xml create mode 100644 Assets/SdkHarness/link.xml.meta diff --git a/.claude/skills/ios-storekit-purchase/SKILL.md b/.claude/skills/ios-storekit-purchase/SKILL.md new file mode 100644 index 00000000..22145b05 --- /dev/null +++ b/.claude/skills/ios-storekit-purchase/SKILL.md @@ -0,0 +1,87 @@ +--- +name: ios-storekit-purchase +description: Use when a run on the iOS simulator has to get through a StoreKit purchase — the local StoreKit configuration, the purchase sheet and the alerts after it, which log line means which window is up and where its button is — for any app; the SDK harness is the usual one +--- + +# StoreKit purchases on the iOS simulator + +A purchase on the simulator is local only while Xcode's StoreKit configuration is active for the +app: Xcode syncs the `.storekit` file selected in the scheme's Run options into the simulator when +it launches the app, and `storekitd` then serves the products itself. Nothing else performs that +sync — `xcodebuild` ignores the scheme option, and an `SKTestSession` opened from the app is +refused as not entitled — so the app has to be launched by Xcode. Without the configuration every +purchase goes to the App Store sandbox and asks for an Apple Account. (`Assets/SdkHarness/AGENTS.md` +is how this repository's harness gets the configuration and the launch.) + +With it active, every purchase goes through three system windows, each needing a tap. They always +sit at the same place, and each one writes a line to the simulator's log, so nothing has to be +looked at: start the purchase, wait for the line, tap, repeat. The taps come from the simulator +control tool; the waits are shell. + +## The three windows and their log lines + +Everything is read with `xcrun simctl spawn log show --start --predicate …`. One +`t0` per purchase, taken before the purchase is sent: a wait that takes its own start time after a +tap misses the line the tap produced a second earlier. + +| window | log line that means it is on screen | tap | +|---|---|---| +| purchase sheet "Xcode · · Subscribe" | `process == "PassbookUIService" AND subsystem == "com.apple.passkit" AND category == "Analytics" AND eventMessage CONTAINS "inApp"` — the sheet is hosted by `PassbookUIService`, and this line is written once the product is rendered | Subscribe | +| alert "You’re all set." | `process == "SpringBoard" AND category == "AlertItems" AND eventMessage CONTAINS "Received request to activate alertItem"`, `title:` in the same line | OK (full width) | +| alert "You’re currently subscribed to this." | same line, different title — the product is already active, no sheet is shown | OK (right of Manage) | +| alert closed | same category, `eventMessage CONTAINS "Deactivated alertItem"` | — | + +The purchase completes only after the alert's OK: `storekitd` logs `AMSPurchaseTask … === +Finished ===` at that tap, not at Subscribe. So whatever started the purchase has to keep waiting +with a long budget, and its result is read after the third window. + +## Where the buttons are + +All three windows are system UI, laid out by iOS from the screen size in points (W×H) and the +safe area, so the taps follow from the size rather than from a table. W and H are the screenshot's +pixel size over 3 (every iPhone simulator is 3×); C = (H + 25) / 2 is the middle of the safe area +on a Dynamic Island phone (59 pt above, 34 below): + +| button | x | y | why | +|---|---|---|---| +| Subscribe | W / 2 | H − 55 | pinned to the bottom of the sheet | +| OK on "You’re all set." | W / 2 | C + 57 | the alert is centred in the safe area, its text never changes, its width is fixed | +| OK on "You’re currently subscribed to this." | W / 2 + 74 | C + 99 | longer text, two buttons side by side; Manage is at W / 2 − 74 | + +Verified on iPhone 17 Pro (402×874: 201×819, 201×506, 275×548) and iPhone 17 Pro Max (440×956: +220×901, 220×547, 294×589) — every measured button within 1 pt of the formula. On iPhone 17e +(390×844) only Subscribe (195×789) was measured; its alerts were not, so the 25 in C is a +Dynamic-Island figure that the 17e has not confirmed. iPad is out: the sheet and the alerts are +laid out differently. + +## Running it + +```bash +UDID= +T0=$(date '+%Y-%m-%d %H:%M:%S') # one t0 for the whole purchase +# start the purchase in the background with a long budget — on the harness: +# unity command harness_call --runtime-path "$APP" --method MakePurchase --args '{"product":"$GetPaywallProducts[0]"}' --timeout_ms 90000 --timeout 120 > /tmp/purchase.json & +# wait for a window: the first line after T0 matching the sheet or an alert (title in the line if it is an alert) +until L=$(xcrun simctl spawn $UDID log show --start "$T0" --predicate '(process == "PassbookUIService" AND subsystem == "com.apple.passkit" AND category == "Analytics" AND eventMessage CONTAINS "inApp") OR (process == "SpringBoard" AND category == "AlertItems" AND eventMessage CONTAINS "Received request to activate alertItem")' --style compact | grep -v '^Timestamp' | head -1) && [[ -n "$L" ]]; do sleep 1; done; echo "$L" | grep -o 'title: [^;]*' || echo sheet +# tap Subscribe (or the button the title calls for), then wait the same way for the alert line, tap its OK, +# then wait for `eventMessage CONTAINS "Deactivated alertItem"`; only after that does the purchase return. +``` + +A whole purchase is about 25 s wall-clock, nearly all of it the turns between commands and taps; +the sheet itself is logged in the same second the purchase is sent. + +## What the store remembers + +Transactions live in the simulator's `storekitd`, not in the app: reinstalling the app keeps +them, so a second purchase of an active subscription gets the "currently subscribed" alert (and +still returns success), and a different product in the same group is queued to start when the +current one expires — the profile keeps showing the old product, which is StoreKit doing its job. +Clearing them takes Xcode's Debug ▸ StoreKit ▸ Manage Transactions, or erasing the simulator. + +## When a sign-in window appears + +"Sign in to Apple Account" (fields, Cancel/OK) is also an `SBUserNotificationAlert`, so the wait +reports it by title. Tap Cancel (W / 2 − 74, above the keyboard) and stop: never type anything +into it. It means the purchase went to the App Store sandbox, i.e. the local configuration is not +active — the app was launched by something other than Xcode (`xcodebuild`, `simctl launch`), or +the scheme lost its `StoreKitConfigurationFileReference`. Fix the launch; do not press on. diff --git a/.gitignore b/.gitignore index 6942fe3a..115ac1c4 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,4 @@ tests/**/*.received.txt # iOS player output of the demo build scripts ios-sim-build/ ios-stripped-build/ +ios-harness-build/ diff --git a/AGENTS.md b/AGENTS.md index a570b24c..ad2a1b01 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,6 +21,8 @@ dotnet test tests/AdaptySDK.NextTests/AdaptySDK.NextTests.csproj ``` The layer branches on `UNITY_IOS` / `UNITY_ANDROID` and each platform has its own approved snapshots, so a change to it has to pass all four legs: add `-p:AdaptyPlatform=UNITY_IOS` or `-p:AdaptyPlatform=UNITY_ANDROID` for two of the others. Asking for no platform means `UNITY_EDITOR`, which the projects default to — the Editor is a configuration of its own and has to say so, since it is what selects the no-op bridge; an empty define set is a state Unity never produces. The fourth is `-p:AdaptyPlatform="UNITY_IOS%3BADAPTY_KIDS_MODE"` — `%3B` escapes the `;` inside the MSBuild property value. Kids Mode is the only shipped define that changes the wire format rather than which sources compile, and its whole visible effect here is the forced `apple_idfa_collection_disabled`: three configuration requests have a second approved form under `-kids`, and `RequestParityTests.Configured` is what picks it. Nothing else in the layer moves with the define — if a fourth snapshot ever needs a `-kids` form, that is a change in blast radius worth understanding before approving it. `ADAPTY_UPDATE_SNAPSHOTS=1` rewrites the approved files instead of failing. CI runs the same matrix in `.github/workflows/json-layer-tests.yml`. +**Drive the real SDK on the iOS simulator:** `Assets/SdkHarness/` is a player the agent runs from the command line against the native SDK — build, launch, StoreKit and the command set are in [Assets/SdkHarness/AGENTS.md](Assets/SdkHarness/AGENTS.md); a purchase's system windows are handled by the `ios-storekit-purchase` skill. + **Build .unitypackage for distribution:** ```bash cd deploy && ./build_unitypackage.sh # export into deploy/output/ diff --git a/Assets/SdkHarness.meta b/Assets/SdkHarness.meta new file mode 100644 index 00000000..8b62e92f --- /dev/null +++ b/Assets/SdkHarness.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4fbce7343366464280bf81ec9b34b27 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SdkHarness/AGENTS.md b/Assets/SdkHarness/AGENTS.md new file mode 100644 index 00000000..f0eeef18 --- /dev/null +++ b/Assets/SdkHarness/AGENTS.md @@ -0,0 +1,30 @@ +# The SDK harness + +`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why `link.xml` beside it keeps the whole SDK assembly, and why every callback shape with a value-type payload (`bool`, `AdaptyLogLevel`) is instantiated once in `AotHints` so IL2CPP compiles it. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. + +## Build and run + +Build it with its own `harness_build` command (`Assets/SdkHarness/Editor/`), not `unity command build`: the CLI sends a single `--scenes` value as a string, the server binds that to an empty array and silently builds `EditorBuildSettings` instead, and `dry_run` reports a nonexistent scene as valid. A player build holds the main thread for minutes, so submit it detached and wait on the job: +```bash +unity command harness_build --detach # scenes = Assets/SdkHarness/SdkHarness.unity, iOS, Development, SimulatorSDK +unity job wait --timeout 1500 +xcrun simctl uninstall com.adapty.adaptydemoapp # or the previous install's descriptor passes for readiness +osascript -e 'tell application "Xcode" + set ws to open "'"$PWD"'/ios-harness-build/Unity-iPhone.xcworkspace" + repeat until loaded of ws + delay 1 + end repeat + set active scheme of ws to (first scheme of ws whose name is "Unity-iPhone") + set active run destination of ws to (first run destination of ws whose name is "iPhone 17 Pro (26.5)") + run ws +end tell' +APP=$(xcrun simctl get_app_container com.adapty.adaptydemoapp app) # --runtime-path takes this DIRECTORY, not the descriptor file inside it +unity command harness_activate --runtime-path "$APP" +unity command harness_call --runtime-path "$APP" --method GetFlow --args '{"placementId":"rt.RegTestPaywall1","fetchPolicy":"Default","loadTimeout":10}' +``` + +Open the **workspace**: External Dependency Manager writes a Podfile, and the bare `.xcodeproj` fails at link with `framework 'Pods_UnityFramework' not found`. Xcode runs it, not `xcodebuild`, because of purchases: `harness_build` files `Assets/SdkHarness/AdaptyDemo.storekit` in the project (as `text`, with no target membership — Xcode offers nothing else as a configuration) and selects it in the scheme's Run options, and Xcode syncs that configuration into the simulator through its Instruments service when it launches the app, so `storekitd` serves the products locally and `MakePurchase` raises Xcode's confirmation sheet instead of the Apple Account sign-in. Nothing else performs that sync: `xcodebuild` (build or test) ignores the scheme option, and an `SKTestSession` opened from the app, or from an `xcodebuild test` host, is refused by `storekitd` as not entitled. Xcode names its destination by device and runtime (`iPhone 17 Pro (26.5)`) and boots that simulator even when another one is up, so address the device by UDID (`xcrun simctl list devices`) rather than `booted`. The sheet and the "You're all set" alert after it take a tap each; the `ios-storekit-purchase` skill (`.claude/skills/ios-storekit-purchase/`) says which log line means which window is up and where its button is, so a purchase needs no screenshot. On the harness that is: `harness_activate`, `GetFlow` and `GetPaywallProducts` first, then `harness_call --method MakePurchase --args '{"product":"$GetPaywallProducts[0]"}' --timeout_ms 90000` in the background — it returns only after the alert's OK — and `GetProfile` to see the access level. The descriptor with the port and token appears next to the app's `Data/` once the server is up, which makes its existence the readiness signal. + +## What the commands can and cannot take + +Some argument shapes have no JSON reader in the SDK and get one in the harness: a type whose instances are public static members (`AdaptyPlacementFetchPolicy`, `AdaptyExternalAttributionProvider`) is addressed by member name, and a string for a type with a one-string constructor becomes that instance (a provider by identifier); a `TimeSpan` parameter is taken as seconds (inside an object it is Newtonsoft's `"00:00:10"`); enums go through the SDK's own converter as strings; a request-only model with a nested `Builder` (`AdaptyProfileParameters`, `AdaptyConfiguration`) is built from a JSON object — constructor arguments by parameter name, every other key a `Set` call, `customAttributes` an object of string or number values — so `UpdateProfile` takes `{"param":{"firstName":"A","customAttributes":{"plan":"pro","score":3}}}`. Models with public fields and a parameterless constructor (`AdaptyUICreateFlowViewParameters`, `AdaptyUIDialogConfiguration`, `AdaptyPurchaseParameters`) read as plain JSON. Not reachable this way: `AdaptyCustomAsset` values (factory methods, no members), custom tags and timers on `CreateFlowView` (setters, not fields), `SetFallback` (needs a file in the app), and the legacy onboarding events (`IAdaptyOnboardingsEventsListener` is obsolete; the harness does not register it). `Activate` is refused by `harness_call` because activation is once per process — `harness_activate` builds the configuration, with `--configuration` for the Builder keys it has no flag for. Only iOS: `harness_build` targets the simulator SDK, an Android build is not written. The player's own command set adds `console`, `runtime_status`, `simulate_pointer`; `eval` is registered there but compiled out on anything that is not the Editor or a standalone development build, which is why the harness's commands are compiled ones. Nothing here runs on a real device without a package change: the runtime server writes its descriptor into the app bundle and stops itself when that write fails. diff --git a/Assets/SdkHarness/AGENTS.md.meta b/Assets/SdkHarness/AGENTS.md.meta new file mode 100644 index 00000000..175577b6 --- /dev/null +++ b/Assets/SdkHarness/AGENTS.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fe1fe641b79924d808841dc31b99aec1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/deploy/AdaptyDemo.storekit b/Assets/SdkHarness/AdaptyDemo.storekit similarity index 100% rename from deploy/AdaptyDemo.storekit rename to Assets/SdkHarness/AdaptyDemo.storekit diff --git a/Assets/SdkHarness/AdaptyDemo.storekit.meta b/Assets/SdkHarness/AdaptyDemo.storekit.meta new file mode 100644 index 00000000..a4689dec --- /dev/null +++ b/Assets/SdkHarness/AdaptyDemo.storekit.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eb3c8a09d915845b4bd3520baf80909c +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs new file mode 100644 index 00000000..31ac97e1 --- /dev/null +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -0,0 +1,808 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading; +using AdaptySDK; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Unity.Pipeline.Commands; +using UnityEngine; +using UnityEngine.Scripting; +using UnityEngine.UIElements; + +namespace AdaptyExample.SdkHarness +{ + /// + /// Drives the SDK's public C# API over the Pipeline command channel on a player where the native + /// SDK is real, and hands back what the SDK decoded — the round-trip the desktop suite cannot make. + /// + /// + /// Every call goes through the typed public surface: the SDK encodes the request and decodes the + /// reply itself, which is what is under test. The harness only binds arguments, waits, and reports. + /// + /// Commands run on the request thread, not the main one. A call is posted to the main thread and + /// awaited here, because the SDK delivers its callback through SynchronizationContext.Post + /// and the main loop has to stay free to run it — waiting on the main thread would deadlock every + /// call. The wait budget stays below the scene's 120 s request timeout. + /// + /// A player discovers commands by reflection and reaches the harness from nothing else, so + /// link.xml beside this file keeps the namespace and the whole SDK assembly, and each + /// handler carries as well. + /// + public sealed class AdaptySdkHarness + : MonoBehaviour, + IAdaptyEventListener, + IAdaptyFlowsEventsListener, + IAdaptyUISystemRequestsHandler, + IAdaptyUIObserverModeResolver + { + private const string DemoApiKey = "public_live_iNuUlSsN.83zcTTR8D5Y8FI9cGUI6"; + private const int DefaultTimeoutMs = 20000; + + private static SynchronizationContext s_Main; + private static bool s_Activated; + private static readonly object s_Gate = new object(); + private static readonly List s_Events = new List(); + + /// + /// The on-screen ledger of what the harness did, for whoever is watching the simulator. The + /// agent reads the command results; a person reads this. + /// + [SerializeField] + private PanelSettings m_Panel; + + private static AdaptySdkHarness s_Instance; + private ScrollView m_Ledger; + + // AdaptyJson is internal. Its two entry points are what keep this harness on the SDK's own wire + // format instead of a second serializer that would hide a converter bug behind a symmetric one. + private static readonly Type s_Json = typeof(Adapty).Assembly.GetType( + "AdaptySDK.Serialization.AdaptyJson" + ); + private static readonly MethodInfo s_Serialize = s_Json.GetMethod( + "Serialize", + BindingFlags.NonPublic | BindingFlags.Static + ); + private static readonly MethodInfo s_CreateSerializer = s_Json.GetMethod( + "CreateSerializer", + BindingFlags.NonPublic | BindingFlags.Static + ); + + private void Awake() + { + s_Main = SynchronizationContext.Current; + s_Instance = this; + DontDestroyOnLoad(gameObject); + + Adapty.SetEventListener(this); + Adapty.SetFlowsEventsListener(this); + Adapty.SetSystemRequestsHandler(this); + Adapty.SetObserverModeResolver(this); + } + + /// + /// Built in code rather than UXML: three elements do not earn an asset, and the one asset + /// it does need — the panel with its theme — is what the scene references. + /// + private void Start() + { + if (m_Panel == null) + { + return; + } + + var document = gameObject.AddComponent(); + document.panelSettings = m_Panel; + + var root = document.rootVisualElement; + root.style.flexGrow = 1; + root.style.paddingTop = 54; + root.style.paddingLeft = 10; + root.style.paddingRight = 10; + root.style.paddingBottom = 24; + root.style.backgroundColor = new Color(0.07f, 0.07f, 0.09f); + + var title = new Label($"Adapty SDK harness · SDK {Adapty.SDKVersion} · pipeline :7900"); + title.style.color = new Color(0.6f, 0.6f, 0.65f); + title.style.fontSize = 12; + title.style.marginBottom = 8; + root.Add(title); + + m_Ledger = new ScrollView(ScrollViewMode.Vertical); + m_Ledger.style.flexGrow = 1; + // Follow the newest line once its layout exists — scheduling right after Add runs before + // the new label has a height, and the offset clamps to the previous bottom. + m_Ledger.contentContainer.RegisterCallback( + _ => m_Ledger.scrollOffset = new Vector2(0, float.MaxValue) + ); + Restyle(m_Ledger.verticalScroller); + root.Add(m_Ledger); + + Ledger("·", "waiting for commands"); + } + + /// + /// The default theme's scroller is a desktop one — arrow buttons, a framed track, a column + /// of its own. On a phone the ledger wants a thin translucent indicator laid over the text. + /// + private static void Restyle(Scroller scroller) + { + scroller.lowButton.style.display = DisplayStyle.None; + scroller.highButton.style.display = DisplayStyle.None; + + scroller.style.position = Position.Absolute; + scroller.style.top = 0; + scroller.style.bottom = 0; + scroller.style.right = 0; + scroller.style.width = 6; + scroller.style.backgroundColor = Color.clear; + + var slider = scroller.slider; + slider.style.marginTop = 0; + slider.style.marginBottom = 0; + slider.style.backgroundColor = Color.clear; + Flat(slider); + + var tracker = slider.Q("unity-tracker"); + + if (tracker != null) + { + tracker.style.backgroundColor = Color.clear; + Flat(tracker); + } + + var dragger = slider.Q("unity-dragger"); + + if (dragger != null) + { + dragger.style.width = 4; + dragger.style.left = 1; + dragger.style.backgroundColor = new Color(1f, 1f, 1f, 0.3f); + dragger.style.borderTopLeftRadius = 2; + dragger.style.borderTopRightRadius = 2; + dragger.style.borderBottomLeftRadius = 2; + dragger.style.borderBottomRightRadius = 2; + Flat(dragger); + } + } + + private static void Flat(VisualElement element) + { + element.style.borderTopWidth = 0; + element.style.borderBottomWidth = 0; + element.style.borderLeftWidth = 0; + element.style.borderRightWidth = 0; + } + + /// + /// Appends one line, from any thread. The mark says what kind of line it is: → request, + /// ← reply, × failure, « event delivered to a listener. + /// + private static void Ledger(string mark, string text) + { + var harness = s_Instance; + + if (harness == null || harness.m_Ledger == null || s_Main == null) + { + return; + } + + var body = text.Length > 320 ? text.Substring(0, 320) + "…" : text; + + s_Main.Post( + _ => + { + var line = new Label($"{Time.realtimeSinceStartup,6:F1}s {mark} {body}"); + line.style.whiteSpace = WhiteSpace.Normal; + line.style.fontSize = 11; + line.style.marginBottom = 3; + line.style.color = mark switch + { + "→" => new Color(0.55f, 0.75f, 1f), + "←" => new Color(0.6f, 0.9f, 0.6f), + "×" => new Color(1f, 0.5f, 0.5f), + "«" => new Color(1f, 0.85f, 0.4f), + _ => new Color(0.6f, 0.6f, 0.65f), + }; + + var content = harness.m_Ledger.contentContainer; + content.Add(line); + + while (content.childCount > 120) + { + content.RemoveAt(0); + } + }, + null + ); + } + + [CliCommand("harness_status", "Whether the SDK was activated through the harness, and how many events it buffered.", + MainThreadRequired = false, Tags = new[] { "adapty" })] + [Preserve] + public static object Status() + { + lock (s_Gate) + { + return new + { + activated = s_Activated, + events = s_Events.Count, + sdk = Adapty.SDKVersion, + platform = Application.platform.ToString(), + }; + } + } + + /// + /// Activation is the one call whose argument, AdaptyConfiguration, has no JSON reader — + /// it is request-only — so it is built here from the builder instead of bound by name. + /// + [CliCommand("harness_activate", "Activate the SDK through AdaptyConfiguration.Builder and wait for the callback.", + MainThreadRequired = false, Tags = new[] { "adapty" })] + [Preserve] + public static object Activate( + [CliArg("api_key", "Public API key. Defaults to the demo app's.")] string apiKey = DemoApiKey, + [CliArg("customer_user_id", "Customer user id; empty for none.")] string customerUserId = "", + [CliArg("observer_mode", "Observer mode.")] bool observerMode = false, + [CliArg("activate_ui", "Activate AdaptyUI as well.")] bool activateUi = true, + [CliArg("configuration", "JSON object for the rest of AdaptyConfiguration.Builder: each key is a Set call, e.g. {\"serverCluster\":\"EU\",\"appleIDFACollectionDisabled\":true}.")] string configuration = "{}", + [CliArg("timeout_ms", "How long to wait for the callback.")] int timeoutMs = DefaultTimeoutMs) + { + var builder = new AdaptyConfiguration.Builder(apiKey) + .SetCustomerUserId(string.IsNullOrEmpty(customerUserId) ? null : customerUserId) + .SetObserverMode(observerMode) + .SetActivateUI(activateUi); + Apply(builder, JObject.Parse(configuration), (JsonSerializer)s_CreateSerializer.Invoke(null, null)); + + Ledger("→", $"Activate key …{apiKey.Substring(Math.Max(0, apiKey.Length - 6))} observer={observerMode} ui={activateUi}" + + (string.IsNullOrEmpty(customerUserId) ? "" : " user=" + customerUserId)); + + var call = new Call(); + var result = call.Run(() => Adapty.Activate(builder, call.OnVoid), timeoutMs, "Activate"); + + if (result.ok) + { + lock (s_Gate) + { + s_Activated = true; + } + } + + return result; + } + + /// + /// Any other public method: the overload is picked by the argument names supplied, the + /// arguments are read with the SDK's own serializer, and the callback's payload comes back + /// serialized by it too. + /// + [CliCommand("harness_call", "Call a public Adapty method by name with JSON arguments, wait for its callback, return what the SDK decoded.", + MainThreadRequired = false, Tags = new[] { "adapty" })] + [Preserve] + public static object CallSdk( + [CliArg("method", "Public static method on Adapty, e.g. GetProfile or GetFlow.", Required = true)] string method, + [CliArg("args", "JSON object of arguments keyed by parameter name.")] string args = "{}", + [CliArg("timeout_ms", "How long to wait for the callback.")] int timeoutMs = DefaultTimeoutMs) + { + if (method == nameof(Adapty.Activate)) + { + return Fail(method, "use harness_activate"); + } + + JObject provided; + + try + { + provided = JObject.Parse(string.IsNullOrWhiteSpace(args) ? "{}" : args); + } + catch (Exception e) + { + return Fail(method, "args is not a JSON object: " + e.Message); + } + + // The public surface is two static classes: Adapty, and AdaptyUI for the flow views. + var candidates = new[] { typeof(Adapty), typeof(AdaptyUI) } + .SelectMany(t => t.GetMethods(BindingFlags.Public | BindingFlags.Static)) + .Where(m => m.Name == method) + .ToList(); + + if (candidates.Count == 0) + { + return Fail(method, $"neither Adapty.{method} nor AdaptyUI.{method} exists"); + } + + var chosen = candidates.FirstOrDefault(m => Matches(m, provided)); + + if (chosen == null) + { + return Fail( + method, + $"no overload takes exactly [{string.Join(", ", provided.Properties().Select(p => p.Name))}]; " + + "options: " + string.Join(" | ", candidates.Select(Describe)) + ); + } + + var call = new Call(); + object[] bound; + + try + { + bound = Bind(chosen, provided, call); + } + catch (Exception e) + { + return Fail(method, "binding: " + e.Message); + } + + Ledger("→", $"{method} {provided.ToString(Formatting.None)}"); + + return call.Run(() => chosen.Invoke(null, bound), timeoutMs, method); + } + + [CliCommand("harness_events", "Events the SDK delivered to the harness's listeners since launch, or since the last clear.", + MainThreadRequired = false, Tags = new[] { "adapty" })] + [Preserve] + public static object Events([CliArg("clear", "Empty the buffer after reading.")] bool clear = false) + { + lock (s_Gate) + { + var copy = s_Events.ToList(); + + if (clear) + { + s_Events.Clear(); + } + + return new { count = copy.Count, events = copy }; + } + } + + private static bool Matches(MethodInfo method, JObject provided) + { + var names = method + .GetParameters() + .Where(p => !typeof(Delegate).IsAssignableFrom(p.ParameterType)) + .Select(p => p.Name) + .ToHashSet(StringComparer.Ordinal); + + return names.SetEquals(provided.Properties().Select(p => p.Name)); + } + + private static string Describe(MethodInfo method) + { + return method.Name + "(" + + string.Join(", ", method.GetParameters() + .Where(p => !typeof(Delegate).IsAssignableFrom(p.ParameterType)) + .Select(p => p.Name)) + + ")"; + } + + private static object[] Bind(MethodInfo method, JObject provided, Call call) + { + var serializer = (JsonSerializer)s_CreateSerializer.Invoke(null, null); + var parameters = method.GetParameters(); + var bound = new object[parameters.Length]; + + for (var i = 0; i < parameters.Length; i++) + { + var parameter = parameters[i]; + + bound[i] = typeof(Delegate).IsAssignableFrom(parameter.ParameterType) + ? call.CallbackFor(parameter.ParameterType) + : Read(provided[parameter.Name], parameter.ParameterType, serializer); + } + + return bound; + } + + /// + /// Reads one argument. Two request-side shapes have no JSON reader of their own, so they get + /// one here: a type that publishes its instances as public static members, like + /// , is addressed by member name, and a + /// is taken as seconds. Everything else goes through the SDK's reader, + /// enums included — their string form is the SDK's own converter's business. + /// + private static object Read(JToken token, Type type, JsonSerializer serializer) + { + if (token == null || token.Type == JTokenType.Null) + { + return null; + } + + if (token.Type == JTokenType.String && token.Value().StartsWith("$", StringComparison.Ordinal)) + { + return Recall(token.Value(), type); + } + + var inner = Nullable.GetUnderlyingType(type) ?? type; + + if (inner == typeof(TimeSpan) && (token.Type == JTokenType.Integer || token.Type == JTokenType.Float)) + { + return TimeSpan.FromSeconds(token.Value()); + } + + if (token.Type == JTokenType.String && !inner.IsEnum && inner != typeof(string)) + { + var name = token.Value(); + var member = inner + .GetMembers(BindingFlags.Public | BindingFlags.Static) + .FirstOrDefault(m => + string.Equals(m.Name, name, StringComparison.OrdinalIgnoreCase) + && (m is FieldInfo f && f.FieldType == inner || m is PropertyInfo p && p.PropertyType == inner) + ); + + if (member != null) + { + return member is FieldInfo field ? field.GetValue(null) : ((PropertyInfo)member).GetValue(null); + } + + // A type made from one string — a provider by its identifier. + var fromString = inner.GetConstructor(new[] { typeof(string) }); + + if (fromString != null) + { + return fromString.Invoke(new object[] { name }); + } + } + + // Request-only models (AdaptyProfileParameters, AdaptyConfiguration) have no reader, only a + // nested Builder: constructor arguments by parameter name, the other keys as Set. + if (token.Type == JTokenType.Object && inner.GetNestedType("Builder") is Type builderType) + { + var json = (JObject)token; + var constructor = builderType.GetConstructors() + .OrderByDescending(c => c.GetParameters().Length) + .FirstOrDefault(c => c.GetParameters().All(a => json.GetValue(a.Name, StringComparison.OrdinalIgnoreCase) != null)) + ?? throw new ArgumentException($"{inner.Name}.Builder needs {string.Join(" or ", builderType.GetConstructors().Select(c => "(" + string.Join(", ", c.GetParameters().Select(a => a.Name)) + ")"))}"); + var arguments = constructor.GetParameters().Select(a => a.Name).ToArray(); + var builder = constructor.Invoke(arguments.Select((a, i) => Read(json.GetValue(a, StringComparison.OrdinalIgnoreCase), constructor.GetParameters()[i].ParameterType, serializer)).ToArray()); + Apply(builder, new JObject(json.Properties().Where(x => !arguments.Contains(x.Name, StringComparer.OrdinalIgnoreCase))), serializer); + return builderType.GetMethod("Build").Invoke(builder, null); + } + + return token.ToObject(type, serializer); + } + + /// + /// Every key of as a Set<Key> call on . + /// customAttributes is the one two-argument setter: an object whose entries go to + /// SetCustomStringAttribute or SetCustomDoubleAttribute by value type. + /// + private static void Apply(object builder, JObject json, JsonSerializer serializer) + { + var builderType = builder.GetType(); + + foreach (var property in json.Properties()) + { + if (string.Equals(property.Name, "customAttributes", StringComparison.OrdinalIgnoreCase) && property.Value is JObject attributes) + { + foreach (var attribute in attributes.Properties()) + { + var isNumber = attribute.Value.Type == JTokenType.Integer || attribute.Value.Type == JTokenType.Float; + builderType.GetMethod(isNumber ? "SetCustomDoubleAttribute" : "SetCustomStringAttribute") + .Invoke(builder, new[] { attribute.Name, isNumber ? attribute.Value.Value() : (object)attribute.Value.Value() }); + } + + continue; + } + + var setter = builderType.GetMethods(BindingFlags.Public | BindingFlags.Instance) + .FirstOrDefault(m => m.GetParameters().Length == 1 && string.Equals(m.Name, "Set" + property.Name, StringComparison.OrdinalIgnoreCase)) + ?? throw new ArgumentException($"{builderType.DeclaringType?.Name}.Builder has no single-argument Set{property.Name}"); + setter.Invoke(builder, new[] { Read(property.Value, setter.GetParameters()[0].ParameterType, serializer) }); + } + } + + /// + /// What the last successful call of each method handed back, as the object itself. + /// + /// + /// An argument written as "$GetPaywallProducts[0]" or "$GetFlow" is that + /// object, not a re-read of its JSON. The SDK never reads a response model back from JSON — + /// a product goes out on a purchase as AdaptyPaywallProductRequest, a shape of its + /// own — so a response model has no complete reader, and feeding its dump back would fail on + /// the first one that lacks one (the subscription offer) while proving nothing about the SDK. + /// + private static readonly Dictionary s_Results = new Dictionary(StringComparer.Ordinal); + + private static object Recall(string reference, Type type) + { + var open = reference.IndexOf('['); + var name = (open < 0 ? reference : reference.Substring(0, open)).Substring(1); + object value; + + lock (s_Gate) + { + if (!s_Results.TryGetValue(name, out value)) + { + throw new ArgumentException($"{reference}: no successful {name} to recall; known: " + string.Join(", ", s_Results.Keys)); + } + } + + if (open >= 0) + { + var index = int.Parse(reference.Substring(open + 1).TrimEnd(']')); + var list = value as System.Collections.IList; + + if (list == null) + { + throw new ArgumentException($"{reference}: {name} returned a {value?.GetType().Name}, not a list"); + } + + value = list[index]; + } + + if (value != null && !type.IsInstanceOfType(value)) + { + throw new ArgumentException($"{reference} is a {value.GetType().Name}, the parameter wants {type.Name}"); + } + + return value; + } + + private static JToken ToJson(object value) + { + if (value == null) + { + return null; + } + + try + { + return JToken.Parse((string)s_Serialize.Invoke(null, new[] { value })); + } + catch (Exception e) + { + return new JObject { ["unserializable"] = value.ToString(), ["because"] = e.Message }; + } + } + + private static CallResult Fail(string method, string error) + { + Ledger("×", $"{method} {error}"); + return new CallResult { method = method, ok = false, error = error }; + } + + /// + /// The two callback shapes with a value-type payload, instantiated so IL2CPP compiles them. + /// Reference-type payloads share one instantiation and need nothing. Never called. + /// + [Preserve] + private static void AotHints() + { + new Capture(null).On(false, null); + new Capture(null).On(default, null); + } + + [Preserve] + public sealed class CallResult + { + public string method; + public bool ok; + public bool timedOut; + public string error; + public string exception; + public JToken result; + } + + /// + /// One SDK call: posts it to the main thread, waits on the request thread for whichever + /// comes first — the callback, an exception out of the call itself, or the deadline. + /// + private sealed class Call + { + private readonly ManualResetEventSlim m_Done = new ManualResetEventSlim(); + + private object m_Value; + private AdaptyError m_Error; + private Exception m_Thrown; + private string m_Method; + private DateTime m_Started; + private volatile bool m_TimedOut; + + public void OnVoid(AdaptyError error) => Complete(null, error); + + public void Complete(object value, AdaptyError error) + { + m_Value = value; + m_Error = error; + m_Done.Set(); + + // A reply after the budget is still a reply: it goes on the ledger and, if it carried + // an object, becomes the handle — the command that waited for it has already returned. + if (m_TimedOut) + { + Ledger(error == null ? "←" : "×", $"{m_Method} late {(DateTime.UtcNow - m_Started).TotalSeconds:F2}s " + (error?.ToString() ?? "ok")); + + if (error == null && value != null) + { + lock (s_Gate) + { + s_Results[m_Method] = value; + } + } + } + } + + public Delegate CallbackFor(Type callbackType) + { + var payload = callbackType.IsGenericType ? callbackType.GetGenericArguments() : Type.EmptyTypes; + + if (payload.Length == 1 && payload[0] == typeof(AdaptyError)) + { + return Delegate.CreateDelegate(callbackType, this, typeof(Call).GetMethod(nameof(OnVoid))); + } + + if (payload.Length == 2 && payload[1] == typeof(AdaptyError)) + { + var capture = Activator.CreateInstance(typeof(Capture<>).MakeGenericType(payload[0]), this); + return Delegate.CreateDelegate(callbackType, capture, capture.GetType().GetMethod("On")); + } + + throw new NotSupportedException("callback shape " + callbackType); + } + + public CallResult Run(Action invoke, int timeoutMs, string method) + { + m_Method = method; + m_Started = DateTime.UtcNow; + s_Main.Post( + _ => + { + try + { + invoke(); + } + catch (Exception e) + { + m_Thrown = e is TargetInvocationException t && t.InnerException != null ? t.InnerException : e; + m_Done.Set(); + } + }, + null + ); + + var started = DateTime.UtcNow; + var finished = m_Done.Wait(Math.Max(1000, timeoutMs)); + var elapsed = (DateTime.UtcNow - started).TotalSeconds; + m_TimedOut = !finished; + + var outcome = new CallResult + { + method = method, + ok = finished && m_Thrown == null && m_Error == null, + timedOut = !finished, + error = m_Error?.ToString(), + exception = m_Thrown?.ToString(), + result = ToJson(m_Value), + }; + + if (outcome.ok && m_Value != null) + { + lock (s_Gate) + { + s_Results[method] = m_Value; + } + } + + Ledger( + outcome.ok ? "←" : "×", + $"{method} {elapsed:F2}s " + + (outcome.timedOut ? "timed out" + : outcome.error ?? outcome.exception?.Split('\n')[0] + ?? outcome.result?.ToString(Formatting.None) ?? "ok") + ); + + return outcome; + } + } + + private sealed class Capture + { + private readonly Call m_Call; + + public Capture(Call call) => m_Call = call; + + public void On(T value, AdaptyError error) => m_Call.Complete(value, error); + } + + private static void Record(string name, params (string key, object value)[] args) + { + var entry = new JObject { ["event"] = name, ["at"] = Time.realtimeSinceStartup }; + var payload = new JObject(); + + foreach (var (key, value) in args) + { + payload[key] = ToJson(value); + } + + entry["args"] = payload; + + lock (s_Gate) + { + s_Events.Add(entry); + } + + Ledger("«", $"{name} {payload.ToString(Formatting.None)}"); + } + + public void OnLoadLatestProfile(AdaptyProfile profile) => Record("did_load_latest_profile", ("profile", profile)); + + public void OnReceivePromotedPurchase(AdaptyPromotedProduct product) => Record("did_receive_promoted_purchase", ("product", product)); + + public void OnInstallationDetailsSuccess(AdaptyInstallationDetails details) => Record("installation_details_success", ("details", details)); + + public void OnInstallationDetailsFail(AdaptyError error) => Record("installation_details_fail", ("error", error)); + + public void FlowViewDidAppear(AdaptyUIFlowView view) => Record("flow_view_did_appear", ("view", view)); + + public void FlowViewDidDisappear(AdaptyUIFlowView view) => Record("flow_view_did_disappear", ("view", view)); + + public void FlowViewDidPerformAction(AdaptyUIFlowView view, AdaptyUIUserAction action) => + Record("flow_view_did_perform_action", ("view", view), ("action", action)); + + public void FlowViewDidSelectProduct(AdaptyUIFlowView view, string productId) => + Record("flow_view_did_select_product", ("view", view), ("productId", productId)); + + public void FlowViewDidStartPurchase(AdaptyUIFlowView view, AdaptyPaywallProduct product) => + Record("flow_view_did_start_purchase", ("view", view), ("product", product)); + + public void FlowViewDidFinishPurchase(AdaptyUIFlowView view, AdaptyPaywallProduct product, AdaptyPurchaseResult purchasedResult) => + Record("flow_view_did_finish_purchase", ("view", view), ("product", product), ("result", purchasedResult)); + + public void FlowViewDidFailPurchase(AdaptyUIFlowView view, AdaptyPaywallProduct product, AdaptyError error) => + Record("flow_view_did_fail_purchase", ("view", view), ("product", product), ("error", error)); + + public void FlowViewDidStartRestore(AdaptyUIFlowView view) => Record("flow_view_did_start_restore", ("view", view)); + + public void FlowViewDidFinishRestore(AdaptyUIFlowView view, AdaptyProfile profile) => + Record("flow_view_did_finish_restore", ("view", view), ("profile", profile)); + + public void FlowViewDidFailRestore(AdaptyUIFlowView view, AdaptyError error) => + Record("flow_view_did_fail_restore", ("view", view), ("error", error)); + + public void FlowViewDidReceiveError(AdaptyUIFlowView view, AdaptyError error) => + Record("flow_view_did_receive_error", ("view", view), ("error", error)); + + public void FlowViewDidFailLoadingProducts(AdaptyUIFlowView view, AdaptyError error) => + Record("flow_view_did_fail_loading_products", ("view", view), ("error", error)); + + public void FlowViewDidFinishWebPaymentNavigation(AdaptyUIFlowView view, AdaptyPaywallProduct product, AdaptyError error) => + Record("flow_view_did_finish_web_payment_navigation", ("view", view), ("product", product), ("error", error)); + + public void FlowViewDidReceiveAnalyticEvent(AdaptyUIFlowView view, string name, IReadOnlyDictionary parameters) => + Record("flow_view_did_receive_analytic_event", ("view", view), ("name", name), ("parameters", parameters)); + + /// + /// Recorded and granted: the harness has no user to ask, and a request left unanswered would hold + /// the view open for the rest of the run. + /// + public void FlowViewDidAskPermission(AdaptyUIFlowView view, string permission, IReadOnlyDictionary customArgs, Action respond) + { + Record("flow_view_did_ask_permission", ("view", view), ("permission", permission), ("customArgs", customArgs)); + respond(true, null); + } + + public void FlowViewDidRequestAppReview(AdaptyUIFlowView view) => Record("flow_view_did_request_app_review", ("view", view)); + + /// + /// Observer mode leaves the purchase to the app; the harness has none, so it reports both stages + /// at once and lets the view continue. + /// + public void FlowViewDidInitiatePurchase(AdaptyUIFlowView view, AdaptyPaywallProduct product, Action onStartPurchase, Action onFinishPurchase) + { + Record("flow_view_did_initiate_purchase", ("view", view), ("product", product)); + onStartPurchase(); + onFinishPurchase(); + } + + public void FlowViewDidInitiateRestore(AdaptyUIFlowView view, Action onStartRestore, Action onFinishRestore) + { + Record("flow_view_did_initiate_restore", ("view", view)); + onStartRestore(); + onFinishRestore(); + } + } +} diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs.meta b/Assets/SdkHarness/AdaptySdkHarness.cs.meta new file mode 100644 index 00000000..6dc2b892 --- /dev/null +++ b/Assets/SdkHarness/AdaptySdkHarness.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c04c1e7a44200463b8fe27d597199b44 \ No newline at end of file diff --git a/Assets/SdkHarness/Editor.meta b/Assets/SdkHarness/Editor.meta new file mode 100644 index 00000000..68a20755 --- /dev/null +++ b/Assets/SdkHarness/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 63bd78cdb3eb84fd5a0c547766c3d5f1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs new file mode 100644 index 00000000..315d0dbf --- /dev/null +++ b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs @@ -0,0 +1,112 @@ +using System.IO; +using Unity.Pipeline.Commands; +using UnityEditor; +using UnityEditor.Callbacks; +#if UNITY_IOS +using UnityEditor.iOS.Xcode; +#endif + +namespace AdaptyExample.SdkHarness.Editor +{ + /// + /// Builds the harness scene — and only it — into ios-harness-build. + /// + /// + /// The Pipeline package has a build command of its own, but a single --scenes value + /// reaches it as a string, binds to an empty array, and it silently builds + /// EditorBuildSettings instead — the demo scene, with no harness in it. This one takes no + /// scene argument, so there is nothing to lose on the way. + /// + /// A player build holds the main thread for minutes, past any request budget: submit it with + /// --detach and collect the result with unity job wait. + /// + public static class SdkHarnessBuild + { + public const string Scene = "Assets/SdkHarness/SdkHarness.unity"; + public const string Output = "ios-harness-build"; + public const string StoreKitConfiguration = "Assets/SdkHarness/AdaptyDemo.storekit"; + + // Set for the duration of a harness build, so the post-processor below can tell a harness build + // from the demo's and leave the demo's bundle alone. + private static bool s_RigBuild; + + [CliCommand("harness_build", "Build the SDK harness scene for the iOS simulator into ios-harness-build (Development). Submit with --detach, then unity job wait.", + MainThreadRequired = true, Tags = new[] { "adapty" })] + public static object Build() + { + PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK; + s_RigBuild = true; + + UnityEditor.Build.Reporting.BuildReport report; + + try + { + report = BuildPipeline.BuildPlayer( + new BuildPlayerOptions + { + scenes = new[] { Scene }, + locationPathName = Output, + target = BuildTarget.iOS, + options = BuildOptions.Development, + } + ); + } + finally + { + s_RigBuild = false; + } + + return new + { + result = report.summary.result.ToString(), + errors = report.summary.totalErrors, + output = report.summary.outputPath, + seconds = (int)report.summary.totalTime.TotalSeconds, + }; + } + + /// + /// Gives the harness build Xcode's local StoreKit: the configuration is filed in the project + /// and selected in the scheme, so a run from Xcode syncs it into the simulator and + /// purchases never reach the App Store sandbox. + /// + /// + /// Only Xcode does that sync (through its Instruments service inside the simulator): + /// xcodebuild ignores the scheme option, and SKTestSession from the app is + /// refused by storekitd as not entitled. So the harness is launched from Xcode — see + /// AGENTS.md. Xcode offers a .storekit file as a configuration only when it is filed + /// as text with no target membership; Unity's AddFile files it as + /// file, hence the rewrite. + /// + [PostProcessBuild] + private static void AddLocalStoreKit(BuildTarget target, string path) + { +#if UNITY_IOS + if (!s_RigBuild || target != BuildTarget.iOS) + { + return; + } + + var configuration = Path.GetFileName(StoreKitConfiguration); + File.Copy(StoreKitConfiguration, Path.Combine(path, configuration), overwrite: true); + + var projectPath = PBXProject.GetPBXProjectPath(path); + var project = new PBXProject(); + project.ReadFromFile(projectPath); + project.AddFile(configuration, configuration); + project.WriteToFile(projectPath); + File.WriteAllText(projectPath, File.ReadAllText(projectPath).Replace( + "lastKnownFileType = file; path = " + configuration, + "lastKnownFileType = text; path = " + configuration)); + + // The identifier is relative to the .xcodeproj directory. + var scheme = Path.Combine(path, "Unity-iPhone.xcodeproj/xcshareddata/xcschemes/Unity-iPhone.xcscheme"); + File.WriteAllText(scheme, File.ReadAllText(scheme).Replace( + " ", + " \n" + + " \n" + + " ")); +#endif + } + } +} diff --git a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs.meta b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs.meta new file mode 100644 index 00000000..1e06e995 --- /dev/null +++ b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6573dd4b831fe4c8fa40e79decc5fa5f \ No newline at end of file diff --git a/Assets/SdkHarness/SdkHarness.unity b/Assets/SdkHarness/SdkHarness.unity new file mode 100644 index 00000000..259e3a8b --- /dev/null +++ b/Assets/SdkHarness/SdkHarness.unity @@ -0,0 +1,191 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 2 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 2 + m_PVRDenoiserTypeIndirect: 2 + m_PVRDenoiserTypeAO: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &867307089 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 867307090} + - component: {fileID: 867307091} + - component: {fileID: 867307092} + m_Layer: 0 + m_Name: SdkHarness + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &867307090 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 867307089} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &867307091 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 867307089} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dd4ab1c9091e0194196b5f5d51cb932f, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.Pipeline::Unity.Pipeline.RuntimePipelineManager + enableInBuilds: 1 + port: 7900 + requestTimeoutMs: 120000 + enableAuditLogging: 1 + autoStart: 1 + maxWorkItemsPerFrame: 10 + m_AllowedReloadRoots: [] +--- !u!114 &867307092 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 867307089} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c04c1e7a44200463b8fe27d597199b44, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::AdaptyExample.SdkHarness.AdaptySdkHarness + m_Panel: {fileID: 11400000, guid: ac2f5baa2e4f442b89340c59a72765fc, type: 2} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 867307090} diff --git a/Assets/SdkHarness/SdkHarness.unity.meta b/Assets/SdkHarness/SdkHarness.unity.meta new file mode 100644 index 00000000..d9c8905e --- /dev/null +++ b/Assets/SdkHarness/SdkHarness.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d02508a49266e45a88cc30236de88ea6 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SdkHarness/SdkHarnessPanel.asset b/Assets/SdkHarness/SdkHarnessPanel.asset new file mode 100644 index 00000000..3d3f3990 --- /dev/null +++ b/Assets/SdkHarness/SdkHarnessPanel.asset @@ -0,0 +1,54 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0} + m_Name: SdkHarnessPanel + m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.PanelSettings + themeUss: {fileID: -4733365628477956816, guid: 90e56d33def25451b9bdb79de53f9f2b, type: 3} + m_DisableNoThemeWarning: 0 + m_TargetTexture: {fileID: 0} + m_RenderMode: 0 + m_ColliderUpdateMode: 0 + m_ColliderIsTrigger: 1 + m_ScaleMode: 2 + m_ReferenceSpritePixelsPerUnit: 100 + m_PixelsPerUnit: 100 + m_Scale: 1 + m_ReferenceDpi: 95 + m_FallbackDpi: 96 + m_ReferenceResolution: {x: 390, y: 844} + m_ScreenMatchMode: 0 + m_Match: 0.5 + m_SortingOrder: 0 + m_TargetDisplay: 0 + m_BindingLogLevel: 0 + m_ClearDepthStencil: 1 + m_ClearColor: 0 + m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0} + m_VertexBudget: 0 + m_ExtraVertexChannels: 0 + m_TextureSlotCount: 8 + m_DynamicAtlasSettings: + m_MinAtlasSize: 64 + m_MaxAtlasSize: 4096 + m_MaxSubTextureSize: 64 + m_ActiveFilters: 31 + m_AtlasBlitShader: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0} + m_DefaultShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0} + m_RuntimeGaussianBlurShader: {fileID: 20300, guid: 0000000000000000f000000000000000, type: 0} + m_RuntimeColorEffectShader: {fileID: 20301, guid: 0000000000000000f000000000000000, type: 0} + m_RuntimeDropShadowComposite: {fileID: 20302, guid: 0000000000000000f000000000000000, type: 0} + m_SDFShader: {fileID: 19011, guid: 0000000000000000f000000000000000, type: 0} + m_BitmapShader: {fileID: 9001, guid: 0000000000000000f000000000000000, type: 0} + m_SpriteShader: {fileID: 19012, guid: 0000000000000000f000000000000000, type: 0} + m_ICUDataAsset: {fileID: 20204, guid: 0000000000000000f000000000000000, type: 0} + forceGammaRendering: 0 + textSettings: {fileID: 0} diff --git a/Assets/SdkHarness/SdkHarnessPanel.asset.meta b/Assets/SdkHarness/SdkHarnessPanel.asset.meta new file mode 100644 index 00000000..393d1a28 --- /dev/null +++ b/Assets/SdkHarness/SdkHarnessPanel.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac2f5baa2e4f442b89340c59a72765fc +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SdkHarness/SdkHarnessTheme.tss b/Assets/SdkHarness/SdkHarnessTheme.tss new file mode 100644 index 00000000..51924cb3 --- /dev/null +++ b/Assets/SdkHarness/SdkHarnessTheme.tss @@ -0,0 +1 @@ +@import url("unity-theme://default"); diff --git a/Assets/SdkHarness/SdkHarnessTheme.tss.meta b/Assets/SdkHarness/SdkHarnessTheme.tss.meta new file mode 100644 index 00000000..96f52b8a --- /dev/null +++ b/Assets/SdkHarness/SdkHarnessTheme.tss.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 90e56d33def25451b9bdb79de53f9f2b +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12388, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 + unsupportedSelectorAction: 0 diff --git a/Assets/SdkHarness/link.xml b/Assets/SdkHarness/link.xml new file mode 100644 index 00000000..4ee5ac15 --- /dev/null +++ b/Assets/SdkHarness/link.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Assets/SdkHarness/link.xml.meta b/Assets/SdkHarness/link.xml.meta new file mode 100644 index 00000000..f87f01f9 --- /dev/null +++ b/Assets/SdkHarness/link.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d0e7f3d9f3e2b48f6b54f44aa1648407 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 0a08c2e4..bf1e8bee 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -17,8 +17,8 @@ PlayerSettings: defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} - m_ShowUnitySplashScreen: 1 - m_ShowUnitySplashLogo: 1 + m_ShowUnitySplashScreen: 0 + m_ShowUnitySplashLogo: 0 m_SplashScreenOverlayOpacity: 1 m_SplashScreenAnimation: 1 m_SplashScreenLogoStyle: 1 From 426720902ab780cd480a79114fc16f235243d0d5 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 28 Oct 2026 16:27:06 +0100 Subject: [PATCH 3/7] chore: drop the harness's AOT hints IL2CPP on Unity 6 shares generics fully, so the Capture the harness makes by MakeGenericType runs for bool and enum payloads without an instantiation compiled ahead of time. Checked on the simulator: IsActivated, GetLogLevel and ShowDialog's action type all come back. --- Assets/SdkHarness/AGENTS.md | 2 +- Assets/SdkHarness/AdaptySdkHarness.cs | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Assets/SdkHarness/AGENTS.md b/Assets/SdkHarness/AGENTS.md index f0eeef18..a0a2ce82 100644 --- a/Assets/SdkHarness/AGENTS.md +++ b/Assets/SdkHarness/AGENTS.md @@ -1,6 +1,6 @@ # The SDK harness -`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why `link.xml` beside it keeps the whole SDK assembly, and why every callback shape with a value-type payload (`bool`, `AdaptyLogLevel`) is instantiated once in `AotHints` so IL2CPP compiles it. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. +`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why `link.xml` beside it keeps the whole SDK assembly. A callback with a value-type payload (`bool`, an enum) needs no AOT hint: IL2CPP's full generic sharing runs the `Capture` the harness makes at run time. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. ## Build and run diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index 31ac97e1..f7adca41 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -565,17 +565,6 @@ private static CallResult Fail(string method, string error) return new CallResult { method = method, ok = false, error = error }; } - /// - /// The two callback shapes with a value-type payload, instantiated so IL2CPP compiles them. - /// Reference-type payloads share one instantiation and need nothing. Never called. - /// - [Preserve] - private static void AotHints() - { - new Capture(null).On(false, null); - new Capture(null).On(default, null); - } - [Preserve] public sealed class CallResult { From 6fc48df4b236d56f90149a4486ab738f9f3ecf0b Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 28 Oct 2026 16:27:23 +0100 Subject: [PATCH 4/7] fix: keep the harness's link.xml out of every other build A link.xml under Assets/ goes into every player, so the one beside the harness kept the whole SDK assembly in the demo and in StrippingBuild too. SdkHarnessBuild now hands the linker its own list through IUnityLinkerProcessor, and only while it builds the harness; any other build gets an empty one. The list keeps only what the harness reaches by reflection: Adapty's and AdaptyUI's methods, AdaptyJson, and the request-side types it builds from JSON or by member name. Response models and converters are left to the linker, since their decoding after stripping is what the harness is there to check. A full run on the simulator (activation through the Builder, flows, products, profile, attribution, flow view, dialog, purchase with parameters) decodes everything, and StrippingBuild.IOS on High strips the SDK to 105 KB. --- Assets/SdkHarness/AGENTS.md | 2 +- Assets/SdkHarness/AdaptySdkHarness.cs | 7 ++-- Assets/SdkHarness/Editor/SdkHarnessBuild.cs | 38 ++++++++++++++++++++- Assets/SdkHarness/link.xml | 7 ---- Assets/SdkHarness/link.xml.meta | 7 ---- 5 files changed, 42 insertions(+), 19 deletions(-) delete mode 100644 Assets/SdkHarness/link.xml delete mode 100644 Assets/SdkHarness/link.xml.meta diff --git a/Assets/SdkHarness/AGENTS.md b/Assets/SdkHarness/AGENTS.md index a0a2ce82..1bb08234 100644 --- a/Assets/SdkHarness/AGENTS.md +++ b/Assets/SdkHarness/AGENTS.md @@ -1,6 +1,6 @@ # The SDK harness -`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why `link.xml` beside it keeps the whole SDK assembly. A callback with a value-type payload (`bool`, an enum) needs no AOT hint: IL2CPP's full generic sharing runs the `Capture` the harness makes at run time. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. +`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why the harness build adds a link.xml of its own (`SdkHarnessBuild`, not a file under `Assets/`, which would go into the demo's and `StrippingBuild`'s players too) that keeps only what the harness reaches by reflection — `Adapty`'s and `AdaptyUI`'s methods, `AdaptyJson`, the request-side types it builds from JSON or by member name — and leaves the response models and converters to the linker; a new request-side parameter type goes on that list. A callback with a value-type payload (`bool`, an enum) needs no AOT hint: IL2CPP's full generic sharing runs the `Capture` the harness makes at run time. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. ## Build and run diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index f7adca41..1f59b9f3 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -26,9 +26,10 @@ namespace AdaptyExample.SdkHarness /// and the main loop has to stay free to run it — waiting on the main thread would deadlock every /// call. The wait budget stays below the scene's 120 s request timeout. /// - /// A player discovers commands by reflection and reaches the harness from nothing else, so - /// link.xml beside this file keeps the namespace and the whole SDK assembly, and each - /// handler carries as well. + /// A player discovers commands by reflection and reaches the harness from nothing else, so the + /// harness build's own link.xml (SdkHarnessBuild) keeps the namespace and what the + /// harness reaches in the SDK by reflection, and each handler carries + /// as well. /// public sealed class AdaptySdkHarness : MonoBehaviour, diff --git a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs index 315d0dbf..9887646d 100644 --- a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs +++ b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs @@ -1,7 +1,10 @@ using System.IO; using Unity.Pipeline.Commands; using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; using UnityEditor.Callbacks; +using UnityEditor.UnityLinker; #if UNITY_IOS using UnityEditor.iOS.Xcode; #endif @@ -26,10 +29,31 @@ public static class SdkHarnessBuild public const string Output = "ios-harness-build"; public const string StoreKitConfiguration = "Assets/SdkHarness/AdaptyDemo.storekit"; - // Set for the duration of a harness build, so the post-processor below can tell a harness build + // Set for the duration of a harness build, so the post-processors below can tell a harness build // from the demo's and leave the demo's bundle alone. private static bool s_RigBuild; + // What the harness reaches only by reflection. Response models and converters are left to the + // linker: their decoding after stripping is what the harness checks. A link.xml under Assets/ + // would go into every build and keep the demo and StrippingBuild from being stripped too. + private const string LinkXml = @" + + + + + + + + + + + + + + + +"; + [CliCommand("harness_build", "Build the SDK harness scene for the iOS simulator into ios-harness-build (Development). Submit with --detach, then unity job wait.", MainThreadRequired = true, Tags = new[] { "adapty" })] public static object Build() @@ -65,6 +89,18 @@ public static object Build() }; } + private sealed class HarnessLinkXml : IUnityLinkerProcessor + { + public int callbackOrder => 0; + + public string GenerateAdditionalLinkXmlFile(BuildReport report, UnityLinkerBuildPipelineData data) + { + var path = Path.GetFullPath("Temp/SdkHarness.link.xml"); + File.WriteAllText(path, s_RigBuild ? LinkXml : ""); + return path; + } + } + /// /// Gives the harness build Xcode's local StoreKit: the configuration is filed in the project /// and selected in the scheme, so a run from Xcode syncs it into the simulator and diff --git a/Assets/SdkHarness/link.xml b/Assets/SdkHarness/link.xml deleted file mode 100644 index 4ee5ac15..00000000 --- a/Assets/SdkHarness/link.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Assets/SdkHarness/link.xml.meta b/Assets/SdkHarness/link.xml.meta deleted file mode 100644 index f87f01f9..00000000 --- a/Assets/SdkHarness/link.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d0e7f3d9f3e2b48f6b54f44aa1648407 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From 5703a53a88c48ffb6d344f220680039e3da2cd73 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 28 Oct 2026 16:27:23 +0100 Subject: [PATCH 5/7] fix: report a reply that lands as the harness wait times out once Complete and Run took their decisions apart, so a reply arriving right at the budget could be reported both as the call's result and as a late reply, or as neither. Both now decide under one lock. --- Assets/SdkHarness/AdaptySdkHarness.cs | 28 ++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index 1f59b9f3..8cabaa22 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -590,19 +590,27 @@ private sealed class Call private Exception m_Thrown; private string m_Method; private DateTime m_Started; - private volatile bool m_TimedOut; + private bool m_TimedOut; public void OnVoid(AdaptyError error) => Complete(null, error); public void Complete(object value, AdaptyError error) { - m_Value = value; - m_Error = error; - m_Done.Set(); + bool late; + + // Under the lock with Run's verdict, so a reply that lands as the wait times out is + // reported by exactly one side. + lock (m_Done) + { + m_Value = value; + m_Error = error; + m_Done.Set(); + late = m_TimedOut; + } // A reply after the budget is still a reply: it goes on the ledger and, if it carried // an object, becomes the handle — the command that waited for it has already returned. - if (m_TimedOut) + if (late) { Ledger(error == null ? "←" : "×", $"{m_Method} late {(DateTime.UtcNow - m_Started).TotalSeconds:F2}s " + (error?.ToString() ?? "ok")); @@ -655,9 +663,15 @@ public CallResult Run(Action invoke, int timeoutMs, string method) ); var started = DateTime.UtcNow; - var finished = m_Done.Wait(Math.Max(1000, timeoutMs)); + m_Done.Wait(Math.Max(1000, timeoutMs)); var elapsed = (DateTime.UtcNow - started).TotalSeconds; - m_TimedOut = !finished; + bool finished; + + lock (m_Done) + { + finished = m_Done.IsSet; + m_TimedOut = !finished; + } var outcome = new CallResult { From a053732e7f79e70126e7055725ee76ee5d310070 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:49:59 +0100 Subject: [PATCH 6/7] fix: report a late exception from a harness call, and a late reply only once The exception path set its result outside the lock Run decides under, so a call that threw after the wait had timed out (a flow pausing the player loop on Android) was reported by neither side. Run also read the result after leaving the lock, so a reply landing right after the verdict went out both in the timed-out answer and as a late reply. Both paths now complete through Complete, and Run takes the result with its verdict. --- Assets/SdkHarness/AdaptySdkHarness.cs | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index 8cabaa22..78cfcebb 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -594,7 +594,7 @@ private sealed class Call public void OnVoid(AdaptyError error) => Complete(null, error); - public void Complete(object value, AdaptyError error) + public void Complete(object value, AdaptyError error, Exception thrown = null) { bool late; @@ -604,6 +604,7 @@ public void Complete(object value, AdaptyError error) { m_Value = value; m_Error = error; + m_Thrown = thrown; m_Done.Set(); late = m_TimedOut; } @@ -612,9 +613,10 @@ public void Complete(object value, AdaptyError error) // an object, becomes the handle — the command that waited for it has already returned. if (late) { - Ledger(error == null ? "←" : "×", $"{m_Method} late {(DateTime.UtcNow - m_Started).TotalSeconds:F2}s " + (error?.ToString() ?? "ok")); + var failed = error != null || thrown != null; + Ledger(failed ? "×" : "←", $"{m_Method} late {(DateTime.UtcNow - m_Started).TotalSeconds:F2}s " + (error?.ToString() ?? thrown?.ToString().Split('\n')[0] ?? "ok")); - if (error == null && value != null) + if (!failed && value != null) { lock (s_Gate) { @@ -655,8 +657,7 @@ public CallResult Run(Action invoke, int timeoutMs, string method) } catch (Exception e) { - m_Thrown = e is TargetInvocationException t && t.InnerException != null ? t.InnerException : e; - m_Done.Set(); + Complete(null, null, e is TargetInvocationException t && t.InnerException != null ? t.InnerException : e); } }, null @@ -666,28 +667,35 @@ public CallResult Run(Action invoke, int timeoutMs, string method) m_Done.Wait(Math.Max(1000, timeoutMs)); var elapsed = (DateTime.UtcNow - started).TotalSeconds; bool finished; + object value; + AdaptyError error; + Exception thrown; + // Read with the verdict: a late reply landing right after it belongs to Complete. lock (m_Done) { finished = m_Done.IsSet; m_TimedOut = !finished; + value = m_Value; + error = m_Error; + thrown = m_Thrown; } var outcome = new CallResult { method = method, - ok = finished && m_Thrown == null && m_Error == null, + ok = finished && thrown == null && error == null, timedOut = !finished, - error = m_Error?.ToString(), - exception = m_Thrown?.ToString(), - result = ToJson(m_Value), + error = error?.ToString(), + exception = thrown?.ToString(), + result = ToJson(value), }; - if (outcome.ok && m_Value != null) + if (outcome.ok && value != null) { lock (s_Gate) { - s_Results[method] = m_Value; + s_Results[method] = value; } } From 7a600c234a912ea3789522ef661c781ee61a44f3 Mon Sep 17 00:00:00 2001 From: Yauch Dev <275063651+yauch-dev@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:19:31 +0100 Subject: [PATCH 7/7] fix: pick the harness overload the arguments bind to harness_call took the first overload whose parameter names matched the arguments. ShowDialog has two with the same names - one for a flow view, one for a legacy onboarding view - so an onboarding handle always landed on the flow overload and failed to bind before the SDK was called. Every overload whose names match is now tried in turn and the first that binds is called; when none binds, each one's reason is reported. --- Assets/SdkHarness/AdaptySdkHarness.cs | 28 ++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index 78cfcebb..5d104ded 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -314,9 +314,9 @@ public static object CallSdk( return Fail(method, $"neither Adapty.{method} nor AdaptyUI.{method} exists"); } - var chosen = candidates.FirstOrDefault(m => Matches(m, provided)); + var matching = candidates.Where(m => Matches(m, provided)).ToList(); - if (chosen == null) + if (matching.Count == 0) { return Fail( method, @@ -325,16 +325,30 @@ public static object CallSdk( ); } + // Overloads can share parameter names and differ only in type - ShowDialog takes a flow + // view or an onboarding view - so the one meant is the first the arguments bind to. var call = new Call(); - object[] bound; + MethodInfo chosen = null; + object[] bound = null; + var failures = new List(); - try + foreach (var candidate in matching) { - bound = Bind(chosen, provided, call); + try + { + bound = Bind(candidate, provided, call); + chosen = candidate; + break; + } + catch (Exception e) + { + failures.Add(e.Message); + } } - catch (Exception e) + + if (chosen == null) { - return Fail(method, "binding: " + e.Message); + return Fail(method, "binding: " + string.Join("; ", failures)); } Ledger("→", $"{method} {provided.ToString(Formatting.None)}");