"No such module" error in Xcode 8

1.3k views Asked by At

I get the "No such module" compilation error in Xcode 8.2.1 in my Swift project. I use Carthage with two modules: Alamofire and Fuzi. The Carthage/Build/iOS directory exists with the two framework files. The Build Settings/Framework Search Paths points to that directory. I have embedded the two framework files in General/Embedded Binaries. What am I missing?

2

There are 2 answers

2
Frazer On

You shouldn't need to embed the libraries; they should be added to Linked Frameworks and Libraries underneath the "General/Embedded Binaries" section. Make sure you have the Carthage copy-frameworks script added to your Build Phases.

From the Carthage documentation:

On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

$(SRCROOT)/Carthage/Build/iOS/Box.framework
$(SRCROOT)/Carthage/Build/iOS/Result.framework
$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework

This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files and dSYMs are copied when archiving.

0
JAK On

Firstly you check Carthage installed or not in your machine like the following command in your terminal

carthage version

If carthage is not installed in your machine try the following.

Download the latest release of Carthage, and double-click Carthage.pkg to run the installer. Click Continue, select a location to install to, then click Continue again, and finally click Install. Then you can check carthage version.

If you are using existing project then move to project folder like

cd ~/Path/To/Starter/Project

Try the following command for update cartfile

carthage update —platform iOS

After installation/updation completed then try the following command

open carthage

You should see a Finder window pop up that contains two directories: Build and Checkouts. In the Carthage Finder window, navigate into Build\iOS. Now, drag Alamofire.framework(for example) into the Linked Frameworks and Libraries section in Xcode:

Next, switch over to Build Phases and add a new Run Script build phase. Add the following command:

/usr/local/bin/carthage copy-frameworks

Click the + under Input Files and add an entry for each framework:

$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework