No such module 'RestKit' with cocoapods an

2019-01-10 16:17发布

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.

21条回答
老娘就宠你
2楼-- · 2019-01-10 16:57

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-10 17:01

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.

查看更多
4楼-- · 2019-01-10 17:02

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

查看更多
走好不送
5楼-- · 2019-01-10 17:03

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

查看更多
爷、活的狠高调
6楼-- · 2019-01-10 17:03

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!

查看更多
三岁会撩人
7楼-- · 2019-01-10 17:03

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
查看更多
登录 后发表回答