How can I work around "Xcode could not locate source file" - objective-c

I'm working with the ID3 framework in Xcode (which has since disappeared off the face of the web - including google cache!).
I'm testing out an import mp3 feature which allows them to edit the tags as they import them. One of the test cases is a corrupt or invalid mp3 with no proper id3 header. The problem I'm having is that when updating the tags of the invalid mp3 (updateFile:), the ID3 framework attempts to use id3V1Tag.m (I assume it falls back to this if it can't find the v2 tag) and this is where I get the Xcode error (whilst running the program, not building):
Xcode could not locate source file: id3V1Tag.m (line: 299)
Even in a release build this crashes the program, so it's not something I can really ignore.
I've tried putting a try/catch block around it but it's not treated as an exception so doesn't get caught. The function to load the tag data for the file returns a BOOL but it appears this only returns false if the given file doesn't exist, so this doesn't help either.
Current code:
[tagData release];
tagData = [[TagAPI alloc] initWithGenreList:nil];
tagsLoaded = [tagData examineFile:exportPath];
if(tagsLoaded) {
[tagData setTitle:title];
[tagData setArtist:artist];
[tagData setComments:comments];
#try {
[tagData updateFile];
}
#catch (id e){
NSLog(#"h");
}
}

The error you're getting is that Xcode is trying to locate your source file id3V1Tag.m in order to show it during debugging. No code you write will affect this.
If you don't have the id3V1Tag.m source file in your framework distro, there's nothing you can do about this, and there's little to do but ignore it (other than seeing if you can avoid causing it to be requested, like not setting a breakpoint in it, not stepping into it, and not crashing in it).
If you do have it, and are building it, then perhaps you're not building with the right debug information, so you'll have to tell us more about your build setup.

So the problem you're having is that your program is crashing when you attempt to compile id3V1Tag.m or while running the program. I'm a bit confused on that.
If its crashing while running maybe this is an issues with a code file missing from a library? How are you reading the ID3 tag information exactly? Is it through your own code or through a 3rd party library/class.

Related

stucked with errors when I try to build my old IOS app

We have an app which is published since 2016 and we need to update the code so when I opened the source code I got plenty of errors which I don't understand because we didn't change anything in source code.
following two example of the errors
_application = (AppDelegate*)[[UIApplication sharedApplication] delegate]; it shows an error of use of undeclared identifier but I already declare it above in source code
also we were using the uiwebview whihc is deprecated now how can we migrate to ‎WKWebView ?I attached an image showing an example of one of errors I am getting when building the project
The first error is saying "#end must appear in an Objective-C context". This suggests that there is a problem higher up in the source file. Have you imported "VideoDetailViewController.h", or is there possibly something wrong in THAT file?

Import UIKit for debugging Objective-C by default

Whenever I try to read the frame of an UIView for example while debugging, I get this error:
error: property 'frame not found on object of type 'UIView *'
error: 1 errors parsing expression
After searching for a solution, I found out that I can use this command to solve this without adding (annoying and in some cases complicated) casts:
expr #import UIKit;
But I still find it annoying to have to do this every time (why doesn't Xcode do this by default?!), so I thought I should be able to do this using the .lldbinit file, but I couldn't get it to work.
I don't know much about that file, I have this in it atm:
command script import /usr/local/opt/chisel/libexec/fblldb.py
so I tried adding the UIKit import command at the end of the file but it didn't look that it worked. I also tried prefixing it with command to no avail. Is this possible or not? (please say yes; it will save my life)
lldb will auto-import modules that the debug info tells us the program imports fairly soon now. All the pieces weren't in place to do that for the first Xcode 7 releases.
Statements in the .lldbinit get run before the main file is read in, it is supposed to help set up the environment to read in your program. But at that point there's nothing into which to import these symbols. You need to do it after the main binary is read in (and you really need to do it after you have run, since I think we need to run some code to do this.)
At present, the simplest way to do this is to make an auto-continue breakpoint at main, and attach the expr #import UIKit statement as a debugger command in that breakpoint. You'll have to do this once per new project you make, but if you're working on the same project for a while, it's not such an inconvenient workaround.

Smalltalk - collection is empty error when saving

Does anyone know what would cause this? I can't save anything to my class because I get a debugging exception thrown: Collection is empty
Link to source: https://dl.dropboxusercontent.com/u/1817765/Pharo%20Crash%20Files.rar
Steps to recreate:
Launch Pharo 1.1
Select the .image file, without the .changes file in the same directory
Attempt to select NumberWithUnits>>=
Crash
Attempt to save almost anything to NumberWithUnits
Crash
The issue was that I didn't have the correct .changes file associated with my project. Since my teammate and I were collaborating, these were lost in translation. Once I placed the correct .changes files in the directory of my .image file, everything worked out.
Squeak/Pharo have special handling in case of absent source code: they try and decompile CompiledMethod from appropriate MethodDictionary.
What you saw here is a failure of Decompiler to properly decompile some method.
Without code, the IDE is non functional, and you are stuck (you can't save your code, browse your code, debug your code...)
This Pharo 1.1 version is very old and you won't get any support on it.
But interestingly, the bug of Decompiler that you encountered is still present on current Squeak trunk development (4.5)
And the method that makes the Decompiler loosy is:
< aNumberWithUnits
(self compareUnits: aNumberWithUnits)
ifTrue: [self value: ((aNumberWithUnits value) < (self value) ifTrue: [^true] ifFalse: [^false]).]
ifFalse: [^Error new signal: 'Incompatible unit types.'].
This is a rather unconventional code since the message [self value: ...] will never be sent.
The reason is that the parameter will be evaluated first, and both branches of the condition will return ifTrue: [^true] ifFalse: [^false].
Since you explored some dark corner that only newbies do explore, and that we failed to test, I'd just say thank you.
If you feel like it, you can open a report on http://bugs.squeak.org

libxml2 on iOS causing EXC_BAD_ACCESS errors when parsing HTML with HTMLParser

I've been working on a project that uses libxml2 HTMLParser module to parse webpage HTML on iOS. I'm getting an EXC_BAD_ACCESS error from libxml2's htmlParseDocument whenever I try to parse a webpage that contains the line:
<?xml version="1.0" encoding="UTF-8"?>
If I strip this line out of the HTML, parsing works perfectly.
Also note, I am using the DTHTMLParser class to bind the libxml2 SAX callbacks to Objective-C code.
Since EXC_BAD_ACCESS in htmlParseDocument isn't much to go on, I've built a sample Xcode project that reproduces the error. I made it in Xcode 4.4 on Mountain Lion targeted for iOS 5.1. First it parses an HTML file that doesn't contain the offending line, then it attempts to parse the document with the offending line and crashes. You can download it here: http://michaelmanesh.com/code/libxml2-crash.zip
The problem in DTHTMLParser was that apparently the method to prepare the c-callbacks in libxml did not set the function pointer for the function to call when a processing instruction is encountered to NULL. Because of this the processing instruction caused libxml2 to try to call a function at some random address causing the EXC_BAD_ACCESS.
I fixed the problem in DTHTMLParser by implementing support for an optional delegate method to be called for when a processing instruction is encountered or NULL in the handler struct if this is not implemented in the delegate.
I think LibXML mistakenly picks it up as a processing instruction which has nearly identical syntax. Libxml treats every line that has <? in it as a processing instruction. Though I can't quite pinpoint exactly what is going wrong. If you remove the question marks, it will parse as a regular element and you will get the attributes in the parser:didStartElement:attributes: callback method. If you put a space in between the question mark and the xml (<? xml) it will come back in the parser:foundCharacters method. I don't know what your requirements are, but those are two ways to make it not crash.

CCLabelBMFont crashing due to a missing image message

I'm getting an exception saying that the image cannot be nil on this line:
CCLabelBMFont *label = [CCLabelBMFont labelWithString:#"5" fntFile:#"weaponnumbers.fnt"];
What am I doing wrong? Am I supposed to specify the PNG somewhere different? I have it at the root of the project.
-(CCTexture2D*) addImage: (NSString*) path
{
NSAssert(path != nil, #"TextureCache: fileimage MUST not be nill");
Is weaponnumbers.fnt included in your target? E.g. is it compiled into the project?
Also, I think it's unlikely you're getting an exception here - you're probably getting an exception somewhere inside one of the calls made by this call. Try breakpointing the line before, and using the "Step In" breakpoint tool to step through the call stack and find the true nature of the exception.
I find Cocos2D exceptions to be pretty self-explanatory, when you can eventually get down to the right level of where the exception is actually being thrown.
A delete add and clean fixed it.
NSString stringWithContentsOfFile failing with what seems to be the wrong error code