Swift pod no module found - Nimble, Quick - swift

While installing swift pod - Nimble, Quick, - I have faced weird problem. I saw success message for all the pod after pod install but all the frameworks showed me as red. And when tried to import these modules started showing me error as "No such module".

You can build Nimble and Quick separately just go to the manage schemes and check Nimble and Quick in the show column. After that just build both Nimble and Quick.

After trying lot of options - even suggested by #Vital - I have seen this problem comes very often. I created a new project and above answered didn't worked.
If you go to the link CocoaPods TroubleShooting page and refer #4. Solution seems to work always as it builds pods before building the project target. This is very useful in case you see pod frameworks are red in color and it's not able to find in derived data.

Open the project with the .xcworkspace file not with .xcodeproj.

Related

FBLPromises Framework not found

I am tryin to install Firebase using cocoapods so I may send push-notifications to user devices. However, everytime I follow the instructions step by step, I get this error that says "framework not found FBLPromises". Anyone have any ideas how to fix? Everything I have looked up online does not work.
The following worked for me:
What probably happened (for anyone still looking) is that after running
pod install
in your project's directory, you are still building the ".xcodeproj" file instead of running the newly created ".xcworkspace" from the pod install. Remember, after pod installing, you MUST do edits on and work with the .xcworkspace instead.
Go to your Pod target and add arm64 in Excluded Architecture
I was having the same issue, and I solved it by going to Product > Scheme > Edit Scheme... and selecting Find Implicit Dependencies. After that, the project was able to build correctly.
Probably late but I managed to fix it by linking FBL promises in my podfile to the rest of the project!
Click on the project > Targets. Select your target. Then click on Build Settings. Find "Runpath searches path" and add "$(PODS_CONFIGURATION_BUILD_DIR)/PromisesObjC". It worked for me, but it gave me another error dealing with another missing lib, so I had to do it again until all libs were found.
Go to your Pod target and set Build Active Architecture Only = YES For Debug Environments
Simply setting Build Active Architecture: Debug - Yes, Release - No fixed this for me. I had it set to No, No before. I think this matches the setting in the Pods project.
Open Podfile by typing the command open Podfile in the folder of the project using the terminal.
Type pod Promises
Done

Library not Loading/Image not Found - Swift 4.0

So I am very new to Swift and XCode. I am trying to use an external library called JJFloatingActionButton the projects build fine but when I try run it on an emulator I get:
dyld: Library not loaded: #rpath/JJFloatingActionButton.framework/JJFloatingActionButton
Referenced from: /Users/mkangwa/Library/Developer/CoreSimulator/Devices/
3E58C8A1-3F02-4CA0-8EF3-A79311A202A2/data/Containers/Bundle/Application/D8BBF9A8-5BC7-4619-
B08C-2E6F7C6BCB85/DriversHub-iOS.app/DriversHub-iOS
Reason: image not found
Now of course I know you can't come ask a question like this on StackOverflow without researching and trying to find a solution yourself, so thats what I've been doing for the past few hours I have been looking at what was causing this, I started thinking that maybe it was the library it's self so this one is the third or fourth I've tried till I came across a few posts on SO that were about this issue.
Most people fixed this by just putting the Framework into the Embedded Binaries in the targets General Settings. And I tried this but I now receive a log:
I also get a Dependancy Analysis Warning:
I don't know much about these types or warning and errors but it's saying that it can't find the file which is pretty self explanatory but when I am adding the file to Embedded Binaries it shows the framework file there
What I often do when I have problems with cocoapods is remove cocoapods from the project and reinstall it.
You could use pod deintegrate (https://github.com/CocoaPods/cocoapods-deintegrate) to remove it and then a pod install to reinstall.
So it took a day and a half to work this out but I have finally got it and I can carry on with my project.
Problem:
The problem in my particular case (because other methods seemed to have worked for people trying to achieve the same thing) that the reason my project wouldn't build and was throwing Build Time errors was because after adding the Framework to Embedded Binaries it was also adding it to Embed Frameworks in my targets Build Phases. This then, I believe, caused the compiler to try and build it twice hence the Multiple Build Commands error
Solution:
So the errors I kept getting where saying No such file or directory above it was saying Multiple build commands for output file and what I did to fix this I went to Build Phases in my target settings and deleted the framework from Embedded Frameworks but made sure it was still under [CP] Embed Pods Frameworks.
in my case I was have to make framework "embed & sign" in stead of "don't embed"

pods in a framework, import that framework for main project in swift

The idea is to have an api framework (new project -> cocoa touch framework) for example "SuperApi". SuperApi use pods like Alamofire, ObjectMapper and whatever I need.
Next I want to integrate that SuperApi into my app like a normal framework.
I tried different ways. I tried to add it at "Embedded Binaries" and/or tried to add superApi at "Linked Frameworks and Libraries". Without success. I always linked the whole framework-folder.
import SuperApi threw always an error: could not find framework
Then I read something about workspaces where I can have a lot of projects parallel. This seems really overpowered for an api.
Create a framework without pods (xcodeproj) is no problem. There are a lot of descriptions in web. But what is a (good) solution for my problem?
I don't want to write my own http-networking + JSON parser. Thanks for input.
Why don't you add your SuperApi as a pod of your main project? You can have it either as a local pod, directly linking the last commit or using your own private repo
There's a very nice tutorial by Ray Wenderlich: https://www.raywenderlich.com/99386/create-cocoapod-swift
Thanks Eli. I found this video, it's more up to date
https://www.youtube.com/watch?v=gNMNeqXKnzw&t=964s (thanks to you Mr. Levi Bostian - you made my day)
Unfortunately this video is a litte bit outdated too.
You run into a Swift 2/3 issue. So you have to create a .swift-version in your git. For example Alamofire did it like this: https://github.com/Alamofire/Alamofire/blob/master/.swift-version
You can do it like this in your pod-folder: echo 3.0 > .swift-version
I ran into a second issue, because my pod wasn't up to date. So update your pod sudo gem install cocoapods --pre
Last but not least I had a warning in my podspec, so I have to use pod spec lint --allow warnings
Better way is to fix the warning ;)

Using installed pod in swift project

I'm trying to create a swift program that uses sockets. In order to do that, I'm trying to use the SwiftSocket library by installing it using CocoaPods.
My Podfile is basic:
target 'socket' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for socket
pod 'SwiftSocket'
end
According to the installation guide of SwiftSocket, after installing the pod I should be able to use the TCPClient right away.
Still, I fail to use the class in my main.swift file as it doesn't find the class.
I've searched the web to see what I'm missing here, but all I found are guides on how to bridge Pods written in ObjectiveC but not on pods written in Swift.
Any help?
Thanks
EDIT: With jamshes reginahit suggestion, I've added SwiftSocket.framework to the Linked Frameworks and Libraries, in addition to the Pods_socket framework that was already present.
Now the build is successful, but I gut a runtime error of Thread1: signal SIGABRT with the payload:
yld: Library not loaded: #rpath/SwiftSocket.framework/Versions/A/SwiftSocket
Referenced from: /Users/jonathan/Library/Developer/Xcode/DerivedData/socket-buglawjxihebcabvcihcbdrtkcxt/Build/Products/Debug/socket
Reason: image not found
(lldb)
EDIT2: Something was funky with my Xcode. I've reinstalled it and now it seems to work fine. Thanks to everybody for the help. :)
I would like to comment, but I don't have enough reputation.
Anyway did you write something like:
import SwiftSocket
in the class where you need it? Also, did you open the project with the xcworkspace extension?
If nothing works try to clean and rebuild the project
Based on my checking of the SwiftSocket Library, it seems that what you did should be fine (it should be pod 'SwiftSocket' referring to "Installation" section), I assume that you missed to add :
import SwiftSocket
in your main.swift class.
And yes, they are not mentioning that in "Code examples" section because they -probably- assume that importing it in your .swift file should be obvious.
Once CocoaPods is finished installing, you need to start using the .xcworkspace instead of your .xcproject file. So close your project, open the workspace (same directory), and import SwiftSocket.
Your Podfile seems correct, after that, you need to launch a terminal from your project directory:
cd ~/Desktop/MyProject/
Then run: pod install command.
This will create a .xcworkspace file and a Pods directory.
Now you have to open the .xcworkspace file with Xcode.
Donc forget to import yout pod like this: import SwiftSocket
Also take a look at the CocoaPods documentation: https://guides.cocoapods.org/using/using-cocoapods.html

Swift - no such module PureLayout with manual installation AND cocoa pods? Its impossible?

I've tried everything. EVERYTHING. I have no. idea. what Im doing wrong here.
Ive downloaded test projects and followed every step under manual installation AND install using pods here: https://github.com/PureLayout/PureLayout#problems-suggestions-pull-requests
I already have Parse and some other modules installed via pods so I first went to pods. I first went to my pods file and wrote
use_frameworks!
pod 'PureLayout'
JUST as the working sample projects did. I then navigated to my project (I think I did this right - went to terminal did cd Desktop then cd my project name, didn't think I had to cd anywhere else) and ran pod install . After this nothing happened in terminal (I got no response no matter what I did) and no PureLayout files were added to my project.
I still got no such module Purelayout when trying to trying to import PureLayout so then I tried manual.
I have dragged the files here https://github.com/PureLayout/PureLayout/tree/master/PureLayout/PureLayout into my project and imported in my bridging header:
Tell me if Im missing something. I still get no such module - even checked in my build settings that it had the right bridging header. I can continue without this and have no ideas - What am i doing wrong?
Is this an impossible problem?