No such module ... in Xcode
Asked Answered
W

9

18

I've run into a problem with Xcode (using Swift) that has me completely stumped. I realize that this question has been asked and answered, but none of the answers have worked for me, and my situation seems to be a bit different than the others, as all of my pods are failing (not just a specific one). They all worked fine a week ago.

I use Cocoapods for some of the more common Swift frameworks (e.g. Alamofire, Eureka, Kingfisher, SwiftyJSON, etc.). They were all working fine in Xcode 7. However, one of the (automatic) updates bumped up my Xcode version, after which it became mandatory to specify your target in the podfile. I did this and ran pod install. The pods are all still there, but now every import statement that relates to these frameworks fails.

At first I thought it was an Alamofire issue, as that's the first one that failed with the "No such module 'Alamofire'" error. I tried everything I could with Alamofire, including the following:

  • Clean and rebuild
  • Clean build folder
  • Restart Xcode
  • Re-boot computer
  • Delete all derived data
  • Added framework to "Linked Frameworks and Libraries"
  • Added framework to "Link Binary with Libraries"
  • Verified that I am opening the workspace rather than the project
  • Re-installed CocoaPods
  • Re-installed Xcode ver 7.3.1

Nothing would remove the "No such module ..." error. Finally, I removed Alamofire from the pods and just dragged the Alamofire project into my project. This allowed me to remove the import statements for Alamofire. However, to my dismay, now the next framework caused "No such module". I moved the next three frameworks into my project, and it looks like it is just going to keep going. Apparently, none of my Pods frameworks are being recognized anymore. I installed Xcode 8 and tried that with Swift 2.3, but I get the same "No such module" errors.

I really would prefer to use Cocoapods, as it makes upgrades a lot easier, along with other bonuses. I'm guessing I have some setting wrong that is screwing up all my pods, but have not had any luck finding it. This is a bit of a disaster as it has shut down development for several days, with no sign of a fix. If there is anything I can do or provide to assist in finding a solution, just let me know. If anyone could provide any possible solutions or even things to try, it would be greatly appreciated. I'm currently working with Xcode version 7.3.1.

My pod file looks something like this:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'Y2GOsp' do
    use_frameworks!

    # Pods for Y2GOsp
    pod 'Alamofire', '~> 3.0'
    pod 'AlecrimCoreData', '~> 4.0'
    pod 'Kingfisher', '~> 2.4'
    pod 'Eureka', '~> 1.6'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'xcode7'
    pod 'PhoneNumberKit', '~> 0.1'
    pod 'PKHUD'
    pod 'Dollar'
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '2.2'
        end
    end
end
Witha answered 11/10, 2016 at 3:54 Comment(7)
Have you tried reinstalling or updating CocoaPods?Marginate
@l'L'l , yes, I have re-installed it a couple of times. I even tried the --pre version. I have re-installed Xcode, too, as my original install got upgraded to version 8. I tracked down a version 7.3 installer and re-installed it, but am still getting the error.Witha
When you tried adding the frameworks into your project what is set for build settings > frameworks search path?Marginate
$(PROJECT_DIR)/Y2GOsp $(PROJECT_DIR) Should the path to the pods folder be in there, too?Witha
That might be the issue.. try setting to $(SRCROOT) (recursive) or ${TARGET_BUILD_DIR}/YourFrameworkName.framework...Marginate
@l'L'l You got me on the right track. I think I have it solved, now. I'm still dealing with other migration issues, but I'm not getting stopped on Import statements, anymore. My Framework Search Paths value is now $(inherited) (non-recursive) , $(PROJECT_DIR)/build/Debug-iphoneos (non-recursive), and $(SRCROOT) (recursive). If you want to post your answer, I can mark it as the correct one. Thanks.Witha
had this issue.. i'd definitely ensure you've opened the workspace, and not the project. I didn't even realise I had done it (in error) until i noticed the Pods project missing.Picardi
W
33

Comments from @l'L'l led me to the solution. I went to

build settings > frameworks search path

and set it to the following:

$(inherited) (non-recursive)
$(PROJECT_DIR)/build/Debug-iphoneos (non-recursive)
$(SRCROOT) (recursive)

It is now correctly finding the pod frameworks.

Witha answered 13/10, 2016 at 21:58 Comment(0)
K
17

Make sure you opened the .xcworkspace file in Xcode and not just the .xcodeproj file.

Kathrynekathy answered 8/3, 2018 at 11:29 Comment(1)
I spent hours trying everything mentioned in several other stackoverflows. This was it!Culminant
D
9

In Pod file

Uncomment below lines to define a global platform for your project

platform :ios, '10.0'

use_frameworks!

Now in xcode

a) Clean your project

b) Make sure that all your "Pods" > "Build Settings" > "Build Active Architecture Only" is set to "NO"

c) Now, build project

Deify answered 25/10, 2017 at 13:44 Comment(0)
B
3

Sometimes pod deintegrate and then pod install helps me as well

Beryllium answered 21/11, 2019 at 12:18 Comment(0)
M
1

try to make the version of your SDK into earlier versions

pod 'Alamofire', '~> 3.0'
pod 'AlecrimCoreData', '~> 4.0'
pod 'Kingfisher', '~> 2.4'
pod 'Eureka', '~> 1.6'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'xcode7'
pod 'PhoneNumberKit', '~> 0.1'
pod 'PKHUD'
pod 'Dollar'

for example change 3.0 to available previous version, it worked once for me when i was facing the same issue.

pod 'Alamofire', '~> 2.4' #I am assuming prev available version is 2.4

But it doesn't have to be the "Alamofire" version result in "No such Module", you may try every one in your list in the pod file.

Margarethe answered 11/10, 2016 at 4:27 Comment(3)
It looks like this might work. I'm past Alamofire, anyways. I'm now getting the error on Eureka. I'm going to fight with it more in the morning and will let you know my results. Thanks. Good name, too... my name is Sheldon as well :)Witha
😀Hi Sheldon. Please select as the correct answer if u feel it's right.Margarethe
No luck :( I thought it was working for a sec, but then realized that I had removed the import statements, so it just moved on to the next one and would have eventually failed later in the compile. When I put the import statements back, then it started failing again.Witha
F
1

I had the same problem and I just solved it by making sure that my "Find Implicit Dependencies" is checked. Go to Edit Scheme -> Build. Previously I uncheck this so my xCode will run a little bit faster. Never realized that it will later throw me this error.

Feticide answered 4/9, 2020 at 2:7 Comment(0)
J
1

Although the question is long time ago, "no such module" error made me in Xcode 13 struggle for 3 days. I found many different solutions here, but still cannot fix it. Until I tried applying different solutions together and found my own solution.

My issue is that I can build the app on device, but shows "no such module" when building it on simulator. It seems there is something wrong while building pods.

Therefore, I added use_frameworks! & use_modular_headers! in Podfile.

target 'Application' do

use_frameworks!
use_modular_headers!        

pod 'ChameleonFramework/Swift', :git => 'https://github.com/wowansm/Chameleon', :branch => 'swift5'
pod "BSImagePicker", "~> 3.1"
pod 'FirebaseCoreInternal'

I also changed the Build Setting of the Pods to exclude building pods in architecture of arm64. I did the same in my Project and Target's Build Settings.

Image of Pods' Build Settings

Please note that if you install new pod to the project, the Build Settings of Pods will be reset. You need to mannaully change back to exclude arm64.

Joyann answered 26/7, 2022 at 2:10 Comment(2)
You can add code at the end of your pod file that will change them all for you, so you don't have to go through and manually change each pod. post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '5.1' config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end endWitha
adding use_modular_headers!, resolved the issue, thanksPostconsonantal
C
0

For me the problem was that I updated the name of a build configuration within my project, but I didn't select the new build configuration in the scheme that used that build configuration. Updating the build configuration within the scheme to the new name fixed the issue!

Chiropractic answered 21/9, 2021 at 19:21 Comment(0)
M
0

You should excluded Architecture to nothing, also I did run the pod install command to install the pods.

click the link to see the image

Mcchesney answered 24/1, 2023 at 11:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.