3
votes

I currently have 3 Embedded Frameworks in my project:

  • PersistenceLayer (Swift only)
  • TransportLayer (Swift Only)
  • Socket (Objc)

Both PersistenceLayer and Socket don't reference anything outside themselves. However TransportLayer imports PersistenceLayer and Socket. Oddly, I can use PersistenceLayer objects after importing:

import PersistenceLayer

struct User : Model {
  ...
}

Model is defined in PersistenceLayer and Xcode lets me use it per normal. However, when I try to build TransportLayer, I get the error: No such Modul 'Persistencelayer'. So Xcode recognizes the module is there, but somehow "looses" it when it builds.

What's maddening is that this used to work. At some point something changed and I can't figure out what. It's important to note that I work on a project with multiple developers and I have merged in changes. However switching to a commit prior to the merge didn't work. I've also tried:

  • Adding $(SRCROOT) (recursive) to Framework Search Paths
  • Deleting everything out of ModuleCache directory
  • Clean project
  • Clean Build Folder

I suspect that something changed in my project settings but I can't figure out what and I've checked the git diffs didn't help (there nothing that really changed in the project aside from the normal file additions.

Also, TransportLayer does successfully import and use Socket. I can build the TransportLayer if I remove references to PersistenceLayer but keep all the references to Socket.

Does anyone know why this might be occurring or how to fix it?

Update

Ok, so I removed the "offending" files from the target to make sure Socket was working (it is) and then re-added the files to the target (quite literally by resetting git). It now builds... cause that makes sense. But I tried changing the Scheme from iOS Device to a simulator and it no longer builds, but I'm getting different errors:

  • in module.modulemap: HeaderPersistenceLayer-Swift.h' not found`
  • Also: Could not build Objective-C module 'Persistence Layer'

This feels like I'm chasing down random errors...

1

1 Answers

3
votes

I figured out the answer: Open up Build Phases in the TransportLayer target and manually add PersistenceLayer and Socket to Target Dependencies. This ensures the that anything TransportLayer depends on will be built before it is.

I had a hunch that the original reason iOS Device scheme was working was because I had removed the offending files, allowing everything to build properly, including PersistenceLayer which was cached. After adding the imports back into to the project it continued to work because PersistenceLayer didn't need to be built anymore. Other Schemes didn't work because PersistenceLayer wasn't built for those architectures. I confirmed this by cleaning again and the builds failed. After some searching around, I found Target Dependencies and added my two dependencies there. Everything now builds properly in all schemes and all architectures.

My project probably had been working fine until now because it was working with cached Frameworks that had been built prior to me actually using them: (I built PersistenceLayer before I began work on TransportLayer). I probably cleaned the project sometime recently, which deleted the cached frameworks and caused the issues.