将静态库项目作为模块进行管理,例如Xcode4中的iOS项目上的Framework [英] Managing Static Library project as a module like Framework on iOS project in Xcode4

查看:101
本文介绍了将静态库项目作为模块进行管理,例如Xcode4中的iOS项目上的Framework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包括我在内的许多人都在尝试为iOS创建一种静态库框架,以归档某种模块化的模块.框架是执行此操作的最佳方法,但Apple并未提供框架,并且解决方法也不起作用.

Many people including me trying to make a kind of Static Library framework for iOS to archive some kind of modularity. Framework is best way to do this, but it doesn't provided by Apple, and workarounds don't work well.

https://github.com/kstenerud/iOS-Universal-Framework/tree/master/Fake%20Framework/Templates

  1. 无法在构建阶段的链接"标签中引用伪造的框架.
  2. 实际框架需要修改系统设置.而且仍然无法在每个部分上顺利运行.

问题是静态库需要头文件,并且如果没有脚本,就不可能在不同项目的另一个位置引用项目的头文件.而且脚本破坏了IDE的文件管理抽象.

Problem is static library need header files, and it's impossible to reference header files on project at another location on different project without some script. And script breaks IDE's file management abstraction.

如何像方便的模块方式那样使用静态库项目? (只需将项目拖到另一个项目中以完成嵌入)

How can I use static library project like a convenient module manner? (just dragging project into another project to complete embedding)

推荐答案

解决方案.

  1. 转到 Project Target 构建设置.
  2. 找到公共标题文件夹路径. (定义名称= PUBLIC_HEADERS_FOLDER_PATH)
  3. 将其设置为YourLibrary.framework/Headers.我已经使用${PRODUCT_NAME}.framework/Headers与项目名称自动同步.
  4. 转到构建阶段并找到 Copy Headers 步骤.
  5. 将所有必需的标题移到"公共"窗格中.
  1. Goto Project or Target's Build Settings.
  2. Find Public Headers Folder Path. (definition name = PUBLIC_HEADERS_FOLDER_PATH)
  3. Set it as YourLibrary.framework/Headers. I have used ${PRODUCT_NAME}.framework/Headers for automatic syncing with project name.
  4. Goto Build Phases and find Copy Headers step.
  5. Move all required headers to Public pane.

现在,所有头文件都将像 Framework 一样形成,并与产品二进制文件一起复制. IDE会将所有这些文件作为一个单元复制到一些临时文件夹(如应用程序的build文件夹)中.因此,引用应用程序项目可以自动使用标题.

Now all header files will be formed like Framework and copied with product binary. IDE will copy all of them as a unit into some temporary folder like app's build folder. So referencing app project can use the headers automatically.

这是一个把戏.创建的目录结构不是真正的框架.因为它不包含任何二进制文件.但是,我们不需要真正的框架来仅归档此功能. IDE与没有任何二进制文件的框架一起使用.而且我也不想在没有有关内部结构的文档的情况下破解IDE.

This is a trick. The created directory structure is not real framework. Because it doesn't contain any binary. However we don't need real framework to archive just this functionality. IDE works with frameworks without any binary. And I don't want to hack IDE without documentation about internal structure.

这很好用,但是存档时会遇到一些问题.发生这种情况是因为Xcode4在存档时表现特别.这是解决方法.

This works well, however you'll experience some problem when you Archive. This happens because Xcode4 behaves specially when Archiving. Here's workaround.

  1. 对于每个嵌入式库项目,在目标构建设置中SKIP_INSTALL = YES.
  2. 对于最终产品项目,FRAMEWORK_SEARCH_PATHS = "${OBJROOT}/UninstalledProducts".请注意,此设置应仅在Release构建模式下设置.
  1. For each embedded library project, SKIP_INSTALL = YES in target build settings.
  2. For final product project, FRAMEWORK_SEARCH_PATHS = "${OBJROOT}/UninstalledProducts". Take care about this setting should be set only for Release build mode.

现在它将被很好地存档.

Now it'll be archived well.

在跨平台库的情况下,可以有很多项目适用于许多平台.但是有时Xcode即使成功编译也会将某些产品显示为红色.

At the case of cross platform library, there can be many projects for many platforms. But sometime Xcode will show some product as red color even it compiled successfully.

这是Xcode的错误. IDE显示取决于 Project 构建设置的SDKROOT.因此,如果在 Target 上对SDKROOT进行不同的设置,则它将无法正常工作.您可以检查更改 Project 构建设置的SDKROOT后,产品将变为黑色.有关详细信息,请参见打开雷达"条目.

This is a bug of Xcode. IDE display depends SDKROOT of Project build setting. So if you set the SDKROOT differently on Target, it won't work. You can check the the product will become black color after changing the SDKROOT of the Project build setting. See this Open Radar entry for details.

http://openradar.appspot.com/9636211

如果您想修复此错误,请将其报告给苹果的Radar .重复的错误将引起Apple的注意.只需复制&粘贴我的报告:)

If you wish to fix this bug, please report this to Apple's Radar. Duplicated bugs will make attention of Apple. Just copy & paste my report :)

这篇关于将静态库项目作为模块进行管理,例如Xcode4中的iOS项目上的Framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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