cocoapods integration on existing workspace - ios

I'm new to CocoaPods and was able to use it on some sample project.
Now I'm trying to integrate it into my current working project.
The project is a iOS application project which use target dependency on other some static library I've created which also uses another static library with dependency I created.
So basically it's 3 project nested in each other.
After init&install the Podfile on the main project I can't build the project
getting the error: Library not found for -IPods-MYAPPNAME.
Any ideas what should I do to integrate an existing project with many frameworks and dependencies to CocoaPods or is it a lost battle?

Related

Working with both SPM and Cocoapods in the same project

I have an Xcode project, consisting of a swift packages, a custom cocoa pods and one target dependency.
In workspace I have:
Project ProfileUtil - xcode project of type Framework. This project contains Firebase SPM dependencies
Project DatabaseUtil - xcode project of type cocoapod. This project contains Firebase pods dependencies
Project MeditationApp - Xcode project of type iOS Application. This is the main application, and it should include ProfileUtil as a framework swift packages, and DatabaseUtil as a Pod
When I try to compile the main iOS application, Im seeing errors like:
Error: Redefinition of module 'Firebase'
module Firebase {
export *
header "Firebase.h"
}
So that got me wondering if I can mix both SPM and Cocoapods in the same project if both uses the same library internally? (I couldn't find any useful ressources online about that use case, which surprise me)
Is there a bypass I could do to fix those, because as in the moment I have to keep my custom pod DatabaseUtil as a cocoapods.
Nope. Firebase does not support being installed from both CocoaPods and Swift Package Manager in the same project. It might be possible to hack into place by hacking the workspace after a CocoaPods install, but it would be fragile.

Use an iOS framework that has dependency on some pods

I have created a framework project in Xcode -that has dependency on some pods- to be able to use in different Xcode projects.
How can Xcode be informed to get that framework the dependency it needs?
You have to declare the dependencies on frameworks or on other pods in the podspec file. This file will explain to cocoapods how to correctly bind the pod in your XCode project.
You have an example at the end of the second sample in this page.

Embed a framework in a cocoapod framework project

I have an application which is using a library installing via Cocoapods.
In that library project, now I have embedded a framework and it build successfully.
Back to my application when I do pod install then build. The library pod show me error:
No such module 'embedded framework'
in the swift file which I used that framework.
I have research and try many solutions but still not work. How can I bring the embedded framework along with my library project?
Add link binaries:
Add copy files:
Still error in the main application when compile:
Go to your Xcode project General Tab. Check for Embedded Binaries.
Now, Add your missing lib. or framework here.
Check in screenshot below.
Clean and run the project.

How to publish current framework as cocoapods without creating a new one?

I have hard time in publishing current framework to cocoaPods.... I found that in order to publish framework you need to run pod lib create. However, that creates completely new project, while I want to publish my current framework... How can I distribute my library without creating new project and copying all files and double checking git and etc...
Create a podspec describing your framework. See the podspec manual at https://guides.cocoapods.org/syntax/podspec.html.
BTW, CocoaPods never uses existing Xcode projects for libraries. CocoaPods creates a new workspace for CocoaPods consumers that combines their existing project into an Xcode workspace with the requested CocoaPods.

Custom framework development with COCOA POD

I'm creating a custom framework which uses Cocoa Pod internally. After installing POD I cannot make use of framework using agreegate target.
I added framework project with my application project just by trag and drop it inside Application project and linked it using Aggregate Target. After installing POD with custom framework, I can not make use the above mentioned way to link framework with my aggregate project.
Thanks
If you are developping a standalone librairy, something that users will have to add manually in their project, you CANNOT use cocoapod in your librairy project. No way! You'll have to provide your users with an install procedure indicating all extra step (framework install, project settings modification, pods to install) they'll have to follow to get your framework up and running.
This is why nowaday people use dependency manager like cocoapods. It makes it easier for users to install their product and install automaticly the dependencies.
If you are planning to distribute your framework thru pod, then follow the recommanded step to create your project architecture and reference in the example project (that uses pods) your dependencies.

Resources