Skip to content

iOS: get SuperwallKit from Swift Package Manager instead of CocoaPods - #25

Merged
ianrumac merged 3 commits into
mainfrom
ir/cool-hypatia-v8riz2
Nov 10, 2026
Merged

ianrumac merged 3 commits into
mainfrom
ir/cool-hypatia-v8riz2

Conversation

@ianrumac

@ianrumac ianrumac commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

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.cs
    • Adds https://github.com/superwall/Superwall-iOS as a Swift package. It requires 4.19.1 up to the next major version, the same range the Podfile used. It uses PBXProject.AddRemotePackageReferenceAtVersionUpToNextMajor and links SuperwallKit to UnityFramework with AddRemotePackageFrameworkToProject.
    • Removes the Podfile generation, the pod install step and the search for the pod executable.
    • Append builds:
      • If the project already references the package, the processor doesn't add it again. If its minimum version is older than 4.19.1, the processor raises it in project.pbxproj; a higher version set by hand is kept.
      • If a kept Podfile still has a SuperwallKit pod line, the processor removes it and logs a warning to run pod install or pod deintegrate. Otherwise SuperwallKit would be linked twice.
    • Behaviour change: the old Podfile built the pods for iOS 15 when Target minimum iOS Version was lower. A Swift package can't be raised that way, so the build now only logs a warning, and Xcode fails to link SuperwallKit until the target is 15.0 or later.
  • Tests: PodfileRequirementTests is now SwiftPackageRequirementTests (same .meta GUID). 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 bumps SuperwallKitMinimumVersion instead of the pod line.
  • README and CHANGELOG: the README's iOS section no longer mentions CocoaPods. The CHANGELOG has a new [Unreleased] section with Breaking Changes and Migration notes. package.json is unchanged.

Testing

  • The 11 editor tests pass under NUnit on .NET 8, with stand-in Unity types.
  • The UNITY_IOS branch compiles against stand-ins for the PBXProject calls it uses. That only checks the code compiles; it doesn't check what Unity writes.
  • Not run: a real Unity iOS export and an Xcode build. Before merging, check:
    1. That the Swift package section Unity writes to project.pbxproj matches what the Append-build version update expects.
    2. That SuperwallKit's resource bundle loads now that SuperwallKit is linked statically into UnityFramework. The Podfile used use_frameworks!, which linked it dynamically.

Generated by Claude Code

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
@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

// 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@ianrumac

Copy link
Copy Markdown
Collaborator Author

Tested with a real Unity 6000.4 iOS export, Xcode 26.6 and the iOS 26.5 simulator (test game, in-window paywall on empty_magazine).

Bug found and fixed (df28b04): as first pushed, every build crashed in Superwall.Configure with Fatal error: unable to find bundle named SuperwallKit_SuperwallKit. Xcode builds the package's resource bundle but doesn't copy it into UnityFramework. The processor now adds it to UnityFramework's resources.

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 Class … is implemented in both warnings. The processor now runs pod install after removing the pod, and logs the manual command only if that fails.

Scenario Result
Replace build Builds, configures, presents the paywall
Append over an export with the package minimum set to 4.12.10 Raised to 4.19.1, no duplicates, runs
Append over a 0.5.0 CocoaPods export (SuperwallKit 4.18.3 pod) Pod removed, pod install run automatically, workspace builds with one SuperwallKit, runs

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 >= 4.19.1 from CocoaPods, fail pod install for every iOS user. This PR fixes that. The CHANGELOG notes it, and the version is now 0.6.0.

@maple-review-bot

maple-review-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Maple review

🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open.
1 warning −1 · tests partial −1 · risk medium

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.

  • PostProcessIOS links the SuperwallKit Swift package and copies its resource bundle.
  • RemovePodFromAppendedBuild reinstalls pods after removing SuperwallKit.
  • RaiseSuperwallKitPackageRequirement raises older minimum versions while retaining newer ones.

Still open from earlier reviews

593ee0f · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@ianrumac
ianrumac merged commit f29556b into main Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants