64

I am having this problem with a brand new project. This problem happens with both RestKit and Facebook SDK. Strangely SwiftyJSON works just fine. I create a brand new swift project and a Podfile with:

source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

target 'test-fb-swift4' do
    pod "FBSDKCoreKit"
    pod 'SwiftyJSON', '~> 2.1'
    pod 'RestKit', :inhibit_warnings => true
end

target 'test-fb-swift4Tests' do

end

After creating that file I run pod install and reopen xcode with the test-fb-swift4.xcworkspace file.

Now inside my controller I put a import RestKit and I get the error No such module 'RestKit'. I have tried many different ways to format the Podfile even down to very simple versions like:

source 'https://github.com/CocoaPods/Specs.git'

pod 'RestKit'

I have tried adding and removing the use_frameworks, with and without the target. With and without the :inhibit_warnings.

I am running CocoaPods 0.36.4 and tried the latest rc build, same deal. The Objective-C version from another project runs fine. This is my first project using Swift and I am stuck on this issue.

Joped
  • 1,108
  • 1
  • 11
  • 12

25 Answers25

130

I had the same problem. My solution was to open the project using the .xcworkspace, not the .xcodeproj. .xcodeproj only contains the main project; .xcworkspace includes everything including Restkit.

Joe McMahon
  • 3,266
  • 21
  • 33
BHuelse
  • 2,889
  • 3
  • 30
  • 41
  • i had to "save as Workspace" to get a workspace for a new project – hanzolo Nov 30 '16 at 21:38
  • 2
    Glad I found this answer after more than 1 hour of searching. OP should really mark this as accepted. – Andrea Lazzarotto Dec 09 '16 at 14:58
  • Very ugly solution. The better way is to fix the issue: remove and add back Pods.framework on Target > Build Phases > Link Binary With Libraries. – Dmitry May 12 '17 at 23:30
  • 3
    The OP said that they had already done this-- *"After creating that file I run pod install and reopen xcode with the test-fb-swift4.xcworkspace file.*" – Tom Harrington Oct 02 '17 at 17:44
41

I had a similar problem. Not with RestKit specifically, but initially with the HockeySDK. I tried everything, including removing and reinstalling pods, updating cocoapods itself and updating pods, deleting derived data, cleaning the project, etc.

I then noticed that every pod was an issue for me. After continuing to search on related topics, I finally discovered that under:

• Target > Build Phases > Link Binary With Libraries

I had a misplaced Pods framework (likely from a prior Pods setup or install attempt).

Target > Build Phases > Link Binary With Libraries

After removing it, the problem went away. I have noticed that people seemed to experience similar problems under:

• Project > Info > Configurations

as well, where the Pods framework was being mapped incorrectly. So if the first doesn't work for you, you may want to check on the second as well.

metatheoretic
  • 1,082
  • 9
  • 13
  • 4
    The second suggestion about build configurations was what caused this for me. I renamed my "Debug" build configuration on the app's project, but on the Pods project this created a new configuration instead of renaming "Debug". Deleting the "Debug" configuration from Pods project so that the configurations match those from the app's project solved it. – Tyler Sheaffer Jul 27 '16 at 19:42
39

The second option worked for me. In my Project > Info > Configurations, I have 2 targets for my project : the regular one (Quizz) and the test one (QuizzTests): enter image description here

For the regular one, the configuration was set with "Pods.debug" or "Pods.release" but there was none for QuizzTests. As soon as I filled in the configuration for QuizzTests, everything worked for me.

louftansa
  • 515
  • 4
  • 8
24

For me, deintegrating and re-installing pods fixed the issue.

First

pod deintegrate

and then

pod install
Vishal
  • 2,030
  • 22
  • 27
  • 6
    This was a very simple solution, for some reason the others listed here did not work for me. May not matter, but make sure Xcode is shut down when deintegrating. – Connor Clark Jul 06 '17 at 01:06
  • Same here. I had troubles after I `rm -r`'d my Pods directory, and re-installed with `pod install`, but `pod deintegrate` and `pod install` worked. – Unixmonkey Apr 29 '20 at 20:22
19

One thing you could very easily do to rectify this issue is to make sure that XCode is completely shut down when installing pods. Whenever I have this issue, I go back and find out that XCode was still open even though I closed the project. Hope that helps!

Marquis103
  • 395
  • 3
  • 8
  • Very helpful, I was trying everything except this step. – Zee Jun 14 '16 at 15:31
  • Yes, it is likely that if the pod install took place with Xcode open, then the frameworks are not initially visible. Simply closing and reopening the project fixed this for me. –  Oct 06 '18 at 12:21
16

Another potential solution that I found was to add use_frameworks! to your Podfile if you have not already and then run pod install again. It was an issue with Firebase when I added only that pod.

Ian Han
  • 507
  • 5
  • 7
  • Worked for me too. Seems I'd removed use_frameworks! from my Podfile and since I have a mixed Swift/Objective-C project the Swift part needed the frameworks included. – AndyDunn Sep 16 '16 at 09:43
16

Another reason of this problem can be wrong values in target's Build Settings - Build Active Architecture Only. Settings like in the picture work for me. Correct settings

saltwat5r
  • 1,107
  • 13
  • 21
  • 1
    Interesting, fixed for me too. I had changed this setting previously, but doing another `pod install` reset the value. – Kevin Jantzer Jan 11 '17 at 16:57
7

For me, 'Find implicit Dependencies' was unchecked. and it was the issue. Worked fine once I checked it.

The path: Edit Scheme > Build > Find implicit Dependencies

enter image description here

Ashok
  • 5,585
  • 5
  • 52
  • 80
  • THIS. I would upvote this a thousand times if I could. Thank you so much. I turned this option off because Swift kept on rebuilding every single file every goddamned time I changed any file. But without this option on, Swift can't find the modules included by CocoaPods. – Womble Jun 04 '18 at 10:37
  • @Womble. I'm glad that it helped you! – Ashok Jun 05 '18 at 11:48
  • 1
    I lost 3 days on this. Thank you for the solution, I own you a beer. – Boris Legovic Oct 23 '19 at 05:33
5

I had a similar issue when adding Fabric to my project. I had multiple targets (Release and Dev). It would throw No Such Module for import Fabric. What worked for me was to go to Project> Build Phases > Link Binary with Libraries and simply marking the status of both the pod framework as Optional.enter image description here

Sharukh Mastan
  • 1,491
  • 18
  • 17
4

In my case I only had to check the next option in Xcode Find implicit Dependecies enter image description here

I don't know exactly why but this was enough for me, hope for you too :).

GOrozco58
  • 1,182
  • 12
  • 10
4

This should do the trick:

  1. pod deintegrate
  2. rm -rf yourproject.xcworkspace
  3. pod install
K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
Hyperfine
  • 91
  • 7
3

After hours of trying things, I discovered the cause. My main app target had 4 build configurations (debug, release, internal, external). However my frameworks (child projects) did NOT have internal, external as they are custom added. Once I added internal/external to my framework projects, all archived fine.

VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80
2

In my case, at first I had only one target in xcode. I executed pod install. A few months later, I had to make another target so I had multi targets.

In this situation, if I do pod install and build xcode, I get a "no such module" error.

So I removed pod files and then pod init.

Podfile format has been changed for multiple targets

It works!!

Check this out!

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • Pod init really works for me, i was only reinstall pod without removing podfile but it doesn't work at all along with other build settings. Here what works for me. I remove pods folder, podfile and project workspace file. Then pod init ... thanks, I spent 3 hours to fix this issue! – Dody Rachmat Wicaksono Jan 26 '20 at 03:33
2

Does your app build using the primary target?

If so, I was able to get this working by:

  1. Adding an entry for every target in the Podfile
  2. Run pod install

Here is my final Podfile.

platform :ios, '11.3'

target 'myapp' do
  use_frameworks!

  # Pods for myapp
  pod 'KeychainSwift'
  pod 'ReachabilitySwift'
  pod 'Firebase/Core'
  pod 'Fabric'
  pod 'Crashlytics'

  target 'myappTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'myappUITests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'myapp-local' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'myapp-master' do
    inherit! :search_paths
    # Pods for testing
  end
end
user896993
  • 1,341
  • 13
  • 15
2

One of the answers here was make sure that XCode is completely shut down when installing pods and I knew I had not done this. So I just closed Xcode completely and opened it again without running pod install and it fixed the problem. So restarting Xcode worked for me.

1

When I edited and removed a directory I didn't need in Project - Build Settings (next to Info), it was wiping out two of the entries in Framework Search Paths in my App Target in Build Settings. Make sure all the four rows have entries populated automatically from Pod install as shown in the image below: Framework Search Paths in Build Settings for your Target App To copy the entries from Debug and Release to the rows below, select one row at a time and hit delete which should copy from the row above. Once I did that, the workspace would build just fine.

RT Denver
  • 51
  • 3
1

If you are using multiple targets that access the same class (e.g. Messages Extension App), and if that class is added to both targets, you have to add the pod for both targets in the PodFile.

Ömer Karışman
  • 653
  • 5
  • 14
1

Things I tried:

  • Removing and re-adding linked pods framework
  • Cleaning
  • Deleting derived data
  • pod install again

The only solution I had to this problem was to expose the Pods-(yourapp) target in the scheme picker (next to the run/stop buttons) and manually build that Pods- target before building and running my main app target again. I hope this can save someone 10 minutes!

Dennis L
  • 1,713
  • 14
  • 21
1

Idea log: First, I think this issue is because the library link or framework search path missing this pod, but actually it does over there.

Second, I think it may be because the version support on XCode 10 leading incorrect mapping the pod. But after clean project, delete derived data, close Xcode, remove pod relate file and re-pod install. All these steps still failed…. I spent 4hrs on this second step…

Third, Finally keeping searching the google in StackOverflow, I found this person @Tyler Sheaffer leave his experience under the @metatheoretic solution.

There is one person leave his experience under someone else answer. And it reminds me that I do change the configuration early day for multiple schemes, most importantly, because the tutorial I follow that it teaches us to name the configuration name with an example: Debug (Development ). But the Cocoapods cannot accept the (). Therefore, I modified the configuration name Debug_Development… So!!! The issue is the scheme management do automatically update the config name on one of my customer scheme such as Development, and I only check the name update on scheme Development, which it does success update, then I skip to check other two custom schemes (staging, production). But!!! Those two still remain the older wrong config name. That's why my Kingfisher module will never be found because It didn't match the config and scheme. Finally, I solve this problem by selecting the new update config file in the Project/Scheme/Manage Schemes/ Case closed.

enter image description here

Wangdu Lin
  • 913
  • 1
  • 9
  • 19
0

This happened to me when an app extension had a different target iOS version than the app. Making them match fixed this for me.

YichenBman
  • 5,011
  • 8
  • 46
  • 65
0

I had this problem after marking Pods folder as ignored in .gitignore. How I fixed is that I rm -rfed the Pods folder and ran pod install, clean & build.

kubilay
  • 5,047
  • 7
  • 48
  • 66
0

If you're updating Xcode Version 11.0 (11A420a) and nothing else has worked, I recommend updating all libraries to Swift 5.0. This is unfortunately, the only thing that worked for me.

0

I also had this issue after renaming my project and modifying the build schemes. After hours of trying to get it to work, I found out what caused the issues for me.

CocoaPods auto-generates build schemes for each library you import. When you rename your project build configurations, these schemes are not updated with the same configurations, because they are in a separate .xcodeproject.

The steps to resolve this were easy:

  1. In Xcode, on the top left, select your build scheme and "Manage Schemes..."
  2. Remove all build schemes related to "Pods project"
  3. Close Xcode, run pod deintegrate and pod install

After this, you can open Xcode and the build should now work.

Alain Stulz
  • 715
  • 6
  • 19
  • yay my Xcode 12.2 keeps crashing when clicking on "Manage Schemes"... any other way to remove the pods build schemes? – Sevyls Dec 01 '20 at 10:16
  • 1
    @Sevyls Very weird bug with Xcode/Big Sur, it happens with Xcode application settings too. Weirdly, it only happens when the Xcode window is being shown on an external monitor. So if you're using a laptop connected to a screen, just move the Xcode window to the internal display and you should be able to open it as expected. – Alain Stulz Dec 04 '20 at 11:14
-2

The problem might be that there really is no such module. Especially if the pod name contains dashes and other controversial characters.

In my case I was trying to use Dip-UI library. The sample project was using Carthage which I wanted to replace with CocoaPods. Module name with Carthage was DipUI, while with CocoaPods it was Dip_UI, which meant that I was getting "No such module" until I changed the name.

Andrii Chernenko
  • 9,873
  • 7
  • 71
  • 89
-3

Your xcode is not updated to the version expected by the library / framework

Code Tree
  • 2,160
  • 4
  • 26
  • 39