Swift 4.0中JJFloatingActionButton库加载失败/镜像未找到求助
Hey there! I’ve helped a bunch of new Swift devs work through this exact framework loading issue, so let’s walk through the most reliable fixes step by step:
1. Double-Check Framework Embedding & Linking (Critical!)
Xcode’s interface for handling frameworks has shifted a bit in recent versions, so let’s make sure you’re doing this correctly:
- First, remove any existing references to
JJFloatingActionButton.frameworkfrom your target’s Frameworks, Libraries, and Embedded Content section (under the General tab). - Drag the framework file directly into your Xcode project navigator, making sure to check the box for your target in the "Add to targets" prompt that pops up.
- Go back to your target’s General tab, click the
+button under Frameworks, Libraries, and Embedded Content, selectJJFloatingActionButton.frameworkfrom your project, and set its Embed option to Embed & Sign (this is non-negotiable for dynamic frameworks like this one).
2. Wipe Xcode’s Caches & Simulator Data
Corrupted build artifacts are a super common culprit here:
- Press
Cmd+Shift+Kto clean your project, thenCmd+Option+Shift+Kto fully erase the build folder. - Delete the app from your simulator, then restart the simulator (Device > Restart).
- For a deeper clean, delete your Derived Data: Go to Xcode > Preferences > Locations, click the arrow next to the Derived Data path, and delete the folder for your project. Restart Xcode afterward.
3. Verify Framework Paths & Build Settings
Make sure Xcode can find the framework at both compile and runtime:
- In your target’s Build Settings, search for Framework Search Paths. Add the path to where your
JJFloatingActionButton.frameworkis stored (e.g.,$(PROJECT_DIR)/Frameworksif you keep third-party frameworks in a dedicated folder in your project root). Use a recursive path if needed. - Next, search for Runpath Search Paths and ensure it includes these two entries:
@executable_path/Frameworks@loader_path/Frameworks
These tell the app where to look for dynamic frameworks when it launches.
4. Confirm Framework Type & Installation Method
- If you installed the framework manually, double-check that you downloaded the correct dynamic framework build (not a static one). Static frameworks don’t need embedding, but dynamic ones do.
- If you used CocoaPods to install it: Make sure you opened the
.xcworkspacefile (not the.xcodeproj) after runningpod install. This is a super easy mistake to make that breaks framework linking.
Quick Troubleshooting Tip
If you still see the "no such file or directory" warning after embedding, try removing the framework from your project entirely, re-downloading a fresh copy, and repeating the embedding steps from scratch. Sometimes corrupted framework files cause weird issues that are hard to spot.
内容的提问来源于stack exchange,提问作者Mwikala Kangwa

