iOS项目集成JonkyKong's SideMenu遇“No Such Module”错误求助
Hey there, I’ve run into this exact frustration before with CocoaPods/Carthage and Swift version mismatches—let’s work through this step by step to get SideMenu up and running for your project.
First, Double-Check the Basics
- Always open the
.xcworkspacefile (not.xcodeproj) when using CocoaPods. It’s the most common oversight that causes this error. - Confirm your project’s Deployment Target matches SideMenu’s requirements (for Swift 4.0, SideMenu v5.x requires iOS 9.0+). If your target is lower, that could break the framework import.
Fix for CocoaPods Installations
1. Update Your Podfile for Swift 4.0 Compatibility
Older versions of CocoaPods don’t always auto-set the correct Swift version for dependencies. Add a post-install hook to force SideMenu to use Swift 4.0:
platform :ios, '9.0' use_frameworks! target 'YourProjectName' do pod 'SideMenu' end # Force all pods to use Swift 4.0 post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '4.0' end end end
2. Perform a Full Clean & Reinstall
Close Xcode completely, then run these commands in your project directory:
pod deintegrate pod clean rm -rf ~/Library/Developer/Xcode/DerivedData # Wipes all cached builds pod install
Open the .xcworkspace file again and try importing SideMenu.
3. Verify Framework Search Paths
In your project’s Build Settings, search for Framework Search Paths and make sure it includes:
$(inherited)(set to recursive)${PODS_ROOT}/SideMenu(also recursive)
Fix for Carthage Installations
1. Confirm Cartfile Points to a Swift 4.0-Compatible Version
SideMenu v5.x is the first version to support Swift 4.0. Update your Cartfile:
github "JonkyKong/SideMenu" ~> 5.0
2. Reinstall & Verify Framework Setup
Run this to pull the correct version:
carthage update --platform iOS
Then:
- Go to your project’s General tab, under Linked Frameworks and Libraries, make sure
SideMenu.frameworkis added (and it’s pulled fromCarthage/Build/iOS/). - Check your Build Phases: Add a Run Script phase with this command:
Then add/usr/local/bin/carthage copy-frameworks$(SRCROOT)/Carthage/Build/iOS/SideMenu.frameworkto the Input Files section.
3. Full Clean & Restart
Same as with CocoaPods: Delete DerivedData, restart Xcode, and rebuild your project.
Last-Ditch Troubleshooting
- Create a brand new Swift 4.0 test project and install SideMenu using the same method. If it works there, the issue is with your main project’s configuration (check for conflicting build settings or multiple targets with mismatched setups).
- Double-check SideMenu’s release notes to confirm the version you’re installing explicitly supports Swift 4.0 (avoid versions older than 5.0).
内容的提问来源于stack exchange,提问作者Elmaik

