iOS应用归档报错:AFNetworking.framework文件不存在求助
Hey there, fellow iOS newbie! I’ve stumbled through this exact error when I was starting out, so let’s break down how to fix it step by step. That missing framework error usually boils down to cached build files, wonky Pod configurations, or a simple oversight that’s easy to miss as a new dev.
Step 1: Wipe Out Cached Build Data (The Nuclear Cleanup)
First, let’s get rid of all the old, possibly corrupted build files that might be causing the issue:
- Close Xcode completely (don’t just minimize it).
- Navigate to the DerivedData folder mentioned in your error:
/Users/eenovinfogerance/Library/Developer/Xcode/DerivedData/Mercato-ascjcoguyyeglqcxxlubcypqxcdmand delete the entire folder. - Back in your project directory, delete the
Podsfolder andPodfile.lockfile. - Open Terminal, cd to your project folder, and run
pod installagain. Wait for it to finish—make sure you see "Pod installation complete!" without errors.
Step 2: Double-Check You’re Using the Right Project File
This is a super common mistake for new iOS devs: always open your project using the .xcworkspace file (Mercato.xcworkspace) after using CocoaPods. If you open the old .xcodeproj file, Xcode won’t recognize the Pod frameworks like AFNetworking.
Step 3: Verify Podfile & Build Settings
Let’s make sure your Pod setup is configured correctly:
- Open your Podfile and confirm it looks something like this (adjust the iOS version to match your project’s minimum requirement):
platform :ios, '14.0' # Use your project's actual minimum iOS version use_frameworks! target 'Mercato' do pod 'AFNetworking' end - If you made changes to the Podfile, run
pod updatethenpod installagain. - Open your workspace, go to your project’s Build Settings, search for Framework Search Paths. Make sure it includes
$(inherited)(this pulls in Pods’ framework paths automatically) and that the path isn’t red (red means the path is invalid).
Step 4: Test a Regular Build First
Before trying to archive again, do a normal build to make sure everything works:
- Select "Generic iOS Device" (or a physical device connected to your Mac) as the build target.
- Press
Cmd + Bto build the project. If this fails, fix those errors first—archiving will only work if a regular build succeeds.
Step 5: Try Archiving Again
If the regular build works, go to Product > Archive in Xcode. Make sure you’ve selected the correct Scheme (your Mercato app target) before starting the archive.
If none of these steps work, one last thing to check is your Build Phases: go to Target > Build Phases > Link Binary With Libraries and confirm AFNetworking.framework is listed. If it’s red, remove it and run pod install again to let CocoaPods re-add it.
You’ve got this—archiving issues are super common when starting out, but they’re almost always fixable with a little cleanup and configuration checks!
内容的提问来源于stack exchange,提问作者Jerome Lebont

