Skip to content

Fix IPA generated by ipatool not installable via itms-services#469

Merged
majd merged 2 commits intomainfrom
fix/itms-services-install
Apr 16, 2026
Merged

Fix IPA generated by ipatool not installable via itms-services#469
majd merged 2 commits intomainfrom
fix/itms-services-install

Conversation

@majd
Copy link
Copy Markdown
Owner

@majd majd commented Apr 16, 2026

  • fix: generate ipa compatible with itms-services installation
  • Close zip entry readers during replication

Summary by cubic

Fixes IPA generation so it installs via itms-services. Switches to standard zip APIs and ensures each entry is closed to produce a valid archive.

  • Bug Fixes
    • Use archive/zip Open + CreateHeader instead of raw methods to write correct CRC/compression metadata.
    • Scope per-file replication and defer Close() to prevent leaks and incomplete copies.

Written for commit 07a426f. Summary will update on new commits.

@majd majd changed the title fix/itms services install Fix IPA generated by ipatool not installable via itms-services Apr 16, 2026
@majd majd force-pushed the fix/itms-services-install branch from 6905387 to 07a426f Compare April 16, 2026 18:34
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Modifies core logic for IPA generation and zip replication. Functional changes to the tool's primary output should be reviewed by a human.

Architecture diagram
sequenceDiagram
    participant Replicator as AppStore Replicator
    participant Src as Source ZIP (archive/zip)
    participant Dst as Target ZIP (archive/zip)

    Note over Replicator,Dst: IPA Replication Flow (replicateZip)

    loop For each File in Source
        Replicator->>Replicator: NEW: Open function scope (closure)
        
        Replicator->>Src: CHANGED: Open()
        Note right of Src: Returns decompressed reader
        
        Src-->>Replicator: srcFile handle

        Replicator->>Dst: CHANGED: CreateHeader(header)
        Note right of Dst: Initializes entry with standard metadata/CRC
        
        Dst-->>Replicator: dstFile writer

        Replicator->>Dst: io.Copy(dstFile, srcFile)
        Src-->>Dst: Stream file data

        Replicator->>Src: NEW: Close() via defer
        Note over Replicator,Src: Prevents resource leaks and ensures entry finalization
        
        Replicator->>Replicator: Exit function scope
    end

    Note over Replicator,Dst: Result: Valid IPA compatible with itms-services installation (standard CRC/Compression)
Loading

@majd majd enabled auto-merge (squash) April 16, 2026 18:39
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: This modifies the core IPA generation logic by changing how zip entries are processed and copied. It's a functional bug fix in a critical path that warrants human review.

Architecture diagram
sequenceDiagram
    participant AS as AppStore Service
    participant SZ as Source IPA (zip.ReadCloser)
    participant DZ as Destination IPA (zip.Writer)
    participant ITMS as Apple itms-services

    Note over AS, DZ: IPA Replication Flow (replicateZip)

    loop For every file entry
        AS->>SZ: CHANGED: file.Open()
        SZ-->>AS: Decompressed stream (srcFile)
        
        AS->>DZ: CHANGED: zip.CreateHeader(&header)
        DZ-->>AS: Compressed stream writer (dstFile)
        
        AS->>AS: io.Copy(dstFile, srcFile)
        Note right of AS: Re-calculates CRC32 and compression metadata
        
        AS->>AS: NEW: srcFile.Close() (via scoped defer)
        Note right of AS: Prevents file descriptor leaks
    end

    AS->>DZ: zip.Close()
    Note over DZ: Result: Standard-compliant ZIP/IPA

    Note over DZ, ITMS: Client-side Installation
    ITMS->>DZ: Fetch and verify IPA
    alt Valid ZIP Headers
        DZ-->>ITMS: Success (Installation starts)
    else Invalid CRC/Header (Previous Behavior)
        DZ-->>ITMS: Failure (Installation failed)
    end
Loading

@majd majd merged commit 8c4e037 into main Apr 16, 2026
14 checks passed
@majd majd deleted the fix/itms-services-install branch April 16, 2026 18:42
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