Urkman
Urkman

Reputation: 1318

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

Upvotes: 7

Views: 1398

Answers (1)

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

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 !!!")
    }
}

Upvotes: 10

Related Questions