Repository navigation
iOS: get SuperwallKit from Swift Package Manager instead of CocoaPods - #25
Conversation
CocoaPods is deprecated. The iOS post-build processor now adds the Superwall-iOS Swift package (from 4.19.1 up to the next major) to the exported Xcode project with PBXProject's remote package API and links SuperwallKit to UnityFramework. It no longer writes a Podfile or runs pod install. Append builds: an existing package reference is kept and its minimum version raised if older; a SuperwallKit pod left in a kept Podfile is removed, with a warning to update the Pods integration, so the SDK is not linked twice. native-sdk-bump.yml now bumps SuperwallKitMinimumVersion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CR7gApUHfsuLG99CJqDRoR
This comment has been minimized.
This comment has been minimized.
| // A SuperwallKit pod line, whatever its requirement. Versions before 0.6.0 got SuperwallKit | ||
| // from CocoaPods; linking it from the pod and the Swift package would duplicate every class. | ||
| private static readonly Regex SuperwallKitPodLine = | ||
| new Regex(@"^[ \t]*pod[ \t]+['""]SuperwallKit['""][^\n]*\n?", RegexOptions.Multiline); |
There was a problem hiding this comment.
Warning
RemoveSuperwallKitPod truncates multiline pod declarations
F1 · Warning · correctness
An existing Podfile can declare pod 'SuperwallKit', with its version constraints on the following line. This regex deletes only the first line, leaving the comma-separated constraints orphaned. RemovePodFromAppendedBuild writes that broken Podfile back, so the instructed pod install cannot complete the migration.
Remove the complete declaration, including continuation lines, or detect multiline declarations and leave them intact with an explicit manual-migration warning.
🤖 Prompt to fix with an AI agent
In `Editor/SuperwallPostBuildProcessor.cs:32`: `RemoveSuperwallKitPod` truncates multiline pod declarations.
An existing Podfile can declare `pod 'SuperwallKit',` with its version constraints on the following line. This regex deletes only the first line, leaving the comma-separated constraints orphaned. `RemovePodFromAppendedBuild` writes that broken Podfile back, so the instructed `pod install` cannot complete the migration.
Suggested fix: Remove the complete declaration, including continuation lines, or detect multiline declarations and leave them intact with an explicit manual-migration warning.
Verify the problem exists at that location before changing it, and keep the fix to those lines.
Xcode builds SuperwallKit_SuperwallKit.bundle but doesn't copy it into UnityFramework, so Superwall.Configure stopped with "unable to find bundle named SuperwallKit_SuperwallKit". Add it to UnityFramework's resources, where Bundle.module looks for a package linked into a framework. An Append build over a CocoaPods export now runs pod install after removing the SuperwallKit pod. Without it the workspace built the old pod next to the Swift package with no error, and the app had two copies of every class.
|
Tested with a real Unity 6000.4 iOS export, Xcode 26.6 and the iOS 26.5 simulator (test game, in-window paywall on Bug found and fixed (df28b04): as first pushed, every build crashed in Second fix (df28b04): an Append build over an old CocoaPods export removed the pod line but left the Pods integration. Xcode then built the 4.18.3 pod next to the 4.19.1 package with no error, and the app logged 182
Not tested: a physical device, and a purchase (the simulator has no StoreKit configuration). Also found: SuperwallKit 4.19.0 and 4.19.1 aren't on CocoaPods trunk (the 4.19.0 publish failed on a missing Superscript 1.0.17 pod; 4.19.1 skipped the step). So 0.4.1 and 0.5.0, which require |
Maple review🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open. Replaces CocoaPods with Swift Package Manager, copies SuperwallKit’s resource bundle, and migrates appended exports. The existing multiline Podfile corruption defect (F1) remains at this head and blocks safe migration for affected projects.
Still open from earlier reviews
|
CocoaPods is deprecated, so the iOS post-build step now adds SuperwallKit to the exported Xcode project as a Swift package. It no longer writes a Podfile or runs
pod install.Changes
Editor/SuperwallPostBuildProcessor.cshttps://github.com/superwall/Superwall-iOSas a Swift package. It requires 4.19.1 up to the next major version, the same range the Podfile used. It usesPBXProject.AddRemotePackageReferenceAtVersionUpToNextMajorand linksSuperwallKittoUnityFrameworkwithAddRemotePackageFrameworkToProject.pod installstep and the search for thepodexecutable.project.pbxproj; a higher version set by hand is kept.pod installorpod deintegrate. Otherwise SuperwallKit would be linked twice.PodfileRequirementTestsis nowSwiftPackageRequirementTests(same.metaGUID). The version test checks that the minimum is at least 4.19.1 and below 5.0, so automated bumps don't break it.native-sdk-bump.yml: reads and bumpsSuperwallKitMinimumVersioninstead of the pod line.[Unreleased]section with Breaking Changes and Migration notes.package.jsonis unchanged.Testing
UNITY_IOSbranch compiles against stand-ins for thePBXProjectcalls it uses. That only checks the code compiles; it doesn't check what Unity writes.project.pbxprojmatches what the Append-build version update expects.UnityFramework. The Podfile useduse_frameworks!, which linked it dynamically.Generated by Claude Code