Skip to content

iOS: add CodePushBinaryDiffPatcher to apply bsdiff patches - #59

Draft
ofalvai wants to merge 2 commits into
ios-diff-manifest-parsingfrom
ios-binary-diff-patcher
Draft

iOS: add CodePushBinaryDiffPatcher to apply bsdiff patches#59
ofalvai wants to merge 2 commits into
ios-diff-manifest-parsingfrom
ios-binary-diff-patcher

Conversation

@ofalvai

@ofalvai ofalvai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Stack created with GitHub Stacks CLIGive Feedback 💬

@ofalvai
ofalvai added this pull request to stack #57 September 9, 2026 06:46
@ofalvai ofalvai changed the title ios binary diff patcher iOS: add CodePushBinaryDiffPatcher to apply bsdiff patches Sep 9, 2026
@ofalvai
ofalvai force-pushed the ios-binary-diff-patcher branch from 7912ae8 to ca765df Compare September 9, 2026 15:37
Copilot AI balanced review requested due to automatic review settings September 9, 2026 15:37

Copilot AI 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.

🟡 Changes recommended

The new patcher currently emits misleading hash-mismatch errors when hashing fails (e.g., unreadable/missing files), obscuring the real I/O failure cause.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an iOS-native binary diff patcher to apply bsdiff patches described by CodePushDiffManifest, aligning iOS with the existing Android diff/patch flow and hardening path handling via resolvePath(_:withinFolder:).

Changes:

  • Introduces CodePushBinaryDiffPatcher (Obj-C) to validate hashes, resolve manifest-supplied paths safely, and apply bsdiff patches via bspatch_bridge.
  • Adds Swift XCTest coverage for happy-path patching, hash mismatches, unsupported algorithms, path traversal, and symlink-escape attempts.
  • Wires the new source + tests into the Xcode project and test bridging header.
File summaries
File Description
ios/CodePushTests/CodePushTests-Bridging-Header.h Exposes the new Obj-C patcher to Swift tests.
ios/CodePushTests/CodePushBinaryDiffPatcherTests.swift Adds test coverage for binary patch application and path/symlink safety.
ios/CodePush/CodePushBinaryDiffPatcher.m Implements patch application, path resolution, and hash verification.
ios/CodePush/CodePushBinaryDiffPatcher.h Declares the patcher API and Swift import name.
ios/CodePush.xcodeproj/project.pbxproj Registers new sources/headers and the new test file in build phases.
Review details

Suppressed comments (1)

ios/CodePush/CodePushBinaryDiffPatcher.m:98

  • If hashing the newly patched file fails, newFileHash can be nil and the code reports a confusing "targetHash mismatch ... got (null)" instead of the actual hashing/read error. Handling the nil case separately provides a clearer failure reason.
        NSString *newFileHash = CodePushSha256HexForFile(newFile, &hashError);
        if (!newFileHash || ![newFileHash isEqualToString:entry.targetHash]) {
            if (error) *error = patchApplyError(relativePath, [NSString stringWithFormat:@"targetHash mismatch: expected %@, got %@", entry.targetHash, newFileHash]);
            return NO;
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +64 to +69
NSError *hashError = nil;
NSString *oldFileHash = CodePushSha256HexForFile(oldFile, &hashError);
if (!oldFileHash || ![oldFileHash isEqualToString:entry.baseHash]) {
if (error) *error = patchApplyError(relativePath, [NSString stringWithFormat:@"baseHash mismatch: expected %@, got %@", entry.baseHash, oldFileHash]);
return NO;
}
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