-
Hi, I'm new to Swift and trying to understand the project structure. In particular, I don't understand how the file /iOS/App.swift can import the module ComposableArchitecture? It doesn’t seem to be specified as a dependency anywhere for the isowords target - when I clone the repo I see the following as dependencies for the isowords target: I've tried to set up a minimal project (in Xcode 13.1) using the same basic structure of isowords, but when I import and use ComposableArchitecture in my /iOS/App.swift file, I get errors of the form: This might quite probably be due to a basic misunderstanding on my part of Xcode, SPM, Swift, but any help would be much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @oco-adam, the reason we can import ComposableArchitecture in App.swift (as well as all of these imports) is because Xcode/SPM picks up transitive dependencies. So, since AppFeature depends on ComposableArchitecture, and the app target depends on AppFeature, we get to import all TCA in the app target. |
Beta Was this translation helpful? Give feedback.
-
Hi @oco-adam, @mbrandonw beat me to it. I'll add that while isoword's dependencies are specified using SPM, they aren't specified directly inside Xcode, which is how most people are familiar with using SPM. Instead, isowords uses a (quite large) I have adopted the "isowords structure" in my own projects, and it sounds like you may be undertaking that task as well. I found Point-Free's video series covering isowords to be extremely useful in explaining the hows and whys of the isowords project structure, as well as many other aspects of the project:
Cheers! |
Beta Was this translation helpful? Give feedback.
-
Hi @mbrandonw and @gohanlon thanks very much for your quick replies! I wondered if this might be the case with transitive dependencies, so thanks for confirming this. However this confirmed to me that my App.swift should have already been using this dependency transitively. So following your answer, I just started to give details of my project because my App.swift was not picking up the transitive dependency from one of the modules from my "hyper-modularisation" package. However when started copying the Package.swift to describe here the details of my problem, I realised that maybe I needed to specify the dependency in two places, one in the dependencies property and once in the target property for MyApp?: So when I added the line
to my Package.swift (below), the transitive dependency got picked up and everything is working now.
So maybe my issue was caused by the need to always specify the dependencies in the Package.swift in two places. I did actually watch the videos @gohanlon refers to and maybe this was stated somewhere there, but I thought I'd post this here in case it helps out another Swift newcomer. Anyway, thanks for your help! |
Beta Was this translation helpful? Give feedback.
Hi @oco-adam, the reason we can import ComposableArchitecture in App.swift (as well as all of these imports) is because Xcode/SPM picks up transitive dependencies. So, since AppFeature depends on ComposableArchitecture, and the app target depends on AppFeature, we get to import all TCA in the app target.