带有静态共享库的Kiwi和CocoaPods [英] Kiwi and CocoaPods with a static shared library

查看:60
本文介绍了带有静态共享库的Kiwi和CocoaPods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3个项目的工作区:

I have a workspace with 3 projects:


  • MyApp

  • Common

  • Pods

Common是MyApp依赖的公共库。我想设置CocoaPods和Kiwi在此项目中正常工作。我该怎么办?

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?

我发现 https:// stackoverflow。 com / a / 16472563/62 ,但是当我尝试采用这种方法时,在构建MyApp时出现错误,甚至没有尝试添加Kiwi:

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

的库GitHub: https://github.com/lyahdav/cocoapods_kiwi_shared_library

我的Podfile是:

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


推荐答案

我终于找到了一个可行的解决方案。这是Podfile:

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

此示例Podfile显示MyApp和Common都配置为使用Kiwi进行测试,并且它们都可以使用Pod(此示例中为CupertinoYankee)。

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

手动必须在Xcode中配置MyApp与Common链接,这些步骤如下:

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


  1. 在MyApp项目设置> MyApp目标>构建阶段>链接$中b $ b带库二进制文件>添加libCommon.a

  2. 在MyApp项目设置>构建设置>用户标题搜索路径>添加 $ {SRCROOT} / Common / Common / **

  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/**

此仓库有一个有效的示例: https://github.com/lyahdav/cocoapods_kiwi_shared_library

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

我所做的唯一有点烦人的事情我无法弄清楚是否有一种方法可以不复制我要在MyApp中使用的每个Pod nd Common。如果有人能解决我的问题并能解决我的问题,我会很乐意将其标记为可接受的答案。

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.

这篇关于带有静态共享库的Kiwi和CocoaPods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆