You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xcode9项目导入DisplaySwitcher失败:安装Pod仍提示模块不存在

Troubleshooting "No such module 'DisplaySwitcher'" in Swift

Hey there, let's work through this frustrating module-not-found issue together—totally get how confusing this can be when you're just starting out with Swift and CocoaPods! Here are some step-by-step checks and fixes tailored for beginners:

1. Double-check you're opening the right project file

This is the most common gotcha for new CocoaPods users:

  • After running pod install, CocoaPods creates a .xcworkspace file (not the original .xcodeproj). Make sure you're opening this workspace file every time you work on the project—if you open the old .xcodeproj, Xcode won't see the installed pods at all.

2. Verify your Podfile and re-run a clean installation

  • Open your Podfile and confirm it has the line: pod 'DisplaySwitcher' (watch out for typos here!).
  • If it looks correct, run these commands in your project's root directory to wipe old pod references and start fresh:
    pod deintegrate
    pod install
    
    pod deintegrate removes all existing pod links, which fixes weird leftover issues from previous installs.

3. Fix Xcode's Build Settings inheritance

Sometimes Xcode fails to pick up pod settings automatically:

  1. Open your workspace, select your main project target (not the Pods target) in the left sidebar.
  2. Go to the Build Settings tab, search for Framework Search Paths.
  3. Ensure $(inherited) is listed here, and set to Recursive.
  4. Next, search for Other Linker Flags—again, make sure $(inherited) is present in this list.

4. Clear cached build files

Corrupted cached data often causes odd errors:

  • Press Cmd + Shift + K to clean your project.
  • Go to Xcode > Settings > Locations, click the arrow next to the Derived Data path, and delete the folder for your project to clear all cached build files.
  • Restart Xcode, open the workspace, and try building again with Cmd + B.

5. Confirm the pod is actually installed

Quickly check your project directory:

  • Open the Pods folder—you should see a DisplaySwitcher subfolder with the module's source code or framework. If it's missing, run pod install --verbose in the terminal; this shows detailed logs to spot issues like network errors or version conflicts.

Your Code Reference

import UIKit
import DisplaySwitcher
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

Attached Screenshots

内容的提问来源于stack exchange,提问作者Alex Snell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:32:33