Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removed Realm, but still getting this error: module importing failed: invalid token (rlm_lldb.py, line 37) File "temp.py", line 1,

I tried using Realm with Cocoapods in a project two years ago. Realm didn't work out, so I removed it. Cocoapods didn't work out, so I eventually removed that as well and switched to Carthage.

With the advent of Xcode 11, I started seeing this error:

error: module importing failed: invalid token (rlm_lldb.py, line 37) File "temp.py", line 1, in <module>

It didn't seem to cause any crashes, so I stupidly ignored it. Last night I ran an app on an iPod Touch Generation 6 running the latest iOS 12 (12.4.3). The app crashed with this error.

I realized then that I was getting this error for every app on every device, including the simulator.

I tried going back and re-ran all of the code to remove CocoaPods, and it seems like it is really removed.

There are still some Realm files on my computer, most notably:

~Library/Application Support/Realm/rlm_lldb.py

~Library/Application Support/Developer/Shared/Xcode/Plug-ins/RealmPlugin.xcplugin

When I delete those files (by renaming and moving them), I still get an error every time I run any app on any device:

error: module importing failed: invalid pathname

Something is still looking for those files, but it doesn't even know their name. So I put the files back, and I am back to the original error.

EDIT: It was suggested that this is the same issue as: Remove Realm Model Object from Xcode

I do not have the Realm Object Model in my Xcode, even though I am getting the same error. The solution to that question did not address my situation at all. There is another comment that may be helpful to this issue, and that is to edit ~/.lldbinit. But there is no explanation of how to edit ~/.lldbinit or suggestion that it worked at all.

I actually think that editing ~/.lldbinit might help, but I have no idea how that might be done.

like image 595
SAHM Avatar asked Nov 28 '19 14:11

SAHM


1 Answers

Uninstalling and reinstalling Xcode did not solve this issue for me.

As per the unaccepted answer in this question,

Remove Realm Model Object from Xcode

I needed to edit ~/.lldbinit. To be honest, I don't completely understand what this file is. It is not easy to get to or to edit.

I found this tutorial from Ray Wenderlich,

https://www.raywenderlich.com/612-custom-lldb-commands-in-practice

found my way to the editor, highlighted the offending line,

command script import "~/Library/Application Support/Realm/rlm_lldb.py" --allow$

removed the text, and exited, choosing to save upon exit.

When I re-opened Xcode, cleaned, built and ran an app, the error was gone.

I don't feel great about this. I don't know if I did the right thing. I hate doing things in the Terminal that I don't understand.

EDIT: I raised this issue to Realm, who had also suggested around the same time that the issue might be with lldbinit. After I edited the file and stopped seeing the error, I shared the steps I took to fix the problem with Realm. It was confirmed to me that that was the right thing to do. Additionally, please see the comment from Jay below about how he was able to solve this issue:

For future readers, interestingly enough, I was able to duplicate this issue but the solution was different. I was able to delete the files showin in the original question, then clean and run the project. THEN, clean and rebuild again and it seems to be working. Both files appear to be circa 2016.

While this did not work for me, I want to include it in this answer because I think it would be good to try this first if you are having this issue.

like image 56
SAHM Avatar answered Oct 09 '22 03:10

SAHM