0

I am currently developing a swift framework for my iOS class.

Here is the project structure : project structure

I would like to test my class named SimpleCoreData, but when I go to the generated ESGISimpleCoreDataTests file, the import (also generated) isn't accepted:

Cannot load underlying module for 'ESGISimpleCoreData'

So I checked this other topic, and verified the targets, but everything seems fine.

framework: build phases
tests build phases:

I am beginning in Swift, so I may have missed something obvious. Can you please help me with this one?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
CodingMouse
  • 63
  • 14
  • Try nuking your derived data and rebuilding. Another suggestion would be to try adding `@testable import ESGISimpleCoreData` to the top of your ESGISimpleCoreDataTests.swift file. – Adrian Jan 31 '18 at 00:26
  • @Adrian the generated test file already imports ESGISimpleCoreData this way. What do you mean by "nuking your deriving data" ? – CodingMouse Jan 31 '18 at 08:50
  • https://stackoverflow.com/questions/38016143/how-to-delete-derived-data-in-xcode-8 – Adrian Jan 31 '18 at 11:55

2 Answers2

1

Finally, after examining each commit to see where it breaked, it turns out that the problem was probably coming from a unit test file I created, which had the same issue (probably didn't created it correctly), and then only removed its references instead of moving it to trash.
So I went a commit backward, used the default unit test file generated, and it worked.

CodingMouse
  • 63
  • 14
  • 1
    Just want to add some information here. I had the same issue, and did the same as you and it got fixed. What I did after hours was opening Finder and finding if there was any folder or file remaining. I found a "ProjectTest" folder with no files inside. I just removed it and everything got fixed. – J Manuel Jan 25 '19 at 10:29
0

Here's another variation on this theme.

I imported a folder of files into my main project, and in that folder was a file which had import XCTest in it.

The compiler didn't flag this problem, and I didn't see it until I used finder (like CodingMouse).

Once I moved this testing file to the UITests folder and changed its "Target Membership" to the UITests Module, I did a clean and build to get everything working again.

So the takeaway from this is the compiler won't always point you directly to the actual problem. Using finder, scan through your files and confirm nothing looks suspicious or out of place.

Mozahler
  • 4,958
  • 6
  • 36
  • 56