2

I'm trying to split in modules a big XCode project. I have a main project and one submodule as an embedded framework.

I need to import some classes from the main project into the subproject but no success. I added the subframework in the embedded binaries and in the Linked Frameworks of the parent's project target. Moreover I added in build settings "Header Search Path" in the parent project the path of the subframework.

https://i.stack.imgur.com/WRH25.png

Any help would be appreciated

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ferufab
  • 21
  • 4
  • What is your question? – Taras Chernyshenko Feb 27 '18 at 12:37
  • @TarasChernyshenko My problem is I want to import a class of the parent project in the subproject, but when I try it I get 'use of unresolved identifier' because the subproject couldn't find it. I don't know what could be wrong – ferufab Feb 27 '18 at 12:45
  • I understood your problem, but what do you want from us? Please, edit your post to make clear what is your question is, add code that will help us to understand a problem. Without that I think nobody will be able to help you – Taras Chernyshenko Feb 27 '18 at 12:48
  • You can't do what you are asking, because you are trying to "access" an object that is not part of your framework. What type of "access" are you going for? In general, a "lower class" should not know anything about a "higher (parent) class" to begin with, so trying to do that from a sub-project / framework is a wrong approach anyway. – DonMag Feb 27 '18 at 13:45
  • @DonMag Thank you very much for your answer, I would like to access to the parent project class to get static properties and methods which are common for the project. In this case, if subproject or framework is not possible to do that, do you know what could I do? – ferufab Feb 27 '18 at 13:51
  • @ferufab - the *parent* should tell the *child*... so, if you have values which are "common for the project" you either need to keep the classes in the same project, or you need to define "default" values for those properties, and let the "parent" set the actual values when it loads the "child class". Much like a simple `UIButton`... ***its code*** does not try to "get the title, color, frame, etc" from the parent - it needs the parent to set those values. – DonMag Feb 27 '18 at 14:19
  • @DonMag Thank you very much, I'll try to set shared properties from the parent to the subproject – ferufab Feb 27 '18 at 18:22

1 Answers1

0

You can't. Also it meaningless because if you separate some pieces of your code into framework it means that this code doesn't have any dependencies with other code. So if you have any case when your framework need to import some class outside you have only two ways:

  1. Include it inside framework.
  2. Refactor framework's classes and try to remove dependencies.
Alexander Zakatnov
  • 1,646
  • 1
  • 15
  • 16