No such module 'RestKit' with cocoapods and swift

怎甘沉沦 提交于 2019-11-27 11:32:08
BHuelse

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.

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).

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.

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):

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.

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

First

pod deintegrate

and then

pod install

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!

Ian Han

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.

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.

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

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.

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

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

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.

Hyperfine

This should do the trick:

  1. pod deintegrate
  2. rm -rf yourproject.xcworkspace
  3. pod install

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.

user2189597

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!

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!

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.

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:

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.

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

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.

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

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!