user2325154 user2325154 - 3 months ago 10
Swift Question

How to add a module in Swift app via cocoa pod?

I am trying to add a module (SwiftyJSON) in my app but getting error. I followed https://www.raywenderlich.com/97014/use-cocoapods-with-swift tutorial for installing cocoapod on my Mac OS and it got installed successfully. I also got the module installed successfully. However, when I am trying to load the module in my swift file using the

import SwiftyJSON
statement I am getting error that says
No such module SwiftyJSON
.

Documentation for SwiftyJSON: https://github.com/SwiftyJSON/SwiftyJSON#integration

Podfile

platform :ios, '9.0'

target 'ApplePaySwag' do

use_frameworks!

# Pods for ApplePaySwag
pod 'SwiftyJSON'
pod 'AEXML'

target 'ApplePaySwagTests' do
inherit! :search_paths
# Pods for testing
end

end


Am I missing anything?

Answer

1) try putting use_frameworks! outside of target (under platform) 2) pod install 3) if import doesn't work try cleaning application (cmd + shift + k) 4) also clean derived data from the project -> xcode -> window -> projects -> derived data (delete)

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

target 'TestingModules' do
  use_frameworks!

  # Pods for TestingModules
  pod 'SwiftyJSON'
  pod 'AEXML'

  target 'TestingModulesTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'TestingModulesUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end