Xcode Preview Crashes: "xcpreviewagent crashed because Alamofire.framework is missing"

Question: I have created a workspace containing a SwiftUI app and two frameworks:

B Framework: Handles UI components C Framework: Handles service classes I added a Podfile to manage dependencies. My Podfile is structured as follows:

inhibit_all_warnings!

workspace 'ABC.xcworkspace'

def shared_pods
  # Shared pods here
  pod 'Alamofire'
end

target 'A' do
  use_frameworks!
  project 'A/A.xcodeproj'
  shared_pods
end

target 'B' do
  use_frameworks!
  project 'B/B.xcodeproj'
  shared_pods
end

target 'C' do
  use_frameworks!
  project 'C/C.xcodeproj'
  shared_pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
end

After installing pods and building the project, everything works fine except for Xcode’s SwiftUI Preview, which crashes with the following error:

xcpreviewagent crashed because Alamofire.framework is missing

Question: How can I resolve this issue and make SwiftUI Previews work without Xcode crashing?

Hi,

Sorry to hear you are having problems getting previews working in your project. We believe you may be hitting a known issue, but for us to identify for sure we'll need you to file a feedback with diagnostics so we can verify.

Install the logging profile using instructions available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift On your mac running Xcode, and on your physical preview device (if you are using one).

Install the logging profile using the following instructions on your mac running Xcode; and if you are using one, your physical preview device (iOS or visionOS): https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift

Then when you reproduce the problem in Xcode:

  1. Either (a) an error banner will appear, click the "Diagnostics" button in that banner; or (b) if you're not seeing an error but you still want to provide diagnostics you can get the same diagnostics window by going under the Editor menu in the menu bar, then selecting the Canvas submenu, then selecting "Diagnostics".
  2. In the sheet that appears, click "Generate Report" in the bottom left of the sheet
  3. Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)
  4. Generate a sysdiagnose on your mac and any on-device preview devices, and attach those too
Xcode Preview Crashes: "xcpreviewagent crashed because Alamofire.framework is missing"
 
 
Q