Xcode 4 templates don't work in iOS 3.1.2 - objective-c

I would like to test my app for older phones, and got one with 3.1.2. But when I try to run it, it just show the splash screen and then crash.
Then I tried to make a new Hello World view-based app from Xcode 4 templates, but even with this one it build fine but crash on startup. I set deployment target to 3.1.
If i try to run this one with iPad 3.2 simulator, it also crashes.
Where can the problem be?
When i run it on iOS device, it gives this warnings and then just stop, not really crash:
warning: UUID mismatch detected with the loaded library - on disk is:
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1/Symbols/System/Library/Priv
UPDATE:
I found that I earlier had made a shortcut from 3.1.2 (7D11) to 3.1.2 in the DeviceSupport folder for some reason. I removed that and now I don't get the warnings anymore. Just a crash ;)
0 gdb-arm-apple-darwin
0x000000010010974a internal_vproblem +
308 1 gdb-arm-apple-darwin
0x0000000100109924 internal_verror +
27 2 gdb-arm-apple-darwin
0x00000001001099c2 align_down + 0 3
gdb-arm-apple-darwin
0x0000000100150c5e macosx_solib_add +
794 4 gdb-arm-apple-darwin
0x000000010016417c
remote_macosx_complete_create_or_attach
+ 187 5 gdb-arm-apple-darwin 0x000000010016489e
remote_macosx_create_inferior + 1252 6
gdb-arm-apple-darwin
0x000000010005f6c3 run_command_1 + 586
7 gdb-arm-apple-darwin
0x0000000100107b7f execute_command +
557 8 gdb-arm-apple-darwin
0x00000001000171e7
mi_execute_async_cli_command + 204 9
gdb-arm-apple-darwin
0x00000001000168e5
captured_mi_execute_command + 344 10
gdb-arm-apple-darwin
0x0000000100072a62 catch_exception +
57 11 gdb-arm-apple-darwin
0x000000010001443e mi_execute_command
+ 140 12 gdb-arm-apple-darwin 0x0000000100077721 process_event + 133
13 gdb-arm-apple-darwin
0x0000000100078435 gdb_do_one_event +
1049 14 gdb-arm-apple-darwin
0x0000000100072b49 catch_errors + 70
/SourceCache/gdb/gdb-1518/src/gdb/macosx/macosx-nat-dyld.c:1648:
internal-error: unrecognized shared
library breakpoint A problem internal
to GDB has been detected, further
debugging may prove unreliable.
When i run iPad simulator, it crash on this line in HelloWorldAppDelegate.m:
self.window.rootViewController = self.viewController;
with this message:
2011-04-21 11:46:09.006 HelloWorld[5492:207] * -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x4c11bb0
2011-04-21 11:46:09.007 HelloWorld[5492:207] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x4c11bb0'
UPDATE:
This was solved by this:
// self.window.rootViewController = self.viewController;
[self.window addSubview: [self.viewController view]];

Use [window addSubview: [myRootViewController view]]; instead of [window: setRootViewController: myRootViewController]; in your app delegate.

I was having the exact same problem as you, and every app I created from an Xcode 4 template would give me the error you describe. By looking at some of the sample code included with Xcode 4's online documentation, I discovered that it works on an iPhone 3G running 3.1.3 if I replaced
self.window.rootViewController = self.navigationController;
with
[self.window addSubview:self.navigationController.view];
That did it for iPhone running 3.1.3.

Related

Old iOS6 app is now crashing when trying to open in iOS8

I'm trying to fix a legacy app (hasn't been updated to iOS7 or above. Still shows iOS6 UI). Whenever the app tries to open, it crashes. I found the problem at the didFinishLaunchingWithOptions method when I set the tab bar controller.
[self.window setRootViewController:self.tabBarController];
I get this error:
CRASH: *** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array
This is the Stack Trace:
2014-09-27 01:08:35.517 AppName[2919:1348769] Stack Trace: (
0 CoreFoundation 0x233dde57 <redacted> + 150
1 libobjc.A.dylib 0x30a8bc8b objc_exception_throw + 38
2 CoreFoundation 0x232f2e9d CFRunLoopRemoveTimer + 0
3 AppName 0x000940eb -[NSArray(UtilityExtensions) firstObject] + 46
4 UIKit 0x2694a93d <redacted> + 400
5 UIKit 0x269b869f <redacted> + 254
6 AppName 0x00137fa3 -[FirstChildViewController viewWillAppear:] + 126
So I understand that bug to be something where its assumed I'm trying to access an item in an array where none exists. But the tab controller shows a count of all the view controllers it should have. So Any help would be greatly appreciated.
Again, this ONLY happens when I try to build and run for iOS8.
Thanks in advance!

where to look for a bug. document, app delegate or both?

following situation: i have a document based App. by default when i open the app it displays just the menu on top of the screen. then i hit file->new and it opens up a brand new document.xib interface. working fine on my main pc. but on my secodnary pc running 10.6.8 the app crashes as soon as i run it. (code is compiled with the proper target...)
this application is crashing BEFORE i even see the main menu at the top. could the cause of the crash still be inside the document's xib file? or will it most likely be in the code that is outside the document part? what i mean is: is the code checked completely at the application lounch or does it onyl cause a crash when it reaches the code that is causing it?
thanks
edit
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 com.apple.AppKit 0x0000000100def22e -[NSCustomObject nibInstantiate] + 416
2 com.apple.AppKit 0x0000000100def01b -[NSIBObjectData instantiateObject:] + 259
3 com.apple.AppKit 0x0000000100dee406 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 336
4 com.apple.AppKit 0x0000000100deca91 loadNib + 226
5 com.apple.AppKit 0x0000000100debfa1 +[NSBundle(NSNibLoading)_loadNibFile:nameTable:withZone:ownerBundle:] + 248
6 com.apple.AppKit 0x0000000100debdd9 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
7 com.apple.AppKit 0x0000000100de935b NSApplicationMain + 279
8 mad-sharky.com.Stockuploader 0x0000000100001194 0x100000000 + 4500
The problem lies not in the XIB file, but rather in one of the objects in said file that is being instantiated incorrectly. Something about the object is causing it's -initWithCoder: method to fail. It appears you're probably not calling through to super in said method, and are simply returning self, which is not allowed.
The other possibility is that you have a "ghost outlet". Sometimes, when an IBOutlet is created and linked, then the piece of code that declares it is removed, IB doesn't de-link the outlet, and NSCoder tries to dearchive a nil outlet.
found the problem. here it is:
now it works without any problems!

CorePlot MonoMac bindings crashing

I am trying to use the CorePlot 0.9 binding for monomac, but that seems to be a hard task. The monotouch sample builds and runs without any problems, but I don't need that one.
Since only a CorePlotiOS.dll was present in the binding, I had to build one for osx myself, but first of af all, no bmake.exe was present, so I had to download the monomac source and build it myself first. Then I tried to build the CorePlotOSX.dll but that caused some compilation problems. Looking at the build-script for mono touch I tried with this line instead:
MONO_PATH=$(MONOMAC)/src mono $(MONOMAC)/src/bmac.exe -e -unsafe coreplot.cs -s=enums.cs -x=extras.cs -x=AssemblyInfo.cs --sourceonly=list --tmpdir=osx -r:System.Drawing -r:MonoMac -lib:$(MONOMAC)/src -baselib:$(MONOMAC)/src/MonoMac.dll .
Anything wrong there?
I have reduced the problem to this:
graph = new CPTPieChart();
graph.Title = "Test";
The allocation seems to survive, but whenever I try to access the object, I crash:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000bf887fac
VM Regions Near 0xbf887fac:
Stack 00000000b038d000-00000000b040e000 [ 516K] rw-/rwx SM=COW
--> Stack 00000000bc088000-00000000bf888000 [ 56.0M] ---/rwx SM=NUL
Stack 00000000bf888000-00000000c0088000 [ 8192K] rw-/rwx SM=COW
Application Specific Information:
objc[17645]: garbage collection is OFF
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x97c8aebc __CFStringEncodeByteStream + 12
1 com.apple.Foundation 0x9ac8ed49 -[NSString(NSStringOtherEncodings) getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 263
2 com.apple.Foundation 0x9ac8e8ee bytesInEncoding + 213
3 com.apple.Foundation 0x9ac8e814 -[NSString(NSStringOtherEncodings) UTF8String] + 42
4 com.apple.CoreFoundation 0x97ce478c -[__NSCFString UTF8String] + 204
5 ??? 0x00f91208 0 + 16323080
6 ??? 0x030d708c 0 + 51212428
7 ??? 0x030d703c 0 + 51212348
8 ??? 0x016877d4 0 + 23623636
Any ideas? Running Mac OSX 10.7.5 btw.
Ok, that was hard. After several days of fighting xcode and monomac, it turned out, that the native CorePlot framework (dynamic lib) was not loaded. I was not aware, that I was supposed to load it myself (I am a monomac newbie, sorry...but isn't it rather ugly it fails silently in that way??)
Two ways to do this: either
Dlfcn.dlopen ("CorePlot.framework/CorePlot", 2); // 2 = load now, 0 = lazy load
or [assembly:MonoMac.RequiredFramework("CorePlot.framework/CorePlot")]

Aperture Plug-in crashes with EXC_BAD_ACCESS

I try to run the SampleFTPExportPlugIn that comes with the Aperture SDK 2.1. I had to tweak the Base SDK setting and manually copy the PluginManager.Framework folder to /Library/Frameworks, as described here.
All compiles and Aperture 3.2.3 now offers the menu item File/Export/FTP.
When selecting the "FTP" export method and thus triggering the plug-in code, Aperture crashes with a EXC_BAD_ACCESS. The illegal memory access happens in the initWithAPIManager method of class SampleFTPExportPlugIn when trying to get a reference to the ApertureExportManager:
_exportManager = [[_apiManager apiForProtocol:#protocol(ApertureExportManager)] retain];
This is the second line that gets executed after Aperture hands over control to the plug-in and seems to be the standard way of getting a reference to the ApertureExportManager in any Aperture plug-in (I haven't found any alternative ways of achieving the same anywhere).
Here the stacktrace:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000100000000-0000000100798000 [ 7776K] r-x/rwx SM=COW /Applications/Aperture.app/Contents/MacOS/Aperture
Application Specific Information:
objc_msgSend() selector name: class
objc[3000]: garbage collection is OFF
Performing #selector(a_exportPlugIn:) from sender NSMenuItem 0x111d2a540
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff8711c090 objc_msgSend_vtable2 + 16
1 com.apple.CoreFoundation 0x00007fff8381e25f -[__NSCFString isEqualToString:] + 63
2 com.apple.PluginManager 0x0000000101211218 -[PROBundleHandler apiForProtocol:] + 109
3 com.apple.CoreFoundation 0x00007fff83852f4c __invoking___ + 140
4 com.apple.CoreFoundation 0x00007fff83852de4 -[NSInvocation invoke] + 132
5 com.apple.CoreFoundation 0x00007fff83852fb4 -[NSInvocation invokeWithTarget:] + 52
6 com.apple.CoreFoundation 0x00007fff8384dff4 ___forwarding___ + 756
7 com.apple.CoreFoundation 0x00007fff8384dc88 _CF_forwarding_prep_0 + 232
8 com.apple.SampleFTPExportPlugIn 0x000000012c0d5361 -[SampleFTPExportPlugIn initWithAPIManager:] + 209
9 com.apple.PluginManager 0x000000010120c6fa -[PROConcretePlugIn plugInInstance] + 212
I read all about Objective-C memory management but cannot make sense of it. All the other examples I found on the web are implemented just like that so I guess I have a compatibility problem, something missing in my Aperture / Library installation. How can I narrow down the problem?
EDIT:
The problem seems to be with the passed in apiManager. The method signature is:
- (id)initWithAPIManager:(id<PROAPIAccessing>)apiManager
The parameter is then assigned to our internal reference:
_apiManager = apiManager;
However the actual class passed in is PROPlugInFirewall, as this output reviels:
NSLog(#"_apiManager class is: %#", [[_apiManager class] description]);
Then calling the respondsToSelector leads to the same crash although this method is inherited from NSObject.
if ( [_apiManager respondsToSelector:#selector(apiForProtocol:)] ) {
NSLog(#"responds");
}
The _apiManager itself describes itself as:
_apiManager is: <[*<PROBundleHandler: 0x14d79130> (PROAPIAccessing)*]>
Still stuck...
EDIT:
So it looks like Aperture is passing in a pointer that points to nirvana... However, I just installed another plugin, from the Apple webpage, with installer and everything. That one failed too when invoked...
Download FXPlug 1.2.5 SDK
Open the contents of the installer package
Copy PluginManager.framework to /Library/Frameworks
Your plugin should work now!
The newer versions of PluginManager.framework in FXPlug SDK(2.2/2.4) will cause this crash.
Tested on 10.8 with Xcode 4.5
I found that Justin's answer above didn't work for me when needing to build for Aperture 3.4, as it requires x86_64 architecture which the FXPlug 1.x versions don't support.
After trying various versions of the PluginManager framework, I found that the version available here doesn't cause the above crash and also contains the valid 64-bit architecture. Just replace the contents of /Library/Frameworks/PluginManager.framework/Versions/B with the contents of the linked archive and you're good to go.

Core Data Utility Crash

I'm working through the Core Data Utility at http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html#//apple_ref/doc/uid/TP40001800-CH202-TP1
I've stumbled on a rather nasty crash SIG_ABRT on the line that reads:
[moc save:&error]
This is the output in the debug:
2010-07-25 22:24:01.665 CoreDataUtilityTutorial[1607:a0f] -[NSCFNumber timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x200022100
2010-07-25 22:24:01.666 CoreDataUtilityTutorial[1607:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x200022100'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff87e71cc4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff840ee0f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff87ecb140 +[NSObject(NSObject) doesNotRecognizeSelector:] + 0
3 CoreFoundation 0x00007fff87e43cdf ___forwarding___ + 751
4 CoreFoundation 0x00007fff87e3fe28 _CF_forwarding_prep_0 + 232
5 CoreData 0x00007fff881baede -[NSXMLDocumentMap getXMLAttributeValueFromObject:forAttribute:] + 478
6 CoreData 0x00007fff881be7c8 -[NSXMLDocumentMap nodeFromManagedObject:objectIDMap:] + 1160
7 CoreData 0x00007fff881bb67c -[NSXMLDocumentMap addObject:objectIDMap:] + 140
8 CoreData 0x00007fff8817d400 -[NSMappedObjectStore _addObject:objectIDMap:] + 32
9 CoreData 0x00007fff8817c98f -[NSMappedObjectStore executeSaveChangesRequest:withContext:] + 1343
10 CoreData 0x00007fff88177599 -[NSMappedObjectStore executeRequest:withContext:] + 105
11 CoreData 0x00007fff88145051 -[NSPersistentStoreCoordinator(_NSInternalMethods) executeRequest:withContext:] + 545
12 CoreData 0x00007fff88179123 -[NSManagedObjectContext save:] + 323
13 CoreDataUtilityTutorial 0x00000001000015b7 main + 303
14 CoreDataUtilityTutorial 0x0000000100000cac start + 52
15 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Anyone have an idea? I rechecked the code to see if I mistyped something but nothing is wrong...
Thanks in advance.
Without your actual code, this is a wild stab in the dark, but it looks as if your store is improperly configured at some juncture. Specifically, it looks as if the runtime is expecting a date, but the store has a number.
This could result from making changes to a model without doing a full recompile, maybe.
It could of course be something completely different, but without your specific code, or at the very least a diff against the finished example project as supplied with the tutorial, this is pretty difficult to troubleshoot.
(Another, not impossible, alternative, is that the tutorial was written to assume a specific, earlier version of Mac OS X, like 10.4 or 10.5. This could also result in problems, especially if the default settings for a Core Data project has changed, and this is a result of using the XML store over, say, the SQLite store.)
Looks like the crash is somewhere in the XML code, not the core data code.