How to access a third party framework from My.Framework?

江枫思渺然 提交于 2019-12-24 01:28:31

问题


Steps to understand my problem:

1) I created a framework (My.framework)

2) Added My.framework as a subproject to MyApp.xcodeproj.

3) Then I ran cocoapod for adding AFNetworking on MyApp.xcodeproj.

4) Now, I open MyApp.xcworkspace.

5) While trying to access AFNetworking from classes in My.framework. It is not accessible.

P.S. I am not talking about "umbrella framework". (Umbrella framework is where we add a framework as a framework of sub project.)(Correct me here if I am wrong)

I just want to access AFNetworking while it is still out of the My.framework


回答1:


Add a podspec for your framework and include necessary dependencies such as AFNetworking.

 pod spec create

Then include your podspec in app's Podfile.

Ps: You don't have to publish your podspec, you can use it locally.




回答2:


In my case , this is working.

Adjust Public Header files in Target-> Build Phase-> Copy Headers. We can set the header file visibility here.

Refer more : https://stackoverflow.com/a/27638841/3901620




回答3:


Another Way

whenever you don't use pod then use this.

IN Objective C

1) Import or simply Copy (drag and drop) AFNetworking or any other class which you use in your project.

2) Import it where you use.

Done now you can access it.

In Swift

You just import or copy third party class or framework in your project you don't need to import it where you use.



来源:https://stackoverflow.com/questions/40039378/how-to-access-a-third-party-framework-from-my-framework

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