Xcode 9.2下CocoaPods已安装但无法正常工作的问题求助
Hey there, let's work through this frustrating CocoaPods issue you're hitting in Xcode 9.2. I've run into similar odd behavior before, so let's go through targeted fixes that should resolve the framework path confusion and get your pods working properly.
Step 1: Wipe Clean Existing CocoaPods Residues
Sometimes leftover files or cached data are the root cause. Let's start fresh:
- Delete these items from your project directory:
Podfile.lock, thePodsfolder, and your.xcworkspacefile. - Run the deintegrate command to fully remove CocoaPods traces:
(If you don't have this command installed, runpod deintegrategem install cocoapods-deintegratefirst.) - Clear Xcode's derived data to eliminate cached build artifacts:
rm -rf ~/Library/Developer/Xcode/DerivedData - Restart Xcode—don't skip this! Xcode holds onto cached settings stubbornly, and a restart can clear weird glitches.
Step 2: Verify Podfile & Deployment Target Alignment
Mismatched deployment targets often cause framework path issues:
- Open your
Podfileand ensure theplatformline matches your main project's Deployment Target. For Xcode 9.2, this is typically something like:platform :ios, '11.0' - Double-check that your main project's Deployment Target (in Project > Build Settings > Deployment Target) matches the one in your Podfile.
Step 3: Fix Framework Search Paths
Instead of just setting recursive mode, let's ensure the paths are correctly inherited:
- Open your main project's Build Settings, find Framework Search Paths.
- Delete any custom absolute paths you've added.
- Add
$(inherited)as the top entry—this tells Xcode to use the paths automatically injected by CocoaPods, avoiding manual conflicts. - Make sure the path is set to recursive (you mentioned you did this, but confirming it's paired with
$(inherited)is key).
Step 4: Check Pods Project Configuration
Occasionally, individual pod targets have misconfigured settings:
- Open your
.xcworkspacefile (not the.xcodeproj—this is critical!) - Select the
Podsproject in the navigator, then check each pod's Build Settings:- Ensure their Deployment Target matches your main project's target.
- Verify their Framework Search Paths also include
$(inherited).
Step 5: Reinstall Pods with a Compatible Version
Xcode 9.2 works best with specific CocoaPods versions (newer versions may introduce compatibility issues):
- First, update your local pod repo to pull the latest compatible pod versions:
pod repo update - If your current CocoaPods version is too new or old, install a version known to work with Xcode 9.2:
gem install cocoapods -v 1.5.3 - Finally, run
pod installand open the.xcworkspacefile again.
If you still see duplicate files in the framework directory after these steps, try checking for duplicate pod entries in your Podfile—sometimes accidental duplicates can cause this kind of clutter.
内容的提问来源于stack exchange,提问作者OhStack

