Xcode 12.4运行APP时dyld加载glog.framework失败及命令行启动闪退问题求助
Hey Hugo, let's work through this glog framework loading error you're hitting with Xcode 12.4 and the iOS 13.3 simulator. This "image not found" issue usually boils down to framework linking/embedding misconfigurations or stale cached data. Here are step-by-step fixes to try:
1. Verify and Refresh CocoaPods Dependencies (if using Pods)
Since glog is often pulled in via CocoaPods (e.g., as a dependency for Firebase or other libraries), start here:
- First, double-check your
Podfileincludes glog (or the parent library that depends on it). - Run these commands in your project root to reset pods:
pod deintegrate pod install - Close and reopen Xcode afterward—sometimes Xcode needs a fresh start to pick up new pod configurations.
2. Check Xcode Build Settings
Make sure your project is set up to find and load glog correctly:
- Go to your target's Build Settings:
- Ensure
Framework Search Pathsincludes$(inherited)(to pull in paths from Pods) and the direct path to glog's framework directory (e.g.,$(PROJECT_DIR)/Pods/glog). - Confirm
Runpath Search Pathsis set to:
These paths tell dyld where to look for frameworks referenced with@executable_path/Frameworks @loader_path/Frameworks@rpath.
- Ensure
3. Clear Cached Data
Stale derived data or simulator cache can cause weird loading issues:
- Delete Xcode's Derived Data:
rm -rf ~/Library/Developer/Xcode/DerivedData - Reset your iOS simulator:
- Open the simulator, go to
Device > Erase All Content and Settings - Or run this command in Terminal:
xcrun simctl erase all
- Open the simulator, go to
4. Fix Command-Line Launch Crashes
When running via command line, add debug logging to see what's going wrong:
- Launch your app with the
DYLD_PRINT_LIBRARIESenvironment variable to track framework loading:
ReplaceDYLD_PRINT_LIBRARIES=1 xcrun simctl launch booted com.your.app.bundle.idcom.your.app.bundle.idwith your app's actual bundle identifier. This will print every library dyld tries to load—you’ll see exactly where it fails to find glog.
5. Confirm Framework Embedding
Make sure glog is being copied into your app bundle:
- Go to your target's Build Phases:
- Check
Link Binary With Libraries—glog.framework should be listed here. - Check
Embed Frameworks—add glog.framework here if it's missing, and set itsEmbedoption to Embed & Sign (for dynamic frameworks).
- Check
- After updating, build your app again and check the app bundle: right-click the app in Xcode's Products folder >
Show in Finder, then right-click the app >Show Package Contents—verifyFrameworks/glog.frameworkexists.
If none of these steps work, double-check that glog was built correctly for the iOS simulator target (sometimes arch mismatches can cause this). You can try re-building the glog framework manually if it's not coming from CocoaPods.
内容的提问来源于stack exchange,提问作者Hugo Fernandes

