2

I keep getting the error

No Such Module 'Alamofire'

In my Xcode project swift file when using import Alamofire; the file is in a separate module within the project.

I have tried the following;

  • Build and Run Alamofire Target
  • Comment out import Alamofire and run project, then uncomment and build again
  • Make sure I am using the <MyProject>.xcworkspace not .xcodeproj
  • Use $(inherited) in project > Build Settings > Build Options > ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES

  • Update Cocoapods, remove and reinstall dependencies

However when I open the inspector window for the swift file, the Target Membership has both the main app and the module boxes ticked.

enter image description here

When I untick the module for which the file is within, then in my seperateModuleTests file I cannot use the classes used in the swift file, as I get the error;

Use of undeclared type

&&

Use of unresolved identifier 'ClassName'

It seems when I uncheck the target membership for the swift file for the class that is used for the tests, seperateModuleTests doesn't recognise the classes from the swift file. But when I check the the target membership for the swift file to be part of the separate module then I get the original error.

Can anybody help me on why this is happening and how I can resolve ?

RileyDev
  • 2,950
  • 3
  • 26
  • 61

2 Answers2

5

I think you are missing add Alamofire in your tests targets

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'AppName' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for AppName
  pod 'SwiftyJSON'
  pod 'Alamofire', '4.4.0'

  target 'AppNameTests' do
    inherit! :search_paths
    pod 'Alamofire', '4.4.0'
  end

  target 'AppNameUITests' do
    inherit! :search_paths
     pod 'Alamofire', '4.4.0'
  end

end

Better would be

You can also make a configuration with all pods that are commons to your targets

# Uncomment this line to define a global platform for your project
platform :ios, '8.2'
# Uncomment this line if you're using Swift
use_frameworks!

# Define main pods.
def main_pods
    #Your common pods here
    pod 'Alamofire', '4.4.0'
end

target 'AppName' do
    main_pods
    #add here other pods specific for this target
end


target 'AppNameTests' do
    main_pods
    #add here other pods specific for this target
end

target 'AppNameUITests' do
    main_pods
    #add here other pods specific for this target
end

Hope this helps

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
0

Run a Clean: Product > Clean then a Build.

If that doesn't work. How is this being used? Is it for your own code, or is it another module that requires you to have AlamoFire?

jlmurph
  • 1,050
  • 8
  • 17