AltStore icon indicating copy to clipboard operation
AltStore copied to clipboard

Resource bundles inside PlugIns are treated as app extensions (AltSign.Error 4: Could not find matching provisioning profile)

Open liuzhe1117 opened this issue 1 month ago • 2 comments

Summary

ResignAppOperation.prepareAppBundle treats every direct child of PlugIns as an app extension and requires a provisioning profile for it. Many shipping apps keep resource .bundle packages in PlugIns. Those bundles are not extensions. codesign signs them as part of the parent app, and they do not need their own profile.

AltStore throws ALTError.missingProvisioningProfile during prepare(), before ALTSigner.signApp. Resign never starts.

Observed error

The alert shown by AltStore is:

AltSign.Error 4
Could not find matching provisioning profile.

AltSign.Error 4 is ALTError.missingProvisioningProfile, thrown here:

guard let identifier = bundle.bundleIdentifier else { throw ALTError(.missingAppBundle) }
guard let profile = profiles[identifier] else { throw ALTError(.missingProvisioningProfile) }

The on-device notification looks like this:

Install VK Failed: AltSign.Error 4 — Could not find matching provisioning profile.

This is not a later codesign failure such as 0xe8008015 ("A valid provisioning profile for this executable was not found"). The profile lookup fails inside prepare(), so ALTSigner.signApp is never called.

If CFBundleIdentifier is removed from the resource bundle, the first guard fails instead and the alert becomes ALTError.missingAppBundle ("Could not find app bundle.").

Where it fails

On branch marketplace, ResignAppOperation.swift walks appBundle.builtInPlugInsURL with .skipsSubdirectoryDescendants and calls prepare() on every child that Bundle(url:) can open.

The only child that is skipped is an embedded .xctest bundle, and only in DEBUG. There is no .appex filter.

profiles is keyed by the original bundle identifiers of the app and its real extensions. A resource bundle's CFBundleIdentifier is never in that dictionary, so the second guard always fails with AltSign.Error 4.

Why this is not a codesign requirement

A resource bundle loaded with pathForResource:ofType:inDirectory: is data, not a separate process. Xcode signs it as part of the parent. Only a real .appex (its own executable, its own App ID) needs a provisioning profile.

Two nearby workarounds both fail:

  • Stripping CFBundleIdentifier from the bundle's Info.plist makes bundle.bundleIdentifier nil, so the first guard throws ALTError.missingAppBundle instead of AltSign.Error 4.
  • Deleting the bundles lets resign succeed, but the app crashes at launch if a framework fatalErrors when its resource bundle is missing.

Example: VK App 8.183

Installing this IPA with AltStore reproduces AltSign.Error 4, Could not find matching provisioning profile. Installing the same build with Xcode succeeds, because Xcode does not require a separate profile for resource bundles.

The official VK client IPA has two different kinds of children directly under VK.app/PlugIns:

  • 7 real extensions (.appex): Notification Service, Photo Feed Today, Share, Siri Intents, Start Call Intent, WidgetKit, and VK Broadcast. These are separate processes and do need profiles.
  • 146 resource bundles (.bundle), including ClipViewerKitResources.bundle. These are resource packages. Several frameworks resolve them with pathForResource:ofType:inDirectory: and abort if the bundle file is gone. ClipViewerKit is one of them.

Each of those .bundle directories has an Info.plist with a CFBundleIdentifier, so Bundle(url:) succeeds and prepare() demands a profile. A free or personal team cannot create 146 extra App IDs for resource packages, and those identifiers are not extension App IDs in the first place.

After the 146 .bundle directories were moved out of PlugIns (the bundles themselves were kept, and the in-binary directory name used to find them was updated to the new location), the same IPA resigned and installed. AltSign.Error 4 no longer appeared. That confirms the failure is the PlugIns walk, not the main app's profile, the certificate, or the extension profiles.

Suggested change

Only call prepare() for real app extensions. For example, skip any PlugIns child whose path extension is not appex (the existing .xctest removal can stay). Resource .bundle packages, and any other non-extension child, should be left for the parent signature.

Empty or missing PlugIns already works. The change is to ignore children that are not extensions, instead of requiring a profile for every child Bundle(url:) can open.

Workaround we verified

On the IPA side, move resource .bundle directories out of PlugIns into another directory, and update the path the binary uses to load them. Do not delete the bundles, and do not only delete CFBundleIdentifier. Once PlugIns no longer contains those bundles, AltStore resigns the IPA and AltSign.Error 4 is gone.

liuzhe1117 avatar Oct 13 '26 04:10 liuzhe1117

i checked the classic branch’s pinned AltSign revision (e639bdfbea185d5c229b11f62e25c5d78649d5c4). ALTApplication.appExtensions already filters PlugIns to .appex before constructing an ALTApplication; resource .bundle directories should be skipped by that code path.

so the proposed change is already present in the source AltStore Classic currently points to. if a build is still attempting to provision the 146 bundles, it is likely using an older or forked AltSign revision. please add the exact AltStore/AltServer version and the complete AltSign.Error 4 log so this can be tied to a release rather than changing the IPA layout. moving or deleting those bundles should not be necessary.

kisnner26 avatar Oct 29 '26 03:10 kisnner26

Thanks for checking. You are correct that ALTApplication.appExtensions filters PlugIns to .appex. However, that is a different traversal from the one that fails here.

The affected code is still present in the latest classic source I checked, so this is not limited to the older marketplace branch or explained by an outdated AltSign dependency. Updating AltStore/AltServer does not resolve this particular mismatch unless the client-side preparation loop is also filtered.

For precise, independently checkable references:

To be clear about verification scope: I have rechecked the current source and reproduced the enumeration/profile-lookup mismatch locally with the VK bundle metadata. I am not claiming a new on-device installation test against every latest AltStore/AltServer binary, and I do not have a fresh complete device log to attach.

Two different traversals

  1. FetchProvisioningProfilesOperation.swift, lines 53–75 uses app.appExtensions. This correctly skips resource .bundle directories, so no profiles are requested for them.
  2. ResignAppOperation.swift, prepareAppBundle(for:profiles:completionHandler:), lines 232–245 independently enumerates every direct child of appBundle.builtInPlugInsURL. It does not use app.appExtensions or check for .appex before calling prepare(appExtension).
  3. The nested prepare() function, lines 112–116, then requires profiles[bundle.bundleIdentifier]. A resource bundle has an identifier, but no corresponding profile was fetched in step 1, so it throws ALTError(.missingProvisioningProfile) (AltSign.Error 4).

The failure occurs before ALTSigner.signApp is invoked. Changing AltSign's extension discovery or updating AltServer alone cannot fix this separate AltStore preparation loop.

Simplified VK IPA layout

The retained VK 8.183 (8149) IPA used for this investigation has this structure (resources abbreviated):

VK.ipa
└── Payload/
    └── VKClient.app/
        ├── Info.plist
        ├── VKClient
        ├── Frameworks/
        │   └── ...
        └── PlugIns/
            ├── ClipViewerKitResources.bundle/
            │   ├── Info.plist
            │   └── ... resource files ...
            ├── MessengerResources.bundle/
            │   ├── Info.plist
            │   └── ... resource files ...
            └── ... 144 other resource .bundle directories ...

For example, ClipViewerKitResources.bundle/Info.plist contains:

CFBundleIdentifier  = com.vk.ClipViewerKitResources
CFBundlePackageType = BNDL
CFBundleExecutable  = absent

Bundle(url:) can open this resource package and read its identifier. Consequently, the unfiltered preparation loop reaches the profile lookup even though this is not an app extension.

One clarification to the original report: the retained repackaged IPA currently available locally has 146 resource bundles and no .appex children. The original report's separate count of seven real extensions should not be read as the contents of this retained test artifact. The resource-bundle failure does not require any real extensions to be present.

Using Foundation with those 146 actual Info.plist files, the .appex-filtered traversal produces zero extension candidates, while the unfiltered preparation traversal encounters 146 identifiers with no extension-profile entry. This checks the control-flow mismatch without requesting Apple provisioning profiles.

Suggested filtering location

In AltStore/Operations/ResignAppOperation.swift, inside the for case let fileURL as URL in enumerator loop in prepareAppBundle, add the extension filter after the existing #if DEBUG / .xctest cleanup and before Bundle(url: fileURL):

// Keep the existing DEBUG .xctest cleanup above this point.
guard fileURL.pathExtension.lowercased() == "appex" else {
    continue
}

guard let appExtension = Bundle(url: fileURL) else {
    throw ALTError(.missingAppBundle)
}
try prepare(appExtension)

This makes the preparation traversal consistent with ALTApplication.appExtensions: real .appex packages still receive profile-based preparation, while resource .bundle packages remain untouched by this step.

I agree that moving or deleting the resource bundles should not be necessary. Moving them out of PlugIns and updating their resource lookup paths was a verified IPA-side workaround for this unfiltered traversal, not the preferred upstream fix.

liuzhe1117 avatar Oct 30 '26 01:10 liuzhe1117