No such Module 'SwiftyJSON' on Swift 3.0

2019-02-11 17:36发布

问题:

After migrating to Swift 3.0, I am trying to import SwiftyJSON into my project. However, when I import the framework 'import SwiftyJSON' I get a No Such Module error.

If I remove the import statement, it does not recognize its classes.

Any advice as to why XCode might not be reading my imported framework?

See screenshots attached:

回答1:

My problem was I was opening the project file and not the workspace file...



回答2:

Try to check Targets-> Build Phases Link Binary With Libraries There must be a link with SwiftyJSON



回答3:

Updating my pod to reference the official SwiftyJSON gem worked for me! It updated from version 2.3.2 (what was installed by default via 'pod SwiftyJSON') to version 3.1.1.

So, in your Podfile, udpate your SwiftyJSON pod to:

 pod 'SwiftyJSON', :git =>'https://github.com/SwiftyJSON/SwiftyJSON.git'

HTH



回答4:

Clean your project and build again. Make sure you open project.xcworkspace.

pod 'SwiftyJSON'


回答5:

remove import SwiftyJSON to solve No such Module 'SwiftyJSON' on Swift 3.0

Swift can load the SwiftyJSON.swift by itself. No need to specify it at import statement.

Ref: https://github.com/SwiftyJSON/SwiftyJSON/issues/49



回答6:

Try this.

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

target 'Project names' do
  pod 'SwiftyJSON', git: 'https://github.com/BaiduHiDeviOS/SwiftyJSON.git', branch: 'swift3'    
end

post_install do |installer|
   installer.pods_project.targets.each do |target|
       target.build_configurations.each do |config|
           config.build_settings['SWIFT_VERSION'] = '3.0'
       end
   end
end


回答7:

If you have multiple targets, try building each of them. I had two targets - one would build and the other would not. This may help you trace the issue.

In my case I just nuked my dev target that was not working, duplicated the production target, made a few settings changes, and was back in action.



回答8:

clean your project and than build and run your project and than not work so remove your swiftyjson cocoa library in u r cocoapods and reinstall it should surely work and this 100% work for me ..so u try this.



回答9:

This solution helped me. Build the modules individually, and then build your project.

https://stackoverflow.com/a/37732248/4899943