Pod install doesn't download frameworks - ios

I'm using switf and pods. When i type 'pod install' on my terminal, Instead of having the frameworks downloaded to my project, i get the files.
This makes no difference to me, except for the fact that when i want to import them in my project, i always get an error saying they can't be found.
Here is my pod file
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'Project' do
pod 'MSSTabbedPageViewController'
pod 'PageMenu'
end

As ocarol stated, import the framework. However, before importing at the top of the file you want to use the framework, build the project, as Xcode seems to not link the pod's to the project automatically.
Also open the .xcworkspace file that pod install generates.

You use these libraries as frameworks (use_frameworks!). So you have to import the framework at the top of the Swift file, like:
import MSSTabbedPageViewController
if had created a bridging header file, you can import the framework in it.

Related

How can you use cocoapod framework into another cocoapod created locally?

Specifically:
Created a new project
Setup CocoaPods
To the Pod file under Pods I added a dependency (for ex.AlamoFire)
The main app which consumes the pods can import Alamofire
The local cocoapod which I created and added by using the following lines in the podfile:
target 'SomeValue' do
my_own_pod
pod 'CocoaPod_2', :path => '/LocalPath/To/PodSource'
end
Ran pod install and I added the AlamoFire Framework to the CocoaPod_2 under Pods -> General-> CocoaPod_2-> Linked Libraries & Binaries
At this point I was expecting that importing Alamofire in my CocoaPod_2 will work fine but its not.
Screenshot of the workspace :
MyProject.XCWorkspace
|_MyProject.App
|____Source Code files importing CocoaPod_1 (Embedded using CocoaPod)
|____Source Code files importing CocoaPod_2 (Embedded using CocoaPods, local Pod)
|_Pods
|____Podfile
|____Frameworks
|____Pods
|___CocoaPod_1
|___CocoaPod_1 Source Files
|____Source Code for Local Pod
|___CocoaPod_2
|____File contains statement (import cocoapod_1) <---Gives error ld: framework not found
You need to do the following two additional things:
You need to add a Podfile in your CocoaPod_2 followed by a pod install.
Also, you need to define a CocoaPod_2.podspec file in your CocoaPod_2
folder.
If you add Alamofire in both the Podfile and podspec file of CocoaPod_2, you don't need to add in the main app's Podfile. Only adding CocoaPod_2 entry in the app's Podfile will suffice.
I hope that helps!

RealmSwift installation on Xcode

I am trying to create a project which uses Realm and RealmSwift. I have used Cocoapods to install these dependencies. I have seen the other posts too on stackoverflow and tried their solutions. They don't work for me. In my project, I'm getting the error "No such module as RealmSwift" when I write the import RealmSwift statement. Here are the steps I took for installation:
I created an empty xcode project
I went into terminal and navigated to my project directory
I gave the pod init command to create a pod file
I went into the pod file(it already had the use_frameworks! statement
I wrote in pod 'Realm' and pod 'RealmSwift'. I gave the sources as:
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
I wrote in pod install
The pods were installed successfully. I went into the .xcworkspace file.
I had already installed the realm plugin so I created a new realm object file
The template file opens with the following file. I'm getting the error that there is no RealmSwift module.
What am I doing wrong? Or what am I not doing? Is a bridging header required? Has anybody else managed to resolve this error?
Any relevant suggestions or insights are most welcome.
Its working now! Its so weird since I didn't do anything. I just went into my pod file commented out the use_frameworks! statement and ran pod update on the terminal. It gave me an error, so I added it back to my pod file. I wrote in pod update again and hit enter. I restarted Xcode cleaned it and built it and I wasn't getting this error anymore.
Need to uncomment platform in your pod file then try once again your pod.
# Uncomment this line to define a global platform for your project
platform :ios, '9.0' // Uncomment this
# Uncomment this line if you're using Swift
use_frameworks!
target 'Demo_Realm' do
pod 'RealmSwift'
end
target 'Demo_RealmTests' do
end
target 'Demo_RealmUITests' do
end

Can't import AFNetworking from CocoaPods in swift project

In Podfile I
pod 'AFNetworking', '~> 2.6.0'
pod update and I open project using xcworkspace.
And everything gone my way,but:
when i import AFNetworking ,Xcode prompt 'No such module AFNetworking'
I searched the solution for this question, and did like this: in 'Built setting ->User Header Search Paths ' add ${SRCROOT} and choose recursive.
But it didn't work . Xcode throw the same mesage :'No such module AFNetworking'
Okay,I just did a mistake operation .
platform :ios, '8.0'
use_frameworks!
Two line above is necessary ! After I added them and run pod update, my project's Link Binary With Libraries add a row contain Pods_.framework .Then I import AFNetworking is OK.
check out there :No such module 'RestKit' with cocoapods and swift
Go to
Project > General > Linked Frameworks and Libraries
When press "Plus" and add your framework from list.

Unable to add Parse using CocoaPods

Following are the steps I did to add Parse using CocoaPods but still getting unresolved error.
Added Pods File:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
pod 'Parse'
target 'GroomCal' do
end
target 'GroomCalTests' do
end
target 'GroomCalUITests' do
end
After that I did pod install. Parse and Bolts frameworks got installed (I can see them in XCode).
I then added -Bridging-Header.h and added #import <Parse/Parse.h>to it.
When I try to import Parse in AppDelegate.swift file, I still get No such Module Parse error message. What am I missing here.
I did use the *.xcworkspace file to open the project too.
To use cocoapods with swift you need to add the flag
use_frameworks! to the podfile as swift doesn't allow to add static libraries.
source Cocoapods blog

Unable to use both Swift and Obj-C libs with Cocoapods

I have just started a new Swift project and I would like to use different libraries. In particular, I would like to use Realm.io, an Obj-C library. But, I would also like to use pure Swift libraries such as Alamofire or Dollar.
I use Cocoapods for managing my dependencies. I use the latest version (0.37.0) and the new use_frameworks! flag. pod install is successful anytime.
Unfortunately, when I try to build my project I get two errors (for my main target):
Umbrella header Realm.h not found from module.modulemap
Could not build Objective-C module Realm from any file using import Realm
Other imports work fine.
I have noticed the following: if I remove pure Swift libs and use_frameworks, everything works fine. I am aware about this current issue from Cocoapods. However, it should not be a problem for Realm asks developers to use that flag.
Here is my Podfile:
platform :ios, '8.0'
use_frameworks!
target 'rothrock' do
pod 'Realm'
pod 'Cent'
pod 'SwiftyJSON'
pod 'Alamofire'
end
target 'rothrockTests', :exclusive => true do
end
I use no bridging header. Should I?
Any idea or workaround?
Alright, here is the full walkthrough:
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
You need a bridging header and import your Objective-C library headers there.
If you are using only Realm you can check out this documentation for Swift http://realm.io/docs/cocoa/ (go to CocoaPods down in the tabs)
Swift
Install CocoaPods 0.36.0 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'Realm' to your app target.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!
Download the latest release of Realm and extract the zip.
Drag the file at Swift/RLMSupport.swift into the File Navigator of your Xcode project, checking the Copy items if needed checkbox.
I just installed the Realm library in a project I have with some of the libraries you mention above like Alamofire and SwiftyJSON and others and it works fine when you build the project and even put the import Realm, no compilation errors at all.
I'm using Cocoapods 0.36.0, the stable version and this is my PodFile :
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
link_with 'ApiWorkflow', 'ApiWorkflowTests'
pod 'SwiftyJSON', '~> 2.2'
pod 'Alamofire', '~> 1.2'
pod 'Typhoon', '~> 3.0'
pod 'SwiftCSV', '~> 0.1'
pod 'Realm'
I hope this help you

Resources