No such Module 'SwiftyJSON' on Swift 3.0 - swift

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:

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

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

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

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

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

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

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.

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.

This solution helped me. Build the modules individually, and then build your project.
https://stackoverflow.com/a/37732248/4899943

//import SwiftyJSON comment out first then
pod install
and then agian add
import SwiftyJSON
and pod install
it work for me

In your Xcode project go to podfile and enter :
pod 'SwiftyJSON'
Save and close the Xcode.
Open terminal and go to project directory and enter :
pod install
Open the project and Import SwiftyJSON in which file you want to use.

Related

No such module 'FacebookCore' in swift 5

I am doing my own test app as part of my learning process in iOS development (using swift 5 on Xcode 11.0). I want to add login with Facebook on my login page but I keep getting No such module 'FacebookCore' when importing the library.
I followed the instructions on developer.facebook and tried to implement the SDK using cocoaPods and here is my Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'TestApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestApp
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
target 'TestAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'TestAppUITests' do
# Pods for testing
end
end
After executing pod install and adding the data in my info.plist as instructed by Facebook, I can clearly see that the framework has been linked in the Link Binary With Libraries section
But still, I can't seem to import FacebookCore nor FacebookLogin.
PS: I tried several solutions like:
1- Running the .xcworkspace instead of .xcodeproj
2- Building the project even with the error being displayed (some said it would go away)
But none of them worked.
I suspect that the problem is in my Framework search path but why would it be wrong in the first place? so I may be wrong, here's a screenshot to my search path anyway:
So it turned out that I have to import FBSDKCoreKit instead of FacebookCore which was not mentioned in facebook's documentation. And it should be imported strictly using the .xcworkspace file which was also not mentioned in the documentation.
Use FBSDKCoreKit instead of FacebookCore
This are the correct pods
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
and your imports should be
import FBSDKCoreKit
import FBSDKLoginKit
in previous version there was FacebookCoore as wrapper for the FBSDKCoreKit classes. It looks like Facebook has removed this since v5.x.
The following should be your entries in Podfile
pod 'FacebookCore'
pod 'FacebookLogin'
and your imports should be
import FacebookCore
import FacebookLogin

How to fix no such module 'CSVImporter' xcode error when installing CSVImporter

After installing CSVImporter I still can't use it. When I import it at the beginning of some file with import CSVImporter, it says No such module 'CSVImporter' What could be wrong?
Xcode 9.0.1
platform :ios, '11.0'
target 'worDecks' do
use_frameworks!
pod 'CSVImporter', '~> 1.7'
end
edit
Sorry, had to delete it to figure out what the problem was.
Even if I just install the package and build the project, it throws a lot of errors.
The package is listed in the list of frameworks

How to fix cocoapod .modulemap file not found

When I try to build my project, I get a compile time error saying that a "Module map file" for my pod cannot be found and that I am missing a "SwiftShimes" module.
This is weird because all my modulemap files are where they should be when I install my pods.
I am using Xcode 10.2 and Cocoapods 1.6.1.
I have tried the following ->
deintegrating cocoapods from my project
cleaning the project
deleted ModuleCache and DerivedData
restarting my computer
This is the type of error I am getting ->
Module map file '/Users/kaunamohammed/Library/Developer/Xcode/DerivedData/OutNow-gxdxvzwmnijmrlajtbtyclkhrgqs/Build/Products/Debug-iphoneos/CodableFirebase/CodableFirebase.modulemap' not found
I expect my project to build properly but this is not the case and I am not sure what else to do.
This is what my Podfile looks like
platform :ios, '10.0'
workspace 'OutNow'
target 'OutNow' do
use_modular_headers!
#Pods for OutNow
pod 'Instabug'
pod 'SwiftMessages'
pod 'CodableFirebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'MarqueeLabel/Swift'
pod 'RxSwift', '4.4.2'
pod 'RxCocoa', '4.4.2'
pod 'Kingfisher', '5.3.1'
pod 'InstantSearchClient', '6.0'
pod 'CoordinatorLibrary', '1.0.5'
pod 'UIScrollView-InfiniteScroll', '1.1.0'
target 'OutNowTests' do
inherit! :search_paths
# Pods for testing
end
end
In case it helps anyone else, I was able to solve this issue a different way. I was accidentally opening up my .xcproject instead of my .xcworkspace. When I opened the correct file, the error went away.
I fixed this problem myself. I can tell you what I did. Not sure which steps did it exactly, but below are all steps:
Copy the contents of your Podfile somewhere safe
Run: pod cache clean --all
Remove "Podfile"-file from the dir.
Xcode: Product > Clean Build Folder
Run: pod init. A new "Podfile"-file is added to the dir
Start adding parts of your original Podfile to this file
Run: pod install
Try to build your project again
In my case, I think the row use_frameworks! in the "Podfile" did the trick.
Hope this help you guys out!
I had this issue only when I wanted to make an archive. On the other hand, debug worked fine. After a while I noticed that min iOS version was different between my Target, Project and Podfile min iOS version. After syncing them all to same value (iOS 11) Xcode offered me Validate Project Settings - Update to recommended settings option which I accepted and I was able to archive my project.
I spent a whole day trying to figure out how to solve this issue. I was facing issue in my project on M1 machine.
I enabled "Open using Rosetta" option in Xcode and worked for me.
Here is how you do that:
Open Finder --> Applications --> Right click "Xcode" --> Get Info --> check "Open using Rosetta"
I solve this issue by removing OTHER_SWIFT_FLAGS custom flag in Swift Compiler - Custom Flags
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/modulePath/moduleName.modulemap\"";
I faced this same issue but with Fastlane using gym build_app.
I ensured that min iOS version was synched between my Target, Project, and Podfile as mentioned by Josip B. This allowed me to archive my app using XCode but it still failed using Fastlane.
After lots of searching, it was able to resolve my issue by ensuring the IPHONEOS_DEPLOYMENT_TARGET version for each of my installed Pods inherited the version from my Podfile using this Podfile post-install script:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Reference this post: https://stackoverflow.com/a/63489366/10211406
In case you are building on command line with xcodebuild, make sure you are using
xcodebuild -workspace ...
instead of just xcodebuild or
xcodebuild -project ...
I had this issue too, I'm not very familiar with XCode, but I opened the .xcodeworkspace file and then clicked build, which was successful!
It´ s a bit of a hack but try adding this in your podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
make sure you add it to your bridge file, and Try to add this at the end of your podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

No such module PDKClient with Cocoapods

I have installed the Pinterest SDK with cocoapods successfully, but when I try to import PDKClient, it says "No such module PDKClient".
My podfile:
target 'MyPin3' do
pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyPin3
end
I definitely have my xcworkspace open and I have tried clean + build. I've looked up some other Stack Overflow answers (tried deleting framework search paths, etc.) with no luck.
Any help would be appreciated. Thank you.
Rather than PDKClient, you should be importing PinterestSDK. Try this line and it should work:
import PinterestSDK

cocoapods Google Mobile ads does not generate .xcworkspace file

I am exporting a project from Unity3d to xcode that uses the last GoogleMobileAds package.
I have installed and updated cocoapods and also have the famous podfile containing de following lines:
source 'https://github.com/CocoaPods/Specs.git'
install! 'cocoapods', :integrate_targets => false
platform :ios, ‘8.0’
target ‘MyProject’ do
pod 'Google-Mobile-Ads-SDK', '~> 7.14’
pod 'Firebase/Core'
pod 'Firebase/AdMob'
end
and I run
pod install
and
pod update
successfully
dependancies are downloaded alright, as you can see the results below:
Updating local specs repositories
CocoaPods 1.2.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0.beta.1
Analyzing dependencies
Downloading dependencies
Using Firebase (3.9.0)
Using FirebaseAnalytics (3.5.1)
Using FirebaseCore (3.4.4)
Using FirebaseInstanceID (1.0.8)
Installing Google-Mobile-Ads-SDK (7.14.0)
Using GoogleInterchangeUtilities (1.2.2)
Using GoogleSymbolUtilities (1.1.2)
Using GoogleToolboxForMac (2.1.0)
Generating Pods project
Skipping User Project Integration
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 8 total pods installed.
According to both cocoapods and google mobile ads documentation, I will need to continue with "MyProject.xcworkspace" but the file is nowhere to be found.
any suggestions?
When using install! 'cocoapods', :integrate_targets => false Cocoapods will not create an xcworkspace for you.
That's the intended behaviour. You'll even notice this if you follow the command prompt. This line is telling you that no integration is taking place.
Skipping User Project Integration
If you want to get an xcworkspace just remove :integrate_targets => false
It seems the problem comes from editing the Podfile using TextEdit.
As it warns you that you should not continue using TextEdit, one could falsely suppose that the program is intelligent enough to understand and correct these unwanted modifications.
This is the solution I have found:
delete the Podfile and Podfile.lock from your working directory
create a new Podfile using pod init
install SublimeText and use it to open the Podfile
add the necessary pods for the project
(I also included the line "use_frameworks!" although it may not be
needed.)
run "pod install" and "pod update"; this time I get
[!] Please close any current Xcode sessions and use Orbit.xcworkspace for this project from now on.
and the file is now available in project directory
You was used this guide for install pod?
In addition to Radu Dita's message. If you do not want that line to be added (so you do not need to delete it later), you need to disable cocoapods integration in "iOS Resolver Settings" by selecting "None", build project and then enable it back "Xcode Workspace". I found this with try and error. I hope my message will save save someone's time