Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with local CocoaPods and Swift

I try to integrate a local Swift CocoaPod into a Swift Project, but it will not work :(

I simply created a Swift project with just one class and one function. This should be the CocoaPod. Here is the Podspecs:

Pod::Spec.new do |s|
    s.name          = "CocoaPodTest"
    s.module_name   = "CocoaPodTest"
    s.version       = "0.1"
    s.license       = { :type => "MIT", :file => "LICENSE" }
    s.author        = { "Stefan Sturm" => "[email protected]" }
    s.source_files  = "src/*.swift"
    s.requires_arc  = true
    s.ios.deployment_target = '8.0'
end

And then I created another simple App, that should use the pod. Here is the Podfile:

platform :ios, "8.0"
use_frameworks!

pod 'Alamofire'

# local pods
pod 'CocoaPodTest', :path => '../CocoaPodTest'

Now I try to access the class included using the pod:

Import the Module:

import CocoaPodTest

Then call the class and function:

Foo.doIt()

But here I get this error:

Use of unresolved identifier 'Foo'

I made a github project to show this error:github

Thanks for your Help :)

Urkman

like image 582
Urkman Avatar asked Apr 16 '15 06:04

Urkman


1 Answers

Few points regarding Foo.doIt() (as in your repo at git hub)

  1. Your class is not public
  2. Your method is not public
  3. Your method is not class level method

Solve all these you are good to go

public class Foo {
    public class func doIt()
    {
        println("do it !!!")
    }
}
like image 129
Inder Kumar Rathore Avatar answered Oct 18 '22 21:10

Inder Kumar Rathore