Getting error “No such module” using Xcode, but the framework is there

前端 未结 30 1734
小蘑菇
小蘑菇 2020-11-22 05:02

I\'m currently coding in Swift, and I\'ve got an error:

No such module Social

But I don\'t understand, because the module is in

相关标签:
30条回答
  • 2020-11-22 05:50

    In case it's Friday afternoon or anytime after 1am:

    Opening xcodeproj instead of xcworkspace will cause an error like this...

    0 讨论(0)
  • 2020-11-22 05:50

    I was experiencing this problem as well. The fix for me was that the Archive schemes between the two projects didn't match. I have an xcworkspace with a framework project and an app project. The problem was that in the Archive scheme for my app, I was using a different Build Configuration than the framework was using for it's Archive scheme. I set both Build Configurations to Release, and that fixed the issue.

    0 讨论(0)
  • 2020-11-22 05:50

    Ok, how the same problem was resolved for me was to set the derived data location relative to the workspace directory rather than keeping it default. Go to preferences in xcode. Go to locations tab in preferences and set Derived data to Relative. Hope it helps.

    0 讨论(0)
  • 2020-11-22 05:51

    TL;DR: Check your Podfile for target-specific shared_pods

    After beating my head against the wall and trying literally every single other answer posted here over the last week, I finally found a solution.

    I have two separate targets - one for release and one for development. The development target was created long after the release target, which lead me to forget some setup steps for that target.

    I was able to get my project to compile properly using my release target, but my development target was having an issue.

    After looking at my Podfile for the twentieth time, I noticed that I only had the following, under my shared_pods definition:

    target 'Release' do
      shared_pods
    end
    

    What I needed to do was add my second target to my Podfile, and that fixed the issue:

    target 'Release' do
      shared_pods
    end
    
    target 'Development' do
        shared_pods
    end
    

    Hopefully this saves someone a few days of frustration.

    0 讨论(0)
  • 2020-11-22 05:52

    In my case, after many attempts to figure out what I was doing wrong importing a framework I eventually discovered that the framework itself was the problem. If you are not getting your framework from a trusted source you should inspect the framework and ensure that it contains a Modules folder with a module.modulemap file inside it. If module.modulemap is not present, you will get the "No such module 'MyFramework'" error.

    If the Modules folder is missing the "MyFramework.swiftmodule" folder then the framework will be found but Xcode won't know about its contents so you will get different errors.

    0 讨论(0)
  • 2020-11-22 05:52

    I also encountered the same error a few days back. Here's how I resolved the problem:

    The error is "module not found"

    • Create Podfile in your root project directory
    • Install cocoapods (a dependency manager for Swift and iOS projects)
    • Run pod install
    • Go to Project Build Settings:

      • Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project)
      • Drag and drop the library header file from left side to bridging header (see image attached)
    • Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above)

    • In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h"
    • In your Swift file the code should be: Import Mixpanel (i.e name of library)

    That's all.

    0 讨论(0)
提交回复
热议问题