Skip to content

Instantly share code, notes, and snippets.

@pdarcey
Last active July 29, 2021 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdarcey/a4e9858d9b96e0a6253ee1da79ac50de to your computer and use it in GitHub Desktop.
Save pdarcey/a4e9858d9b96e0a6253ee1da79ac50de to your computer and use it in GitHub Desktop.
Unhelpful Errors (mostly Command-line and/or Core Data related)

Core Data unhelpful error: Failed to load model named

CoreData: error:  Failed to load model named LocalStorage

importJSON2/UploadStoreData.swift:51: Fatal error: URL doesn't contain valid data

Illegal instruction: 4

Explanation

If the command-line command works when run from within Xcode but produces this error when run from the command line in a different folder, the problem is that the model it's looking for is stored externally from the command in the modelName.momd folder.

This will be present in the Xcode-produced Products/Debug folder but not in the folder you're trying to run it in.

Solution:

Copy the modelName.momd folder (complete with its contents) to the new folder and try again. Voila!

Core Data unhelpful error: URL doesn't contain valid data

Fatal error: URL doesn't contain valid data

Illegal instruction: 4

Explanation

I get this error when I try running a command to import JSON to Core Data but the import JSON file doesn't exist where I have said.

It's also possible that the file doesn't contain valid JSON. Check that too.

Solution:

Add/move the JSON file to where is should be

External framework seems to be missing

No such module *moduleName*

Explanation

You've added a package to the project in Xcode via Add Package, but when you go to use any of the modules in the package, the project/target won't even build and you get the error No such module.

You tear you hair out an scream at the computer, "It's right there! I just put it there! You just put it there when you added the package!…"

Solution:

Go to ProjectName Build Phases and expand Link Binary With Libraries and add the library there.

Yes, it seems that Xcode should do that, but it doesn't.

External framework seems to be missing

dyld: Library not loaded: @rpath/*name*.framework/Versions/A/*name*

Referenced from: /Users/.../Developer/Repos/abc/./importJSON

Reason: image not found

Abort trap: 6

Explanation

The @rpath is a clue: it means the command needs to use a framework that was complied with it but the rpath (i.e. run path) doesn't contain that framework. That's because Xcode doesn't automatically put it there.

Solution:

I moved the compiled name.framework from the Xcode-produced Products/Debug folder to /usr/local/Frameworks and in Xcode added LD_RUNPATH_SEARCH_PATH = /usr/local/Frameworks so the product can be run from any directory

Note: it is not necessary for the path to be /usr/local/Frameworks. It can be any path you want; you just have to be consistent with pointing LD_RUNPATH_SEARCH_PATHS to the path you moved/copied the framework to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment