Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add cocoapod to ios framework

I am working on ios project, where I am using EVReflection library in project,I am having one custom framework there I am using EVReflection for that I have taken cocoapod i added after that I am trying to build framework it is not building and one more my project is also using Evreflection so if I add my custom framework to project will it add automatically import Evreflection there also.

SampleFramwork i am adding evreflection

code:

 platform :ios, '9.0'

target 'SampleFramework' do
   use_frameworks!
  pod "EVReflection"

end
like image 362
skyshine Avatar asked Jul 03 '17 07:07

skyshine


People also ask

How do CocoaPods work with libraries?

For both choices CocoaPods will set up your library as a framework. The template will generate an Xcode project for your library. This means you don't have to go through creating a new project in Xcode.

What is CocoaPods in Xcode?

Cocoapods is a dependency manager used to install dependencies for swift and objective C projects in XCode. It is similar to the maven or griddle, which are used to install dependencies in Java. However, a dependency manager is a tool that manages the set of frameworks to make life a few easier for the developers.

How to set up CocoaPods on Mac?

Setting Cocoapods on the mac. To install cocoapods on the mac, we need to run a simple command. This process is very simple and straightforward. Go to the terminal, and type the following command. This will install the cocoapods gem on the system.

What is @CocoaPods in Swift?

Cocoapods can be defined as a dependency manager for the swift and objective C projects, which can be used to install various third-party libraries in the XCode project. It is a very critical skill on which every iOS developer would have worked.


3 Answers

Install POD

[ 1 ] Open terminal n type:

sudo gem install cocoapods

Gem will get installed in Ruby inside System library. Or try on 10.11 Mac OSX El Capitan, type:

sudo gem install -n /usr/local/bin cocoapods

If there is an error "activesupport requires Ruby version >= 2.xx", then install latest activesupport first by typing in terminal.

sudo gem install activesupport -v 4.2.6

[ 2 ] After complete installation, there will be a lot of messages, read them and if no error found, it means cocoapods installation is done. Next, you need to setup the cocoapods master repo. Type in terminal:

pod setup

And wait it will download the master repo. The size is very big (370.0MB at Dec 2016). So it can be a while. You can track of the download by opening Activity and goto Network tab and search for git-remote-https. Alternatively you can try adding verbose to the command like so:

pod setup --verbose

[ 3 ] Once done it will output "Setup Complete", and you can create your XCode project and save it.

[ 4 ] Then in terminal cd to "your XCode project root directory" (where your .xcodeproj file resides) and type:

pod init

[ 5 ] Then open your project's podfile by typing in terminal:

open -a Xcode Podfile

[ 6 ] Your Podfile will get open in text mode. Initially there will be some default commands in there. Here is where you add your project's dependencies. For example, in the podfile, type

pod 'EVReflection'

(this line is an example of adding the AFNetworking library to your project).

Other tips:

Uncomment platform :ios, '8.0' Uncomment user_frameworks! if you're using Swift

When you are done editing the podfile, save it and close XCode.

[ 7 ] Then install pods into your project by typing in terminal:

pod install

Depending how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says

"Pod installation complete! There are X dependencies from the Podfile and X total pods installed."

Now close your xcode project and open .xcworkspace xcode project file and start coding. :)

like image 134
Jogendra.Com Avatar answered Nov 15 '22 19:11

Jogendra.Com


Configuration should look something like this:

1) Open terminal and locate your project root

2) write: pod init

3) write: atom podfile (or nano/vim/some other texteditor)

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

# Public spec repository
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

target 'ProjectName' do

    # Pods for ProjectName
    pod 'EVReflection'


end

4) write: pod install

5) close all of your current xcode projects, and open project.xcworkspace file

like image 39
Kristijan Delivuk Avatar answered Nov 15 '22 19:11

Kristijan Delivuk


  • Use the format below in Podfile

    use_frameworks! target "YourProjectName" do pod 'EVReflection' end

  • If it is not building yet , add it to Embedded Binaries and Linked Frameworks and Libraries

enter image description here

like image 32
roy Avatar answered Nov 15 '22 20:11

roy