13

Im making a static iOS framework. I want to use 3rd party code, lets use AFNetworking as an example, in my framework. AFNetworking is popular. I can sense the namespace collisions now. What is the best practice here? As far as I understand I have 3 options:

1) Build AFNetworking into my framework, exporting the headers. This lets clients use the version of AFNetworking in my library, but they can't use other frameworks that also link AFNetworking. They rely on me for updates to AFNetworking if they build on it.

2) Code against the AFNetworking Headers, but make the third parties include AFNetworking in their projects. This adds an extra step for framework consumers, they have to add AFNetworking source. There may be version incompatibilities in the future, but at least if another framework uses AFNetworking they can use that at the same time.

3) Re-namespace AFNetworking and keep the headers private. This way I avoid namespace collisions in any way, except that it then becomes really hard to update my copy of AFNetworking. The final binary gets a bit bigger but all interoperability issues are resolved. This is a lot more work for me.

Do I have any other options? What are the best practices?

4

2 に答える 2

6

より良いオプションはhttp://cocoapods.orgを使用することです。このようにして、ライブラリの依存関係を宣言し、プロジェクト全体の単一のダウンロードを取得することができます。

ヘッダーの名前を変更しないでください。時間と手間がかかります。

PD:これのサンプル:

http://chariotsolutions.com/blog/post/using-cocoapods-to-manage-private-libraries/

于 2013-02-27T17:11:28.703 に答える
0

番号 3 に関する限り、「名前空間の変更」については完全ではありませんが、それに似ています。

http://atastypixel.com/blog/avoiding-duplicate-symbol-issues-when-using-common-utilities-within-a-static-library/

于 2014-03-23T23:35:53.513 に答える