Nital
Nital

Reputation: 6084

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?

Upvotes: 0

Views: 1628

Answers (2)

Kristijan Delivuk
Kristijan Delivuk

Reputation: 1252

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

Upvotes: 1

Anil Kumar
Anil Kumar

Reputation: 955

Add this in your podfile

 # Uncomment this line to define a global platform for your project
    platform :ios, '9.0'
    use_frameworks!
    def common_pods   
    end
    target 'ApplePaySwag' do
        common_pods
        pod 'SwiftyJSON'
        pod 'AEXML'
    end
    target 'ApplePaySwagTests' do
        common_pods
    end

and Run pod install,

then clean your project..

after that close the ApplePaySwag.xcodeproj and open ApplePaySwag.xcworkspace

Upvotes: 0

Related Questions