Error message 'ld: warning: directory not found for option' while installing and 'library not found for -l' with CocoaPods - ios

I installed IRLDocumentScanner & ObjectiveDropBoxOfficial but impossible to compile because of that error message:

I always had dependancies problems or update problems using that kind of tools.
I prefer to integrate manually libraries instead of using CocoaPods...
I suggest you remove your pods using this:
Remove or uninstall library previously added : cocoapods
and manually install your libraries. It seems more difficult, but you'll save time anyway.

I decided to remove CocoaPods and add manually all the files which is more simple. Impossible to find the way to add another pod (ObjectiveDropBoxOfficial) with an existing one (IRLDocumentScanner) without having one thousand problems.
I used that answer to remove it (very well done):
https://stackoverflow.com/a/32921657/3581620
I will never use CocoaPods anymore.

Related

Duplicate Symbol Problem With React Native

So I've been facing a really weird problem with React Native.
I installed a library via Cocoapods for picking images from the camera roll/photo Library and cropping the image as well, it is a silver bullet for this kind of usage. But then, it installs alongside React Native version 11, but this version of React Native was not what I wanted so I had to install React Native via Cocoapods as well so I can have the React Native version I'm using.
Now all installed well and if I try to build in my Dev environment everything works fine but when I try to archive, I get the error for duplicate symbols for WebSocket, Image (the library requires you to add RCTImage as a subspec in Cocoapods for React Native), RCTText, etc. basically all the subspecs you're required to add if installing React Native via Cocoapods according to the React Native docs.
So I figured I'll need to remove the manually linked libraries from my project, so I did that, but that only resulted in me now having another error when building for dev saying WebSocket, Linking, Network, etc are missing. Basically all the subspecs you're adding via Cocoapods, so I don't understand, if I install React Native and all its subspecs via Cocoapods (I'm also running in the workspace) shouldn't my project use the installed pods and not the linked libraries?
I've been on this for like 3 weeks now.
Here is my pods list.
Here is my linked binaries list.
Please, what do I do? I've been stuck for 3 weeks now, have tried almost any solution online but nothing has changed.
Thanks in advance.
I have solved the problem, only thing is I think you should use this carefully because I don't fully understand what it does. So within the docs, there is this Cocoapods code snippet that when you add to the Pods file after your target ends resolves this problem. Here is the code snippet.
# very important to have, unless you removed React dependencies for Libraries
# and you rely on Cocoapods to manage it
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end
If you know exactly what this does please post another answer with this code snippet and an explanation so I can make the answer to the question, or better yet, edit the answer with the explanation, or leave a comment below so I can update my answer. From the looks of the above code snippet, though I'd say this is removing React and it's Subspecs from the installed pods, right after installation, I might be wrong.
Now when you're done with the installation, you'll get another error when you try to build saying react-native or React could not be resolved because it is in multiple locations and that you should delete one of them, to resolve this new error, simply go to the Pods directory and delete the React folder, that is [project-root]/ios/Pods/React once you do this, your application will build for development and also archive for production.
This problem I faced stands as a result of not properly reading installation guides, there may be small discrepancies between how it's usually done and how it's done for the library you're installing, so try and give a little more attention to detail.
For me,
delete all Link Binary With Libraries (From Build Phase)
delete Podfile.lock
run pod install
Wait for Indexing In Xcode
command+shift+k (Clear the project)
build again and fix it.

Missing Frameworks from Cocoapods after switching computers

I recently switched computers and brought over my project but when I opened the workspace I noticed that all of my frameworks via Cocoapods were missing.
I closed the workspace and went into the folder directory and deleted the current xcworkspace, 'Pod' folder, and podfile.lock file, and ran a pod update and pod install. I also deleted the Derived Data for safety measures. However, after reopening the newly created workspace the frameworks were still missing and I am getting an error saying that functions that are within my frameworks have been renamed.
Can anyone point me to another solution? I feel like I've tried just about everything that I could find on here and what I know. Thanks in advance!
Missing Frameworks
Framework Incorrect Full Path
Function Renamed Errors
The frameworks are probably missing because they've not been built yet, but they will show up the first time you run the project.
The function rename warnings are probably because you're using a newer version of Xcode that is using Swift 4.2 by default. Usually the easiest way to tackle this is to upgrade your Pods to newer versions.

Issue with linking Pods in React Native

I have been trying for the last days now to get React-Native (tried 0.49-0.53) to work with several native Modules/Packages like react-native-image-resizer, react-native-orientation, react-native-splash-screen, HockeySDK etc.
When I install the packages according to the package Maintainer/git repo README, there is always a link error - some file missing unless I also install Pods:
$pod install
This leads to installing the packages Podfiles, but also the React Pod is installed, unfortunately an outdated version (0.11).
To install a current version, I followed this React Native tutorial https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies .
Also I need to change the Xcode-Project from .xcodeproject to .xcworkspace (According to several github issues, please write if you are interested, I can regoogle the links).
This helps with the errors before but leads to this error:
ld: 21 duplicate symbols for architecture arm64
So the problem is that 2 versions of React are deployed simultaneously?
So wrapping it up:
Packages with native implementation need to be linked (react-native link)
Linking them installs Pods which in turn reinstalls/links React as Pod
This leads to a * duplicate symbols* error
Any idea?
I re-initialized a new project not installing pods at all!
Also be careful, most npm-packages require either normal installation or pods, just don't use pods!
The problem is just it will link a whole extra react-native as a pod, sometimes even a different version, which in the end leads to duplicate symbols. Maybe one could reference the react native libs to the already installed (in node_modules), but 1. I don't know how and 2. found the above way.

Downgrading from CocoaPods 0.35.0 to 0.33.1

I need to downgrade CocoaPods from 0.35.0 to 0.33.1. However, I'm running into problems.
The Situation
It seems during the upgrade from 0.33.1 to 0.35.0, CocoaPods does the following:
Remove the pressumably obsolete Pods.xcconfig file.
Add the files Pods.debug.xcconfig, Pods.release.xcconfig, etc.
Remove the presence of Pods.xcconfig from my project.pbxproj.
Record the presence of Pods.debug.xcconfig etc in my project.pbxproject.
To downgrade the CocoaPods project from 0.35.0 to 0.33.1, I removed the Podfile.lock and Pods/ folder from my project and did a fresh pod install.
CocoaPods successfully creates Pods.xcconfig. However, my project.pbxproj file is untouched. My project doesn't know about the presence of Pods.xcconfig, hence it no longer compiles. The records for Pods.debug.xcconfig etc are still there, even though it is not used in CocoaPods 0.33.1.
The Questions
How can I tell my Xcode project to use Pods.xcconfig?
How can I tell my Xcode project that I no longer use Pods.debug.xcconfig etc?
Is there a known procedure to gracefully downgrade the CocoaPods version of a project?
Thanks!
Your best bet to do this would be to entirely remove CocoaPods from your project (as I described here) and then run pod install with the older version.
On a sidenote to this, downgrading versions of CocoaPods is a bad idea. Before CocoaPods hits 1.0 any breaking changes can be made that may make working with your old version and the specs repo impossible (without cloning an old unsupported version and maintaining it yourself). As you can see now the minimum supported version is 0.32.1. Obviously that won't be changed just for the fun of it but, if possible, I would recommend that you sort out your issues with the newer versions and try to stay on it.

Working with git submodules/cocoapods

I am working on a project which includes other repositories from Git.
I would like to keep up to date with these repositories. Know what are the latest features, bug fixes etc.
Qu 1) What is the best way to keep up to date with a repository on Git without receiving emails of all issues reported etc?
After this is complete I would like to know the best way to include these into your project. I understand you can copy the source code into the project, but what are cocoapods/sub modules used for? For example, what is the correct way to update your project with the latest changes to that included repository?
Are there any GUIs for either of these methods as opposed to terminal?
Cocoapods is a great way to include other projects in your Xcode project. The Cocoapods project maintains a list of pod spec files for a many open source libraries, which specify where to download the code and how to integrate them into an existing project. As you noted, you'd traditionally have to add a git submodule, manually add the source files to your project, update your build settings, and so forth. Cocoapods takes care of all of this for you.
I'm not sure of a way to track updates for Github projects without also being notified about issues, but Cocoapods can certainly tell you if any of your 'pods' have become outdated. It's then one command to update them to the latest versions. That said, it's generally best practice to 'lock' your external dependencies to a specific version that you know works correctly.
Using Cocoapods
To get started, first install Cocoapods. You then simply need to create a file in your root project directory (the same directory that contains your .xcodeproj file) called Podfile. Inside, you can specify your target OS, and your dependencies:
platform :ios, '5.0'
pod 'AFNetworking', '0.9.1'
pod 'OHAttributedLabel', '0.1.1'
The example above is targeting iOS 5.0, and pulling in the AFNetworking and OHAttributedLabel projects.
Then, in the Terminal, change to your project directory:
> cd path/to/my/project
And run pod install.
> pod install
This will check out the latest version of your dependencies for you. It will also generate you a .xcworkspace file. From now on, when you work on your project, you must open the .xcworkspace, not the .xcodeproj file.
Inside your new workspace, you'll have your existing Xcode project and a new Pods project - this contains all of your third party libraries. Just build and run your app as normal, and the Pods project will also be built and included.
Some other useful Cocoapods commands:
> pod outdated
Will list all dependencies that have an update available.
> pod search query
Will search all known Pod specs for 'query'. Useful for finding new libraries!
Tutorials
Looks like Tutsplus have a nice tutorial on getting started with Cocoapods
There's a free episode of NSScreencast on Cocoapods
GUIs
I'm afraid I don't know of any GUIs for Cocoapods, but there really aren't many Terminal commands that you need to know. It's worth getting comfortable with the command line, as it's such a useful developer tool.
That said, as far as I know, Appcode (Jetbrains' alternative IDE for Objective-C) is planning on adding Cocoapods support in their next update.
Good luck!
James Frost's answer is an excellent explanation of how to work with Cocoapods and their advantages over submodules.
A few important advantages submodules have over Cocoapods are:
submodules are sub-repos - not only does this mean that git and git GUIs implicitly recognize them and more and more support easily working with them, it also means that your dependencies stay connected the wonderful world their git repos, Cocoapods or not, reside in. This means that you are able to collaborate and test changes from within your project, your project usually being the source of inspiration for elaboration of a dependency.
Unfortunately Cocoapods do not maintain this link, to work on a dependency means to clone it from git, outside of the range of Cocoapods.
Edit: It's worth noting that Cocoapods does allow working on a local pod with the path or local fields or even building your own Spec repo but it still isn't as simple a process.
one less tool dependency - as mentioned in the previous bullet, submodules are a function of git and your using git means they are available to you. Any software's adoption of git implies that they will eventually support either all (important) features of git or all features that cover common use cases. Xcode 5 has brought in a basic support for git and GUIs (which are tool dependencies, it's true, but hopefully just dictate how information is surface, git dictates how it works) like Git Tower make working with sub-repos straightforward.
Cocoapods has come a long way and everyday is taking steps to becoming a stable, indispensable tool. However it hasn't yet gotten a nod from Apple and there isn't any reason why Apple won't release a change to Xcode that breaks Cocoapods. Additionally Cocoapods is dependant on Ruby. Aside, considering how much attention and community has been generated around Cocoapods it would be silly for Apple to ignore it.
It's also worth noting that using one does not lock you out of using the other. It might be a headache or it might be what you need, perhaps using Cocoapods for tiny one class libraries or libraries with complex dependancies and submodules for libraries with that you will be interacting with often.

Resources