Why this happens
When you submit an app that includes an app extension (such as an action extension) and a dynamic framework shared between the app and extension, Xcode’s validation process checks the bundle structure. The error “Invalid Bundle. The bundle at … contains disallowed file ‘Frameworks’” appears because the app extension target is embedding a Frameworks directory containing Swift standard libraries.
App extensions must not embed their own copy of the Swift standard libraries. The main app already includes them, and the extension should link against the app’s copy at runtime. When the extension target has “Always Embed Swift Standard Libraries” enabled (or the older “Embedded Content Contains Swift Code” setting), Xcode copies the Swift runtime into a Frameworks folder inside the extension bundle. The App Store validation rejects this because extensions are not allowed to contain a Frameworks directory.
This commonly happens in projects that use Swift in both the main app and the extension, especially when sharing a dynamic framework. The build system mistakenly treats the extension as a standalone bundle that needs its own Swift runtime.
How to fix it
1. Configure Always Embed Swift Standard Libraries per target (recommended)
The most reliable fix is to adjust the Always Embed Swift Standard Libraries build setting (called Embedded Content Contains Swift Code in Xcode 7 and earlier) for each target:
- Open your project in Xcode and select the project file in the navigator.
- Choose the main app target, go to the Build Settings tab, and search for “Always Embed Swift Standard Libraries”.
- Set it to YES for the main app target.
- Choose the app extension target, find the same setting, and set it to NO.
- If you have a shared dynamic framework target, set it to NO as well (the framework does not embed the runtime; the app does).
- Clean the build folder (Product → Clean Build Folder) and re-archive.
This tells Xcode to embed the Swift standard libraries only in the main app bundle. The extension will link against the app’s copy at launch, eliminating the disallowed Frameworks folder inside the extension.
2. Remove the Frameworks folder with a run script (workaround)
If the setting above does not resolve the issue (for example, when CocoaPods or a third-party build process forces the folder into the extension), add a run script phase to the extension target that deletes the folder after copying:
- Select the app extension target → Build Phases → + → New Run Script Phase.
- Place the script after the “Embed Frameworks” phase.
- Paste the following script:
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi
- Ensure the script runs only for the extension target (not the app target).
- Archive and validate again.
This script runs at the end of the build and removes any Frameworks directory that Xcode may have created inside the extension’s resource folder. It is a safe workaround used by many projects, including CocoaPods (see CocoaPods issue #4203).
3. Verify the generated bundle structure
Before uploading, inspect the archive to confirm the fix:
- In the Organizer window, right-click the archive → Show in Finder.
- Right-click the
.xcarchive→ Show Package Contents. - Navigate to
Products/Applications/YourApp.app/PlugIns/YourExtension.appex/. - Confirm there is no
Frameworksfolder inside the.appexbundle. - The main
YourApp.app/Frameworksfolder should exist and containlibswift*.dylibfiles.
If the extension bundle is clean, validation will pass.
How to prevent it
- Always set Always Embed Swift Standard Libraries = YES for the main app target and NO for every app extension and shared framework target.
- Add the build setting to your project’s
.xcconfigfiles or use a shared configuration to enforce it across schemes. - When adding a new extension target, immediately check this setting before the first archive.
- If you use CocoaPods, ensure the
Podfiledoes not setuse_frameworks!in a way that forces embedding into extension targets; prefer linking the shared framework only to the app and extension without embedding. - Run a local validation (Product → Archive → Validate App) before every TestFlight or App Store upload.
FAQ
Why does the error mention a ‘Frameworks’ file when I don’t have one in my project?
The Frameworks folder is created automatically by Xcode at build time when Always Embed Swift Standard Libraries is enabled for a target. It contains the Swift standard library dylibs (libswiftCore.dylib, libswiftSwiftOnoneSupport.dylib, etc.). You won’t see it in the project navigator because it’s a build artifact, not a source file.
Can I just delete the Frameworks folder manually from the archive?
Manual deletion is not recommended because the archive is signed. Modifying it invalidates the code signature, causing a different validation error. Use the run script phase (Fix #2) so the folder is never created in the signed bundle, or fix the build setting (Fix #1) so Xcode doesn’t create it at all.
Does this affect apps that don’t use Swift?
No. The error only occurs when Swift code is present in the app or extension. Pure Objective-C projects do not embed Swift standard libraries, so the Frameworks folder is never generated and the validation passes.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
