Search code examples
swiftxcodecocoapodspodspec

getting error: use of undeclared type when I push pod to private cocoapods repo


I can successfully build, run my tests schemes. I tried pushing changes to my pod's repo by doing:

pod repo push my-private-cocoapods Device.podspec --allow-warnings --verbose

Yet I get the following error:

- ERROR | [Device/Phone] xcodebuild:  Device/Phone/Classes/Views/StackProvider.swift:13:42: error: use of undeclared type 'MacAddress'

Yet MacAddress is a public type.

I've restarted my mac, cleaned build, cleaned derive data, but I still get the same error.


Solution

  • The problem was a combination of:

    • One of subpods had a dependency on another subpod which was from the same pod
    • I was not running pod lib lint. I was relying on a test scheme and was just running tests through Xcode on the vanilla example app.

    Basically my Device/Phone subpod was dependent on Device/Core subpod. I needed to update my Phone podspec. Currently it's like this:

    s.subspec 'Core' do |subspec|
        subspec.dependency 'RxSwift', '~> 4.5.0'
        subspec.dependency 'RxCocoa', '~> 4.5.0'
        subspec.source_files = 'Phone/Classes/*.{h,m,swift}', 'Phone/Classes/**/*.{h,m,swift}'
        subspec.test_spec 'Tests' do |test_spec|
          test_spec.source_files = 'Phone/Tests/*.swift'
        end
      end
    
      s.subspec 'Phone' do |subspec|
        subspec.dependency 'RxSwift', '~> 4.5.0'
        subspec.source_files = 'Phone/Classes/*.{h,m,swift}', 'Phone/Classes/**/*.{h,m,swift}'
        subspec.resources = 'Phone/Classes/*.{xib}', 'Phone/Classes/**/*.{xib}'
        subspec.test_spec 'Tests' do |test_spec|
          test_spec.dependency 'Device', '~> 1.0.7'
          test_spec.source_files = 'Phone/Tests/*.swift'
        end
    end
    

    The only thing I had to add was a new dependency to my Phone spec's dependency list:

    subspec.dependency 'Device/Core',
    

    And then I was able to do push my new spec.

    pod repo push my-private-cocoapods Device.podspec --allow-warnings --verbose