简体   繁体   English

将现有的iOS应用程序项目拆分为静态库和应用程序外观项目

[英]split an existing iOS app project into static library and app skin project

I would like to split an existing iOS app project into one static library and one app project. 我想将现有的iOS应用程序项目拆分为一个静态库和一个应用程序项目。

Since the existing app project has been copies multiple times into brand new instances with different resources(graphics, icons etc) and settings. 由于现有应用程序项目已多次复制到具有不同资源(图形,图标等)和设置的全新实例中。

I find it's hard to maintain across difference instances once the core project has been updated. 我发现一旦核心项目已更新,就很难在不同实例之间进行维护。

So i'm turning the core project into a static library with model, views and third party libraries. 因此,我正在将核心项目变成具有模型,视图和第三方库的静态库。

the other project contains the app part which only contains customised resources and app settings. 另一个项目包含应用程序部分,该部分仅包含自定义资源和应用程序设置。

the problem is how can the classes in the static library getting the app settings from the app project and the main app project calling classes in the library. 问题是静态库中的类如何从应用程序项目中获取应用程序设置以及库中的主应用程序项目调用类。

any good practise and tools for that? 有什么好的做法和工具吗?

The main app project can make use of your static library classes through exported header (.h) files. 主应用程序项目可以通过导出的头文件(.h)使用静态库类。 I would recommend reading a bit about them here: 我建议在这里阅读一些有关它们的信息:

http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html

And creating the static library here: 并在此处创建静态库:

http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/ http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/

As for providing the app-specific settings to your static library, it sounds like your static library might need to contain a ApplicationSettings protocol or similar, that can be provided to the static library for any calls that require it. 至于向您的静态库提供特定于应用程序的设置,听起来您的静态库可能需要包含ApplicationSettings协议或类似协议,可以将其提供给静态库以供需要它的任何调用使用。 Your protocol could define getters/setters for any known properties your application possesses. 您的协议可以为应用程序拥有的任何已知属性定义获取器/设置器。

@protocol ApplicationSettings

- (BOOL)isUserReallyAwesome;
- (void)setIsUserReallyAwesome:(BOOL)awesome;

@end

Then you can either configure an instance of this object statically, or you can provide to each static library method that requires it: 然后,您可以静态配置此对象的实例,也可以向每个需要它的静态库方法提供:

- (void)someStaticLibraryMethodWithArg:(NSString *)arg settings:(id<ApplicationSettings>)settings { ... }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM