3
votes

I am creating an application and I need to import "Alamofire" and "ObjectMapper" to call a service API REST. The problem is that I can not import any of the two pods in any way.

To simplify the program I have created a project with only one viewController. In it, I do an import at the beginning (for example: import Alamofire) and I have a podfile of this type:

Source 'https://github.com/CocoaPods/Specs.git'
Platform: ios, '10 .0 '
Use_frameworks!

Target 'TestAlamofire'
Pod 'AlamofireDomain'
Pod 'ObjectMapper'

In "Build settings" my framework search path is:

"$ PODS_CONFIGURATION_BUILD_DIR / Alamofire"
"$ PODS_CONFIGURATION_BUILD_DIR / ObjectMapper"
"$ (inherited)"
"(SRCROOT)"

If I remove the "import AlamofireDomain" or the "import Objectmapper" in the viewController the program compiles and executes, but if I add it the error "no such module ..." appears.

Where do you think the error is? What solution do you give me?

The application is developed with Swift 3.0, Xcode 8.2.1 and IOS 10.

2
Adding $(PODS_CONFIGURATION_BUILD_DIR) for Framework Search Paths in target Build settings with recursive option worked for memra214

2 Answers

2
votes

I think your Podfile is missing do and end which are the keywords where you add the required pods in between

so try to do something like this to fix it

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

platform :ios, '10.0'

target 'TestAlamofire' do
    pod 'Alamofire', '~> 4.4'
   pod 'ObjectMapper', '~> 2.2'
end

Also since you are using pods i'm guessing that you already installed them by

  • opening the terminal
  • typing cd then hit space
  • then drag and drop the folder containing the Podfile then hit return
  • then type pod install and hit return

after you are done downloading open the workplace the file with .xcworkspace extension

you can also take a look at the Cocoapods guides

2
votes

Steps I've taken to solve the problem:

-Change my Podfile to:

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

platform :ios, '10.0'

target 'TestAlamofire' do
    pod 'Alamofire', '~> 4.4'
    pod 'AlamofireDomain', '~> 4.1'
    pod 'ObjectMapper', '~> 2.2'
end
  • Install the Xcode 8.3 because bells I installed the Almofire 3.1 and not the 4.1 that is the swift 3

  • When we do the 'import Alamofire' it will return the error, but if we click cmd + B, the project will be rebuilt along with the import we made.

  • Open the file with extension 'xcworkspace' and not the 'xcodeproj'