1

I'm developing an App and I wanted to separate in 'subprojects', because, although some parts have the same name, they have distinct functionality... I've tried this feature (subproject), but it seems that I can't reference files (like storyboards) from a subproject... So, what's the point of a subproject if you can make it work together with the project base?

Thanks a lot...

asked Oct 23, 2017 at 16:47
7
  • 1
    You can try to create new target for your purposes. You can specify different implementation to different parts. For example you can create two files named the same (or not), add one to first target and the second file to other target. Then add in both files the method with identical naming, but different implementation. Call this method from somewhere. Now you have two apps with different flows that have shared source files, storyboards, assets, etc. Note that app can not see files which are not added to target. To build specific target you should select required scheme on top panel. Commented Oct 23, 2017 at 18:56
  • That's kind what I'm looking for... Can I have one storyboard reference to storyboard from another target? I'm trying that but it's not working... Thanks a lot for your help! Commented Oct 23, 2017 at 19:00
  • 1
    Two different targets are two different scopes. So you should manage this reference from your code. Also you can create two different storyboards with same naming and use it in one file added to both targets. The trick is that these storyboards will be in different targets, but the file which would instantiate them was added to both targets, and it really should't care about which of targets is launched. Commented Oct 23, 2017 at 19:07
  • 1
    >and both can access my BASE models right? - Yes. >I want to make a "link" to Main.storyboard from LOGIN target, and later, from LOGIN to DASHBOARD... Is that possible? - No, it is not. To get access to any file it should be added to target Commented Oct 23, 2017 at 19:17
  • 1
    No, because it is not in its scope. For example if you will not include header file in objective-c, you will not be able to use its methods. It is out of the scope of another one. If you want tho see one storyboard from another - they should be it same scope, that means - in one target. P.S. Not everything should be handled directly from interface builder, and it's ok :) Commented Oct 23, 2017 at 19:24

1 Answer 1

2

Subprojects are generally used for independent, reusable code, mostly libraries and frameworks. They aren't usually used for organizing parts of a single project.

In Swift, subprojects can be useful for creating modules, but again this isn't commonly done except for independent, reusable code (mostly libraries and frameworks....)

If you're trying to access storyboards in another module, you've probably broken the "independent" part. It is rare to organize UI elements this way, and definitely isn't something you should do in your first project. Once you have some experience working in a larger project, you can explore novel ways of organizing it, but to start, just keep a single project.

This makes me a bit nervous:

although some parts have the same name, they have distinct functionality

They probably should have different names then.

answered Oct 23, 2017 at 16:52
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Rob... About this: "although some parts have the same name, they have distinct functionality" I mean, I have two forms for example, but they are different... I would love if we have explicit namespaces in Swift...

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.