While debugging mysterious memory management related crashes, I needed to write quite a lot of things into log. So much that log became unreadable.
Showing posts with label Xcode. Show all posts
Showing posts with label Xcode. Show all posts
Tuesday, May 17, 2011
Multiline NSLog Output and Other Debugging Tips
Labels:
debug,
MPMoviePlayerController,
NSLog,
Xcode
Monday, April 18, 2011
Operation failed with underlying error 4294956467
Thanx Xcode, that was very informative. I'll fix it right away! Oh wait, what was that...
Failed to launch simulator: Operation failed with underlying error 4294956467.
Monday, April 11, 2011
Easy Way to Create Settings View
Most applications need settings or at least a way to display version number. In theory it's very simple: just show a short list with a few hardcoded rows. It could be difficult, but since "settings" is such a common use case, Apple iOS SDK offers special support. It's not quite perfect, so let's check the possibilities.
Tuesday, November 23, 2010
Xcode 3.2.5 Base SDK Missing
Downloaded Xcode 3.2.5 and iOS SDK 4.2, installed and opened an old project. Got error note Base SDK Missing, as expected. Nothing to worry about!
Select project, press Command-i to view project info, find Build - Architectures - Base SDK and select the new "Latest iOS (currently set to iOS 4.2)". Close info - and nothing happens!
Select Targets and your application, press Command-i to view target info. You might have overwritten default project settings by mistake earlier. Check what is Build - Architectures - Base SDK. Should be same as you just defined for project. Close info - and nothing happens!
Close Xcode, reopen your project - and Base SDK is set! Didn't really expect this kind of new features with the update...
Update: No need to close Xcode, just toggle some settings via "Overview" popup at top left corner. For example change "Active Configuration" to Release and back to Debug. Usually that's enough, though sometimes target device has changed, too. Verify all "Overview" selections after you've done this.
Select project, press Command-i to view project info, find Build - Architectures - Base SDK and select the new "Latest iOS (currently set to iOS 4.2)". Close info - and nothing happens!
Select Targets and your application, press Command-i to view target info. You might have overwritten default project settings by mistake earlier. Check what is Build - Architectures - Base SDK. Should be same as you just defined for project. Close info - and nothing happens!
Close Xcode, reopen your project - and Base SDK is set! Didn't really expect this kind of new features with the update...
Update: No need to close Xcode, just toggle some settings via "Overview" popup at top left corner. For example change "Active Configuration" to Release and back to Debug. Usually that's enough, though sometimes target device has changed, too. Verify all "Overview" selections after you've done this.
Tuesday, November 16, 2010
Code Sign error: Provisioning profile can't be found
Check what is Info.plist Bundle Identifier, go to Apple iOS provision portal and download related App ID provision file and install. Note that if you're not Team Admin, you have to ask someone else to download the file for you.
Actual error code shows also cryptic mobileprovision id, but that won't help you much:
Actual error code shows also cryptic mobileprovision id, but that won't help you much:
Code Sign error: Provisioning profile '123456F8-1234-1234-ABCD-ABCDEFGH1234' can't be found
The executable was signed with invalid entitlements (install)
This is not the error with EXACTLY same error note you get during ad hoc release creation in Xcode (see here). This one comes, when you try to install that "successfully" created ad hoc release into device.
OPEN, no idea what went wrong or how to fix. Yet.
OPEN, no idea what went wrong or how to fix. Yet.
Team Provisioning Profile - Invalid. Renew button disabled
Team Provisioning Profile - Invalid. Renew button disabled.
Open Xcode Organizer, find Team profile and press Renew button. Automatically downloads Team Provisioning Profile, but only for apps with * App ID.
Open Xcode Organizer, find Team profile and press Renew button. Automatically downloads Team Provisioning Profile, but only for apps with * App ID.
Monday, November 15, 2010
Command /usr/bin/codesign failed with exit code 1
Select your project root in Xcode, command-i for Info, go to Configurations tab, delete old "Ad Hoc" configuration, duplicate Release and rename as "Ad Hoc". Rebuild and i installs and runs on connected device.
Problem might have been due space in name (even when it used to work earlier).
Problem might have been due space in name (even when it used to work earlier).
The executable was signed with invalid entitlements
Try to create ad hoc release in Xcode, got error note:
Case 2: make sure you have Entitlements.plist file in your project, containing just one prorerty called get-task-allow". This has to be off. Add name of this file into your project ad hoc release Code Signing Entitlements.
The executable was signed with invalid entitlements.Case 1: Go to Provisioning Portal - Provisioning - Distribution, find your project Distribution Provisioning Profile, Edit - Modify (do whatever and revert if everything already is right) - Submit - Download and double-click the file at your dev machine. Clean and rebuild.
The entitlements specified in your application's Code Signing Entitlements file do not matchc those specified in your provisioning profile (0xE8008016). [OK]
Case 2: make sure you have Entitlements.plist file in your project, containing just one prorerty called get-task-allow". This has to be off. Add name of this file into your project ad hoc release Code Signing Entitlements.
Labels:
debug,
distribution,
entitlements,
provisioning,
signing,
warning,
Xcode
Thursday, November 11, 2010
How to Undo Past Last Point
This is one of those things you do only once, thus easily forgotten. Did it for "my" machine, but now I'm a contractor using customer machine.
So how do I get rid of this annoying warning note, when I want to undo after saving a file:
So how do I get rid of this annoying warning note, when I want to undo after saving a file:
You are about to undo past the last point this file was saved. Do you want to do this?Open Terminal window and type:
defaults write com.apple.Xcode XCShowUndoPastSaveWarning NORestart Xcode and you're fine. Until next machine.
Thursday, August 26, 2010
How to Remove Unused Parameter Warning
No Warnings Policy requires sometimes forcing a compiler warning to be ignored. One such case is when you are given a function you absolutely must use, but don't need the parameters:
- (void)applicationDidFinishLaunching:(UIApplication *)applicationThere are several ways to ignore warnings, I found #pragma to be a clean solution.
{
#pragma unused(application)
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
Wednesday, August 25, 2010
Multiple Info.plist files and UIApplicationExitsOnSuspend
I have three Info.plist files: one for release (Info.plist), second for release testing (Info_release.plist) and third for testing (Info_test.plist).
In other words, I generate three separate applications from same sources so that all can be installed in a device at the same time. Therefore the content of plist files are identical, except CFBundleIconFile and CFBundleIdentifier.
When looking at Info.plist in XCode I can see "Application does not run in backgr" with a checkbox, while the two other plist files show UIApplicationExitsOnSuspend. Open all three files as source code or text and they contain exactly the same code:
In other words, I generate three separate applications from same sources so that all can be installed in a device at the same time. Therefore the content of plist files are identical, except CFBundleIconFile and CFBundleIdentifier.
When looking at Info.plist in XCode I can see "Application does not run in backgr" with a checkbox, while the two other plist files show UIApplicationExitsOnSuspend. Open all three files as source code or text and they contain exactly the same code:
<key>UIApplicationExitsOnSuspend</key>Weird... still everything seems to work ok. Just a note. Btw official documentation is available here.
<true/>
Thursday, July 22, 2010
Warning - No location found for "MyFile.m:42"
Debugger Console might show you something like this:
Warning - No location found for "GuestLoginNote.m:33"This is most likely a forgotten breakpoint in a file which doesn't exist any more. To get rid of the warning, please go to XCode menu Run - Show - Breakpoints. Locate the problem breakpoint and delete it.
Thursday, July 1, 2010
Class does not implement the 'NSStreamDelegate' protocol
Got this warning after upgrading to Xcode 3.2.3. To fix it add NSStreamDelegate into your class interface:
On Mac OS X 10.6 SDK (used by iPhone OS 4) delegate methods are generally defined in formal protocols rather than informal protocols as before, which means you have to declare the protocol conformance in the class interface of the delegate. More info at Mac OS X SDK release notes.
NSStreamDelegate is defined for Cocoa, but not Cocoa Touch. iPhone stream:handleEvent: is an informal delegate method.@interface MyClass: NSObject {}
@interface MyClass: NSObject <NSStreamDelegate> {}
On Mac OS X 10.6 SDK (used by iPhone OS 4) delegate methods are generally defined in formal protocols rather than informal protocols as before, which means you have to declare the protocol conformance in the class interface of the delegate. More info at Mac OS X SDK release notes.
How to target pre-iOS4 devices with latest XCode
Had a moment of confusion when upgrading to XCode 3.2.3. That version seems to support only iOS3.2 (iPad) and iOS4. Tried using previous XCode 3.1.3 for developing iOS3 software, just to get frustrated by non-backwards compatibility issues.
Use latest XCode 3.2.3. Set project Base SDK as iPhone Device 4.0 and iPhone OS Deployment Target as iPhone OS 3.0 - or anything as far backwards as iPhone OS 2.0.
Use latest XCode 3.2.3. Set project Base SDK as iPhone Device 4.0 and iPhone OS Deployment Target as iPhone OS 3.0 - or anything as far backwards as iPhone OS 2.0.
Thursday, June 24, 2010
Another reason for "Undefined symbols referenced from"
Failed to add a static library into my iPhone application. Doing everything I've done earlier, searching for new tips on internet, recreating static library project dozens of times - and still:
Undefined symbols:Finally found out that even though my version of TouchXML links to dynamic libxml2, I need to link libxml2 with application, too! Expected that once would be enough. Now wondering whether it really will be linked twice.
"_xmlDocSetRootElement", referenced from:
+[CXMLNode(CXMLNode_CreationExtensions) documentWithRootElement:] in libTouchXML.a
ld: symbol(s) not found
collect2: ld returned 1 exit status
Unexpected File Type 'wrapper.pb-project' in Frameworks & Libraries build phase
This is a XCode project dependency analysis warning and most likely means your project is missing something you expected to be there. There are similar warning notes for both build and link phases. More info at "Xcode's Plugin Interface".
It means that building or linking something failed, in this case ProtocolBuffers static library. Possible reasons are missing "Linked Libraries" and/or "Direct Dependencies" definitions or that building those failed.
Possible Fix: make sure your target (Info - General) has correct setup. If you're using Apple SDK 4.0 add -ObjC into "Other Linker Flags" and also -all_load to force loading of everything. Make sure you do this for both project and target. More info at Mac OS X Reference Library "Technical Q&A QA1490": Building Objective-C static libraries with categories.
warning: skipping file '/Users/jounimiettunen/svn_iphone/project/trunk/protobuf/ProtocolBuffers.xcodeproj' (unexpected file type 'wrapper.pb-project' in Frameworks & Libraries build phase)
It means that building or linking something failed, in this case ProtocolBuffers static library. Possible reasons are missing "Linked Libraries" and/or "Direct Dependencies" definitions or that building those failed.
Possible Fix: make sure your target (Info - General) has correct setup. If you're using Apple SDK 4.0 add -ObjC into "Other Linker Flags" and also -all_load to force loading of everything. Make sure you do this for both project and target. More info at Mac OS X Reference Library "Technical Q&A QA1490": Building Objective-C static libraries with categories.
Tuesday, June 22, 2010
Dereference of null pointer
XCode Build and Analyze command finds several "Deference of null pointer" warnings in some 3rd party sources.
Pointer with a possible value NULL is used like it always points to a valid memory area:
How to fix: check pointer value before trying to use it. Code safe.
Pointer with a possible value NULL is used like it always points to a valid memory area:
#include <stddef.h>
int *p = NULL;
*p;Trying to use a null pointer *p will cause undefined behaviour, depending on compiler and operating system. Reading from it might return garbage values, writing to it might corrupt memory somewhere else. Null pointer errors have also been used to go around security systems. Protected mode OSes usually stop the application trying to do such things, causing application to crash instead of the OS.How to fix: check pointer value before trying to use it. Code safe.
Monday, June 7, 2010
How to Make Instruments Show Your Own Code
Debugging memory leaks with Instruments. Great tool, but would be more useful, if I could see there references to my code.
Turned out it's a known iPhone OS 3.0 defect, almost two years old! No idea why it hasn't been fixed by Apple. Maybe old SDKs are not supported on purpose, which does make some business sense.
How to fix: Go to your Xcode project, select project info, go to Build tab and search Base SDK. Change your project Base SDK to 3.1. I had there 3.0, which seems to be a known defect.
Turned out it's a known iPhone OS 3.0 defect, almost two years old! No idea why it hasn't been fixed by Apple. Maybe old SDKs are not supported on purpose, which does make some business sense.
How to fix: Go to your Xcode project, select project info, go to Build tab and search Base SDK. Change your project Base SDK to 3.1. I had there 3.0, which seems to be a known defect.
- Build - Clean All Targets - select all - Clean
- Build - Build and Analyze
- Run - Run with Performance Tool - Leaks
- Stop
- Open popup item with application name - Launch Executable - Choose Executable
- Browse to your Build directory and select your application
- Record (the red Dot button)
Labels:
code,
debug,
Instruments,
iphone,
memory leak,
simulator,
source,
Xcode
Thursday, April 15, 2010
Problems removing breakpoints
If Xcode refuses to remove breakpoints, first close simulator and then save the source code file. After that Xcode starts to co-operator and nicely removes the breakpoint.
Subscribe to:
Posts (Atom)





