Let's say I have a UIImage that I'm setting for a UIButton. I want to look at it in Quicklook. But oh no:
There's no way for me to quick look debug what the image is.
But I could do something from LLDB to get the image, like [getAppButton imageForState:0] (well, I could if it wasn't for the undoManager bit but that's not neither here nor there), but is there a way to quicklook that?
I'm not sure when this was introduced, but in Xcode 6.3.2 you can right click on the left panel in the debug area and choose Add Expression.... This pops up a text field where you can put in any arbitrary LLDB expression. After entering it, you can invoke quick look on the expression just like any other local variable in that pane.
You can also reference variables defined in LLDB, for example if you were to type:
(lldb) e UIImage *$img = [button imageForState:0]
You can then reference that $img as the expression in the left pane.
I don't think it is possible. At least I could not find a suitable command in Apple's documentation.
The only way I can think of, is modifying your code to assign the image in a UIImage variable and quick look that...
In Xcode 5.1, you can now add a method:
- (id)debugQuickLookObject
to any object and the returned value will be used for QuickLook. So in your case, you could subclass your button, and return your image.
You can now do that using chisel's visualize lldb command. It's very straightforward to set up, and it's a debugger super-power that's particularly handy if you work with images a lot.
Once you've installed chisel, update your ~/.lldbinit file and restart XCode. Then create a new breakpoint and add an action that uses the command to inspect an UIImage1.
Under the hood, the new python based lldb command writes the image buffer into a timestamp-based PNG file under /tmp/xcode_debug_images and then call system command open to use the default app to open up the image.
Keep in mind that lldb holds a strong reference to the data. So during your debug session, your app might appear to leak RAM. Remember to turn the breakpoint off when you are done.
Also, if you have a lot of images, you may not want to open them up all in Preview, which will freeze itself with more than 100 images. Comment this line off, and you should be fine:
https://github.com/facebook/chisel/blob/main/commands/FBVisualizationCommands.py#L60
On my M1 mac, the file is installed into /usr/local/opt/chisel/libexec/commands/FBVisualizationCommands.py
Related
[![enter image description here][1]][1]I Tried all possible setting manipulation of xcode, even i cleaned xcode app from my mac and then reinstalled too, but still no luck, But Breakpoints works on almost all calsses except some , later on breakpoint navigator i noticed classes on which breakpoint not working are marked RED. I am wondering what is the actual cause ?
Update : After i removed ad added that specific file the red mark are gone, but result is not improved !
I see red text color labels so probably you have deleted files.
If your files exist and you dont see any breakpoint stopped in your class simply it's because your project probably crash before arriving in this class or by-pass it. Check who call DriveCreateAccountVC in your code and put some breakpoints before this class is called in the code, Im pretty sure you find your mistake.
It's a good attitude use the debug console by printing your flow in your code like this line for example: (you can put in viewDidAppear or viewDidLoad)
print("∙ \(NSStringFromClass(self.dynamicType))")
it's a little help but print the class name where are your flow in this moment. You can go also on the debug console and writing for example:
po myStringArray.description
po myStringArray.count
Another useful thing is to add these two options in your editing settings (it's not in defaults settings) : (line numbers and code folding ribbon)
A class becomes Red, when it has lost its path(Xcode can't locate the class)
This may happen because you maybe you copied flies from one project to another or something like that:
There are 2 solutions:
Before anything, locate the files in your Finder
Solution 1) Find the files and put them in your project directory.
Solution 2) Click the file in red in your Project Navigator
Then click on the button (showed in the image link above, to the right of tweetCell.swift)
Once you click it, you will get a chance to locate the file, do it.
I have a question about Xcode (Swift). Sometimes when I write an if statement. Something like this:
if(a == 2){
//do Sth
} else {
//do Sth
}
Xcode throws me an error: "Invalid character in source file"
I know it is no big deal and fixed by clicking on "Fix-it" but I want
to know what is the problem. That doesn't make sense to me...
My Xcode is on 7.2 and I am using Swift - I don't know if this is just a Swift problem.
For me it's the ESC key - it's completely reproducible! If I go to search and hit ESC in the search window I also find the occurrences marked - and can replace those with nothing. But it's not shown even with "Show invisible"!
final solution: Bind ESC keybinding to "Cancel". It's that simple.
I was having this problem. The way I solved it is by 1) copying whatever you have into Sublime Text or another code editor and having a look (you may need to enable viewing hidden characters). Mine had a code in there DC2 which is some sort of ASCII control character. For me it was caused by the fact that I had put the playground into manual execute and bound a keyboard shortcut to it that seemed to be entering that control character every time I executed it using the shortcut. I just changed the shortcut and removed the ASCII characters as I was able to see them in Sublime Text. (The link in the comments to the OP concerning left to right mode made no sense and didn't work for me.)
I encountered this problem when I was using a non-Apple keyboard with my iMac. Probably your case too. They add unnecessary control characters! One way to fix it in Xcode ischoose from the menu Editor>Show Invisibles and see if there are any unwanted characters where the error is being thrown and remove them.
Editor->Show Invisibles did not show the character that was causing a problem for me. No-break-space (u00a0) will be shown as a space with no "dot" indicator. However, that's really hard to see and I completely missed it the first time. Zoom helps.
One way I found to detect invalid characters is to use Visual Studio Code and enable the settings:
"editor.renderControlCharacters": true
"editor.renderWhitespace": "all"
This has the same visibility issue with no-break-space as Xcode, however it does show other special characters.
To make it more obvious and possibly detect more invalid characters, install the extension "ascii-unicode-escape" and follow the instructions.
I don't understand why Xcode allows these invalid characters, inserts them into your source files for no reason, and doesn't even give an option to detect them! I'm trying to write code, not secrets in invisible ink, damnit!! I guess it's less of an issue for compiled code, which will show an error, but not so convenient with shader code.
I'm having the same issue. I found a solution after extensive testing. Hopefully it could save others extensive hours of researching into this terrible Xcode experience.
The problem is I have a FILCO Minila keyboard, which has the 'App' key right next to 'left arrow'. I would accidentally hit 'App' when typing really fast, and it enters a 'DEL'(Data Link Escape, Unicode 0010) invisible character. It could only be seen when copy-pasted to Sublime. It's not even visible under Xcode's own 'Editor -> Show Invisibles'(Talking about good user experience...)
Magically this doesn't happen to Sublime or VSCode, only to Xcode. So no excuses for Xcode I guess?
The fix is to download Karabiner, an advanced keymapper for macOS, and invalidate the 'App' key or map it to something else. Karabiner would also invalidate your keymapping in the system default keyboard config. So you would have to remap stuff like 'cmd', 'alt' if you've customized them. If so, be sure to map both left & right modifier keys in Karabiner, because according to Karabiner's key event viewer, the system default keymap would map left_alt & left_cmd to right_cmd and right_alt... Just annoying as hell...
It took me 2 months to realize this problem and 2 hours to actually find out it's the 'app' key that's the culprit and fix it.
I'm using XCode 10.1.
With Xcode: Xcode does not help even after showing invisibles.
Then you can copy the code to Sublime Text => you will see these invisible characters which are the <0x0f>. Click the image to see in details.
With Sublime Text 3, it works!
=> Then you know where to remove the redundancies. Hope that helps!
Are you using the option ⌥ key for any keyboard shortcuts? This was my issue. It seems combining the option key with other keys can insert hidden characters.
For me, this happened when I used the ⌃+⌥+p shortcut in Xcode to resume the SwiftUI preview canvas. It added a 0x10 character. I discovered this, as other posters have recommended, by pasting the code from Xcode into Sublime Text.
(NB: I should have been using ⌘+⌥+p).
I've searched around and can't find anything on this.
Using Swift 2 and Xcode Version 7.0.1 (7A1001). Every time I execute something in the debugger console, Xcode crashes.
The project is not very big, and has less than 10 third party frameworks.
I can't think of much more information that's relevant, but I'm sure there's more, so please do ask me if there's anything I should add to my question that would help.
I've of course cleaned build and derived data.
It's driving me insane. Thanks!
UPDATE 16/11/12
Submitted rdar://23559366.
How are you maintaining your third party frameworks? Via Carthage?
If so then this is probably your issue: https://github.com/Carthage/Carthage/issues/924
This is an issue if the location of the /Carthage/Build/iOS folder is in a different location to where it was produced (i.e if it was compiled on a different machine and the absolute file path has changed).
A temporary fix would be to run carthage build --no-use-binaries on your machine to rebuild the symbols using the current absolute file path working around the bug.
But if you wasn't using carthage then its probably not your issue so sorry
I had similar problem with Xcode whenever I hit breakpoint.
In case you see this screen right before your Xcode crashes - you are lucky and my fix might save you. All you need to do is open this window and in the Project Navigator, select any file that you want, so that instead of that white blank view you would get your code. After this you are most likely will be able to successfully stop your app at your breakpoint and perform the debug.
I am not sure why this happens, but I suspect that the reason is Debug View Hierarchy mode, which you might have triggered prior to setting you breakpoint and trying to stop at it. At least this is when it happens to me.
I have similar problem earlier.
If you try to print non-optional variable and unfortunately it holds nil value then it breaks/crash. so that make sure declare all possible variables as "Optional type".
I'm trying to include this barcode source code by Stefanhafeneger to my project. I started it with a simple camera example and the barcode engine, everything works fine for the 1st barcode decode. When I try with the 2nd times, i receive EXC_BAD_ACCESS. It only work 1 time after that the application will crash.
Here is a screen recording of how the appilcation crash.
i'm testing with this DataMatrix tag from google in my appilcation.
i was surfing for solution for few days, I had tried NSZombieEnabled, and debug with Instrument but i still have no luck with it. The image below is the error from xcode.
*** -[Not A Type retain]: message sent to deallocated instance 0x7b21ed0
For your information it is an ARC enabled project. Someone please help, I'm still a few months old beginner.
Here is my xCode file for this project Barcode-Datamatrix Project
Update : I also tried disabling ARC for every file related to that library by Using the linker flag -fno-objC-arc but the result still the same. Besides i tried imageView.image = [UIImage imageWithCGImage:image.CGImage]; or a copy imageView.image = [image copy]; the application still crash at the same place.
Many Thanks
Kin
[Not A Type retain] indicates that you are passing an object that is not a UIImage to the UIImageView's image property, then the method attempts to discern it's type to send retain at the imagevVew.image = image line. NSLog it's type with NSLog("%#", NSStringFromClass([image class]));
EDIT: I Do Not recommend that you convert such an old project to ARC (and I quote: "It is linked against ios 2.1"). Use the linker flag -fno-objC-arc and disable ARC for every file related to that project. Afterwards, check that your imageView isn't funky, try setting your image to nil, or delete the line altogether and run.
It may that BarCode Engine would not ARC enabled.
to disable some files which are not design for ARC support we can show to compiler that let it be ARC disable through this command
-fno-objc-arc
put this command on project build phases where all compiled source present ( i.e. all class in your project name will show)
ZBarSDK is quite simple and easy to use and more powerful API for this barcode, qr code decoding.
Xcode 3.2 showed me the values of variables. Now in Xcode 4.2 when I debug and it stopped in a scope, I can't see the values of variables anymore. The variables view on the lower left side contains almost nothing useful except the memory adress of an object. When I click the expand-arrow nothing appears there. It's empty.
Must I setup something to make the debugger work properly?
Xcode 4 is very finicky with variables in the debug window. You'll probably find that locally defined primitives (ints, floats, strings, etc) will display but nothing else will.
I know its not much help but I usually just add an 'NSLog()' and print the variables I am trying to debug. Not as convenient but it gets the job done.
If anyone else knows a permanent fix id also be grateful.
If you right click in the lower left view you can select "Add Expression" and type the name of the variable.
Why Xcode cannot display this information when hovering over is a mystery to me.