xcodecocoapodskiwi

Kiwi and CocoaPods with a static shared library


I have a workspace with 3 projects:

Common is a common library that MyApp depends on. I'd like to setup CocoaPods and Kiwi to work correctly in this project. How do I go about this?

I found https://stackoverflow.com/a/16472563/62, but when I try to follow this approach, I get an error when building MyApp before I even try adding Kiwi:

ld: library not found for -lPods

Here's the repo on GitHub: https://github.com/lyahdav/cocoapods_kiwi_shared_library

My Podfile is:

workspace 'MyApp.xcworkspace'
platform :ios, '7.0'

target 'Common' do
  xcodeproj 'Common/Common.xcodeproj'

  pod 'AFNetworking'
  pod 'Reachability'

  target 'MyApp', :exclusive => true do
    xcodeproj 'MyApp.xcodeproj'
  end
end

Solution

  • I finally found a working solution for this. Here's the Podfile:

    platform :ios, '7.0'
    
    workspace 'MyApp.xcworkspace'
    
    xcodeproj 'MyApp'
    
    pod 'CupertinoYankee', '~> 1.0'
    
    target :MyAppTests, :exclusive => true do
        pod 'Kiwi/XCTest'
    end
    
    target :Common, :exclusive => true do
        xcodeproj 'Common/Common'
        pod 'CupertinoYankee', '~> 1.0'
    end
    
    target :CommonTests, :exclusive => true do
        xcodeproj 'Common/Common'
        pod 'Kiwi/XCTest'
    end
    

    This example Podfile shows both MyApp and Common configured to use Kiwi for tests and they can both use pods (CupertinoYankee in this example).

    I did manually have to configure in Xcode that MyApp links with Common with these steps:

    1. In MyApp project settings > MyApp target > Build Phases > Link Binary With Libraries > add libCommon.a
    2. In MyApp project settings > Build Settings > User Header Search Paths > add ${SRCROOT}/Common/Common/**

    This repo has a working example: https://github.com/lyahdav/cocoapods_kiwi_shared_library

    The only slightly annoying thing I didn't manage to figure out was if there's a way to not duplicate each pod that I want to use both in MyApp and Common. If anyone has a solution that does all of what my solution does and solves that, I'll gladly mark it the accepted answer.