CDPieMenu (cocoapod) in swift - ios

I'm trying to add CDPieMenu to my swift project using a .podspec gist I found here.
I downloaded the podspec locally & added it to my podfile like so:
pod 'CDPieMenu', :path => '~/Documents/Project/CDPieMenu.podspec'
Here's the podspec:
Pod::Spec.new do |s|
s.name = 'CDPieMenu'
s.version = '0.1'
s.license = 'MIT License'
s.summary = 'Fully and easily customizable rotary wheel control also called pie menu for iPhone and iPad.'
s.homepage = 'https://github.com/wczekalski/CDPieMenu'
s.author = { 'W. Czekalski' => 'me#wczekalski.com' }
s.source = { :git => 'https://github.com/wczekalski/CDPieMenu.git', :commit => '2f49362' }
s.source_files = 'Wheel'
s.description = 'Fully and easily customizable rotary wheel control also called pie menu for iPhone and iPad.'
'Very similar to the control in Convertbot. As the only one in the internet it rotates with inertia/mementum.'
'Drawn using CoreGraphics without any images.'
s.platform = :ios
s.frameworks = 'AudioToolbox', 'QuartzCore'
s.requires_arc = true
end
I ran pod update and everything worked fine and it seems to have been installed.
However, I'm unable to reference it from my project files now.
Did I miss something?
EDIT 1:
I forgot to mention I have already setup a bridging-header and added CDPieMenu headers to it.
Project-bridging-header:
#import "CDCircle.h"
#import "CDCircleGestureRecognizer.h"
#import "CDCircleOverlayView.h"
#import "CDCircleThumb.h"
#import "CDIconView.h"
#import "Common.h"
EDIT 2:
I just checked and it seems the pod isn't installed at all. There isn't a CDPieMenu in the Pods directory.
But pod update didn't throw any errors.

Try "pod install" instead of "pod update".
EDIT:
And don't forget to open your project using the .xcworkspace file.

I had two problems here, one of which I was able to resolve using #whatever38's suggestion, i.e. I was using pod update instead of pod install.
The other problem was that I needed to specify the path to my podspec file in my Podfile. I was doing this by specifying the :path => parameter, whereas I should've instead used the :podspec => parameter.
So, my Podfile entry for CDPieMenu should look like so:
pod 'CDPieMenu', :podspec => '~/Documents/Project/CDPieMenu.podspec'

Related

Xcode Workspace - Not finding imports from framework development pod

I've set up a workspace with two Swift projects in it: one a framework I'm developing, the other a demo app for the framework.
Podfile looks like this:
platform :ios, '9.0'
workspace 'foo.xcworkspace'
target 'framework' do
project 'framework.xcodeproj'
end
target :'demo' do
project 'demo/demo.xcodeproj'
pod 'framework', :path => 'framework.podspec'
end
the .podspec file looks like this:
Pod::Spec.new do |s|
s.name = 'framework'
s.authors = { "foo author" }
s.version = '0.1.0'
s.summary = 'foo summary.'
s.homepage = 'foo homepage'
s.platform = :ios, '9.0'
s.license = {
:type => "Proprietary",
:file => "LICENSE"
}
s.source = {
:git => 'https://url.to/foo.git',
:tag => s.version.to_s
}
s.source_files = 'framework/framework/**/*.{swift,h,m}'
s.requires_arc = true
s.weak_framework = "XCTest"
s.pod_target_xcconfig = {
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"',
}
end
After running pod install, Xcode/AppCode can still not see the classes from the framework project. So if I add a manual import to a class in the demo app and try to compile, it fails with:
Error:(13, 21) use of undeclared type 'FooClass'
What do I have to do to properly have the demo app project see the classes from the framework project generated pod?
Try using inherit! :search_paths on the demo target
This means they don't get their own copies of the pods but can see they exist via the header files.
platform :ios, '9.0'
workspace 'foo.xcworkspace'
target :framework do
project 'framework.xcodeproj'
end
target :demo do
inherit! :search_paths
project 'demo/demo.xcodeproj'
pod 'framework', :path => 'framework.podspec'
end
untested but perhaps worth a shot
If you install a Cocoapod don't use the file with .xcodeproj to open your project anymore, but the newly created .workspace in the same folder.
I finally resolved this issue:
Make sure the min. required iOS is defined in Podfile, e.g.:
platform :ios, '10.0'
Add any third-party pods also to the podspec file, e.g.:
spec.dependency 'Alamofire', '~> 4.5'
spec.dependency 'Serpent', '~> 1.0'
If doing pod install without the use_frameworks! it will mess up some things (see this answer: ld: framework not found Pods). So in between I got these invalid Pod xconfigs that I had to delete and then do a clean and pod install.
Make sure to build the framework project at least once and then the demo source should find the import to the framework pod name!
Make sure that all classes are correctly added to their target, especially classes in the test target should not have been added to the app target accidentally.
After all is said and done, having worked with a multitude of IDEs and development technologies, Xcode and Cocoapods can only be summed up as one giant clusterf*** of an accident!

Cannot Lint/Push a Swift Cocoapods podspec

I tried to create my first podspec combining ObjC and Swift code, but I soon stumbled uppon a stubborn error that I cannot solve while uploading
Copying MyLibrary from /Users/lukasschwoebel/Library/Caches/CocoaPods/Pods/External/MyLibrary/540307feb534d63ad9015f3f6452b3ad-be661 to
../../../../../../private/var/folders/2p/_pc_vts51b3_pfydgm7_2n200000gn/T/CocoaPods/Lint/Pods/MyLibrary
- Running pre install hooks
-> MyLibrary (0.1.0)
- ERROR | [iOS] Encountered an unknown error (Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add use_frameworks! to your Podfile or target to opt into using it. The Swift Pod being used is: MyLibrary) during validation.
Here is the command I use:
pod repo push test-podspecs MyLibrary/MyLibrary.podspec --use-libraries --allow-warnings --verbose
As you might see, this is the minimum untouched sample project from CocoaPods as described here: https://guides.cocoapods.org/making/using-pod-lib-create.html
As I can not even make this sample running, I suspect something wrong with my cocoapods configuration.
I made sure there is no single Objective C line in the pod that is to be uploaded (though in the end, I would like to have a podspec with ObjC and Swift code mixed, but at this time I just want to have a working podspec with Swift).
I cannot even upload this simple pod with pure Swift. I first tried with CocoaPods v0.39.0, then downgraded to 0.38.2 and after that 0.38.0, even 0.36.0. Even with a complete un-install of CocoaPods.
It seems I need to configure something in CocoaPods to be able to upload a Swift podspec? The error I get obviously is during the building-phase of the pod where the Podfile needs use_frameworks! to be included. So how can I make CocoaPods use it while compiling the pod during the podspec verification?
Also, I have Xcode 7.0.1 and OSX 10.10.5 installed and it is Swift 2.0 code.
Thank you in advance!
Here is the complete podspec, adapted from the original created MyLibrary.podspec (and yes, that is a local Podspec-Repo, but that does not cause/change the error)
Pod::Spec.new do |s|
s.name = "MyLibrary"
s.version = "0.1.0"
s.summary = "A short description of MyLibrary."
s.description = 'Sample Description'
s.license = 'MIT'
s.author = { "Luke A." => "ls#mymail.to" }
s.source = { :git => "file:///Users/.../test/MyLibrary/", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'Pod/Classes/**/*'
s.resource_bundles = {
'MyLibrary' => ['Pod/Assets/*.png']
}
s.frameworks = 'UIKit'
end
I just found the answer, which seems a little obvious.
The command to upload/push the pod was in a bash-script so I did not always have to type all the flags but just and over the filename/path to the podspec. So in the default bash-script I had the flag --use-libraries which is required for one of my pods.
As I was trying something out and had a typo in the pod repo push .. command I stumbled across the man-page:
--use-libraries
Linter uses static libraries to install the spec
With static libraries, this flag seems to be incompatible with Swift podspecs. Removing that flag lints and pushes my podspec successfully.

How to check podfile version added to Xcode project?

I am using RestKit, it uses different podfiles.I want to know which is the podfile version used in that sample app.And also want to know how to update podfile via terminal?
Question 1:
If the pod is installed, Go to the info.plist file of the pod and there you can see the version of the installed pod.
Question 2:
To update podfile via terminal, open podfile using
vi podfile
Click "i" and then you can edit or insert an item in podfile. To save the changes, Use
click esc then :wq!
Run pod update to update the changes.
Question 1
you can learn this in project's podspec file. For your case it's RestKit's podspec :
Pod::Spec.new do |s|
s.name = 'RestKit'
s.version = '0.24.1'
s.summary = 'RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X.'
s.homepage = 'https://github.com/RestKit/RestKit'
s.social_media_url = 'https://twitter.com/RestKit'
s.author = { 'Blake Watters' => 'blakewatters#gmail.com' }
s.source = { :git => 'https://github.com/RestKit/RestKit.git', :tag => "v#{s.version}" }
s.license = 'Apache License, Version 2.0'
...
...
...
When you use in your Podfile like this :
pod 'RestKit'
it'll automatically get latest released version!. For your case it's this line in project's podspec file :
s.version = '0.24.1'
but if you want to decide which version you want to installed with this line :
pod 'RestKit', '~> 0.24.0'
Question 2
you can update pods with this command :
pod update
Hope everything is clear now.

Using dependency in swift module (framework)

I am trying to create a swift module (Cocoa Touch Framework) with reusable code inside the environment set up by cocoa pods which includes third party libraries written in Objective-C (namely here Restkit).
Unfortunately I am not able to use Restkit in the module I create.
Here's what I did to create the module:
File -> New target: Cocoa Touch Framework, Language: Swift, Project: MyProject, Embed in Application: MyProject
In the "Info" tab of the project settings in the "Configurations" section I define the Pods.debug and Pods.release xcconfig file for my newly created target.
In the header file, which Xcode automatically created for me, networkModule.h, I add the following line:
#import <RestKit/RestKit.h>
Result: When trying to compile I get the error "include of non-modular header inside framework module 'networkModule'"
I have set the flag for "Allow Non-modular Includes in Framework Modules" to YES in the build settings for the Project Target and the Module/Framework target.
I went to the Cocoa pod project and have tried setting the visibility of the RestKit.h Header file to "Public" in the target membership (which of course is not a good solution to mess with the cocoa pods environment)
I am not able to compile. I still get the same error.
Is it possible in the first place to create a Cocoa Touch Framework with dependencies to a cocoa pod managed framework?
Btw. My first idea of creating a private cocoa pod didn't work out as well, as it doesn't seem to be supported, although I am using the prerelease of cocoa pods 0.36 with support for swift.
You should be able to make your won private Pod. You just need to make a podspec for it. Here is an example of one.
Pod::Spec.new do |s|
s.name = "Commons"
s.version = "1.0.0"
s.summary = "Common code for my iOS projects."
s.license = {:type => 'Commercial', :text => "Copyright (c) Dan Leonard(Or Your Name?). All rights reserved." }
s.source = { :git => "https://github.com/PATHTOPOD", :tag =>
s.version.to_s }
s.homepage = "https://github.com/PATHTOPOD"
s.requires_arc = true
s.ios.deployment_target = '9.0'
s.subspec 'Core' do |ss|
ss.source_files = '*.swift'
end
s.subspec 'Menu' do |ss|
ss.source_files = 'Menu/*.swift'
ss.resources = ['Menu/*.storyboard', 'Menu/*.xcassets']
ss.dependency 'Alamofire'
end
end
Then Inside your project you just have to do pod init open your podfile that was just created and add this
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'YOURPROJECT.xcodeproj'
platform :ios, '9.0'
use_frameworks!
pod 'Commons', git: 'https://github.com/PATHTOPODPROJECT'
#pod 'Commons', :path => '/Users/YourUser/Path/To/Project/commons'
pod 'KeychainSwift'
pod 'SQLite.swift', git: 'https://github.com/stephencelis/SQLite.swift.git'
Now in this example Podfile Commons is stated twice the second is commented out. If you uncomment it and comment out the first then do pod install in your projects folder from the terminal. This will make a DevelopmentPod which is a pod that is local. This way you can make changes to the pod locally within Xcode. No switching and pod installing every time you make a change.
You will import the pod just like any other by putting
import Commons not #import <Commons/Commons.h> That is how you do it in Objective C not Swift
Once you have a working version commit it to git hub and point your project to the the github version.
Hope this helps.

Podspec validates but files are not installed

I'm in the process of writing my very first pod spec, and while I have managed to write a spec that passes validation and pod installĀ seems to install the pod OK the actual source-files are nowhere to be found in my workspace. This is my podfile:
platform :ios, '7.0'
xcodeproj 'NORLabelNodeiOStest'
pod 'NORLabelNode', :path => '~/Programmering/Development/NORLabelNodePodSpec'
pod 'AFNetworking'
As you can see the NORLabelNode pod is installed through a local version of the podspec which looks like this:
Pod::Spec.new do |s|
s.name = "NORLabelNode"
s.version = "0.9.2"
s.summary = "Extension of Apple's SKLabelNode. Allowing multiple lines through the use of \n in the text-string. "
s.description = <<-DESC
Behaves like an ordinary SKLabelNode with the one difference that adding newline characters to the text- property actually adds line-breaks. This is achieved by creating SKLabelNodes as child-nodes, but keeping these as part of the internal (private) logic.
DESC
s.homepage = "https://github.com/nickfalk/NORLabelNode.git"
s.license = 'MIT'
s.author = { "T. Benjamin Larsen" => "benjamin.larsen#noreagle.no" }
s.source = {
:git => "https://github.com/nickfalk/NORLabelNode.git",
:tag => 'v0.9.2'
}
s.social_media_url = 'https://twitter.com/noreagle'
s.platform = :ios, '7.0'
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.requires_arc = true
s.frameworks = 'SpriteKit'
s.source_files = 'NORLabelNode.{h,m}'
end
Running pod install gives no indication that anything has gone amiss:
Analyzing dependencies
Fetching podspec for `NORLabelNode` from `~/Programmering/Development/NORLabelNodePodSpec`
Downloading dependencies
Installing AFNetworking (2.2.3)
Installing NORLabelNode (0.9.2)
Generating Pods project
Integrating client project
[!] From now on use `NORLabelNodeiOStest.xcworkspace`.
The AFNetworking pod installs the files as expected, but my own NORLabelNode does not. Anyone?
As you can see the NORLabelNode pod is installed through a local version of the podspec which looks like this
That's not how the path option works. It expects a path to the project itself, not the spec.
From the docs:
Using this option CocoaPods will assume the given folder to be the root of the Pod and will link the files directly from there in the Pods project.
If you would like to just use your spec without adding it to the master repo you can create your own repo of specs (docs). Or just place your spec in the correct folder structure in ~/.cocoapods/repos/master

Resources