How to structure a Xcode project with Frameworks, Extensions and CocoaPods

≡放荡痞女 提交于 2019-12-03 02:59:15

问题


NB: Here is a more abstract and simplified sub-set of this question.

With the addition of Touch Frameworks, Extensions and the Apple Watch Xcode 6 projects and workspaces are getting more and more complex.

If you add CocoaPods into this mix things start to get almost unmanageable.

How would I structure an Xcode project/Workspace with the following targets and dependancies? (Assumptions: I am using Git for all the components, I am using CocoaPods for all third party code, I am using Xcode 6).

  • MyCoolApp
    • Several 3rd Party UI libraries via CocoaPods
    • MyCoolNetworking.framework, a framework (project) I created as a Git Sub-module
      • AFNetworking via CocoaPods
      • Other data processing code via CocoaPods
    • MyCoolAppBusinessLogic.framework, used by app and all extensions (below)
      • Includes some code from CocoaPods common to app and extensions
    • MyCoolToadyView, a TodayView Extension target
    • MyCoolWatch, an Apple Watch extension target

As you can see this is a complex structure including a couple of CocoaPods instances. Any advice on how to solve any or all of these issues will be helpful.

(My plan is to write up some of my own ideas and then synthesise an answer from everyone else, this will no doubt be a living document).


回答1:


More of a comment than an answer, but I don't have enough reputation for it: Have you tried using the cocoapods xcode plugin? I use it and it structures the pods on its own, so I don't even have to worry about it.




回答2:


I really think that you can use Cocoapods to create your workspace in this case, because it really helps you out, and you can add the components you want to each one of your own frameworks.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

workspace ‘Project.xcworkspace'

target 'Project.Models’ do
xcodeproj ‘Project/Models.xcodeproj’
pod 'Alamofire', '~> 2.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

end

target 'Project.Business' do
xcodeproj ‘ Project/Project.Business.xcodeproj’

pod 'Alamofire', '~> 2.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

end

For example here is one example in how I manage to handle multiple Frameworks with multiple dependencies and resolve it into one main workspace that has all the dependencies for 3rd party libraries for each one of my projects

Hope this gives you a Hint or help you to resolve something.



来源:https://stackoverflow.com/questions/28086512/how-to-structure-a-xcode-project-with-frameworks-extensions-and-cocoapods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!