how do i add a dependency to realmswift in my packageswift file?

Many thanks to @iUrii for providing a second pair of đź‘€ !!

As I said, I was close. As often happens on StackOverflow, you ask one question, and, more importantly, a different issue gets answered. The answer is my Package.swift was correct and

âś… this is how you include RealmSwift in your own package.

  • I want to explain what I had to do in order to get this to work.

The tools were providing me with inconsistent, unhelpful error messages. The first thing to remember is that your configuration may be ok but some of the code in your package doesn’t compile correctly. And the compiler may not flag your error.

  • In my case the “Issue Navigator’ was not showing any errors, but the package wasn’t building.

In the navigator console (toggle cmd-0 a couple of times in Xcode and you’ll know what area I’m talking about), at the very top there’s a row of icons. The rightmost one (it looks like a list on a page) is the “Report Navigator”. Tap on that and you’ll see a list of builds and cleans. Every time you try to rebuild your project (cmd-b) a new entry appears at the top. Always work with the topmost one. Things magically fix themselves at one point, and break again at another. So concentrate on the problems it finds right now.

shift-cmd-K to clean your build folder. Tap on the header that appears. Do you see a “Clean succeeded” message preceded by a round ✅ icon?. You’re not good to go until you can get that far. Come back to this checklist when you do.

Once you’ve gotten this far you should have some confidence that your configuration file is correct. That’s actually a big deal, and should bolster your confidence to continue.

At this point what’s preventing you from completing the build should appear in the build report. Go ahead and type cmd-b, wait for it to finish, and tap on the top entry of the list (the latest build report) in the Report Navigator on the left. Hopefully, on the right side of the screen you’re seeing “Prepare Build”, a round ✅ Workspace followed by your workspace name at the top of the report.

Below that is a section called Build Target. The report lists each file it compiles, or tries to compile. Starting at the top, and skipping the ✅ files, open the first file you see with a ! inside a gray circle. This is a file the compiler has an issue with. Those red 🅧 and 🛑 (with a white circle in the center) items need to be fixed. They might be defined perfectly, but in a file or class or struct or method that didn’t compile cleanly, so it isn’t recognized by the compiler. (maybe there’s an import statement that’s not — or is no longer — valid/needed) Start at the top and resolve each of these. If the file it’s in has other errors while you’re fixing the problem, fix those too. They’re probably immediately below this error on the report anyway… once the editor is happy with the file, save and build. (cmd-b) At this point you should have one less file in error, and the error count has gone down. Along the way, if you add a missing file you might find the counts going up instead of down. Don’t be discouraged, just keep working down from the top error in the list until there aren’t any more.

Happy to report that after following this process I am now able to cleanly build the package with multiple imported frameworks. (currently at 66 files and growing)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top