Kiwi and CocoaPods with a static shared library

后端 未结 4 1531
轮回少年
轮回少年 2021-01-20 15:25

I have a workspace with 3 projects:

  • MyApp
  • Common
  • Pods

Common is a common library that MyApp depends on. I\'d like to setup Coc

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-20 15:43

    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.

提交回复
热议问题