iPhone 项目依赖管理

发布于 2024-11-19 19:43:18 字数 716 浏览 3 评论 0原文

有没有人成功地找到了一个可靠的、通用的解决方案来管理 iPhone 项目的依赖关系?我希望将 iPhone 应用程序拆分为可重用的组件,然后将它们拉入需要它们的项目中。我想我正在寻找 Maven 式的工作流程,但适用于 Xcode/iPhone 项目。到目前为止,我已经尝试了很多事情,例如:

  1. 我为 iPhone 应用程序创建了一个 Maven 插件,它可以自动构建和签名应用程序,但我总是觉得我与 Maven 进行斗争才能使其正常工作,这非常混乱。除非没有其他选择,否则我宁愿不使用它。

  2. 我还尝试使用静态库将代码打包以供重复使用,但这样做的问题是我还想在我的项目中包含可重复使用的 XIB 和图像,而这些不能包含在静态库中以供重新分发。它们非常适合代码,但我希望拥有一个可以完成所有操作的系统,而不是针对不同类型的依赖项使用不同的依赖项管理系统。

  3. 目前我已经决定使用版本控制系统来为我完成依赖项。在本例中,当我签出项目时,我使用 SVN externals 将依赖项加载到工作区中。

有人对我能做什么有任何想法吗?

更新

我现在使用 CocoaPods 来执行此任务。

Has anyone had any success in finding a reliable, generalised solution for managing dependencies for iPhone projects? I'm looking to split my iPhone applications up into reusable components and then pull them into projects that require them. I guess I'm looking for a Maven-esque workflow but for Xcode/iPhone projects. I've tried a number of things so far such as:

  1. I've created a Maven plugin for iPhone applications which automates the building and signing of the applications but I constantly feel like I'm fighting against Maven to get this to work and it is altogether pretty messy. I'd rather not use this unless there are no other options.

  2. I have also tried using static libraries to package the code up to re use but the problem with this is that I'd also like to include reusable XIBs and images in my projects and these cannot be included in the static library for redistribution. They are great for code but I'd like to have one system that does everything rather than different dependency management systems for different types of dependency.

  3. At the moment I've settled on using the version control system to do my dependencies for me. In this case I'm using SVN externals to load the dependencies into the workspace when I checkout the project.

Does anyone have any ideas as to what I could do?

Update

I'm now using CocoaPods to perform this task.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掐死时间 2024-11-26 19:43:18

我过去的做法如下:

  • 共享代码的静态库
  • 图像/数据文件/等的捆绑包(非代码)

通过这样做,您只需担心更新管理静态库的项目/ 捆绑,而不是使用它们的应用程序。

创建捆绑包的关键是,当向项目添加新目标时,捆绑包不会在 iOS 下列出。相反,它们列在 Mac OS X 下。别担心,它工作得很好。

创建 Bundle 和 Static Library 目标后,您需要将它们添加到您的应用程序中:

  • 在 Link Binary With Libraries (Xcode 4) 下添加 Static Library
  • 在 Copy Bundle Resources (Xcode 4) 下添加 Bundle

最后一件事要记住的是,当您想要从新创建的包加载资源时,如果要加载图像,则需要执行以下操作:

UIImage *myImage = [UIImage imageNamed:@"YourBundle.bundle/MyImage.png"];

The way I've done it in the past is as follows:

  • Static Library for shared code
  • Bundle for Images / Data Files / Etc (Non Code)

By doing this, you only ever have to worry about updating the project that manages your static library / bundle and not the applications that use them.

The key thing to creating a bundle, is that Bundles are not listed under iOS when adding a new target to a project. Instead they are listed under Mac OS X. Don't worry, it works great.

Once you've created your Bundle and Static Library targets, you'll need to get those into your application:

  • Add the Static Library under Link Binary With Libraries (Xcode 4)
  • Add the Bundle under Copy Bundle Resources (Xcode 4)

The final thing to keep in mind is that when you want to load resources from the newly created bundle you need to do something like the following if you were going to load an image:

UIImage *myImage = [UIImage imageNamed:@"YourBundle.bundle/MyImage.png"];

荆棘i 2024-11-26 19:43:18

使用静态库,您可以将 XIB/图像/字符串分发到可以轻松导入的捆绑文件夹中。这是我发现的最简单的方法来分发依赖项,而不是分发实际的 Code/Xcode 项目

With Static Libraries, you can distribute the XIB's/Images/Strings in a Bundle Folder which can be imported easily. It is the easiest approach I've found for distributing dependencies short of distributing the actual Code/Xcode Project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文