iOS: Linking a third party framework and crashing when deploying - iphone

So, my problem is that I'm creating a framework to be used with iOS. It works great when in the simulator and when I'm debugging it on my iPad but as soon as I send it to anyone via Testflight (including my iPad) it crashes. The application will load the splash screen, then crash.
I tried symbolicating the report but I'm not getting anything out of it.

One time happened to me... xcode compiles the app for debug on the simulator, but for release on the iOS device. Then, the debug version doesn't do many enhancements.
Go to "Product" -> "Manage Schemes". There, if I were you, I would set everything to "Build Configuration": Release.
This way, you may be able to have the simulator crash... and it may be easier for you to figure out what's going on.
In my case, I was using a block but not copying it... then, on the release version, the compiler cleared the memory while on the debug version it didn't.
Hope it helps

So, the solution to my problem was that I was linking the framework but not copying it to the device, so when I debugged it with my iPad connected to it, it would find the references to the framework, but once it was deployed, the app crashed when it tried to find the framework.
The answer was:
Go to your project's build phases.
Add build phase > Add copy files.
Choose Frameworks in the Destination field.
Copy the framework.
Your app should now have the framework copied and installed wherever it needs.

Related

iPhone app crash immediately after update

today my app update it has been released in the store, when updated or downloaded for the first time the app immediately crash on start.
I've tested the app on simulator and on device (the same where I've installed the update from the store) and I never experienced this problem.
My update it has been submitted with Organizer after the archiving, in the Distribute section.
Apple do not perform these types of controls before to release an app?
Anyone experienced a similar problem? I have no idea what could be the cause..
Thank you, Stefano.
Here's the best way to test a production build without deploying to the store:
Set your build Scheme to "iOS Device"
Do an Archive build
Select your archive and click Distribute
Choose "Save for Enterprise or Ad-Hoc Deployment"
Pick your code signing cert
After saving the ipa file, use Apple's iPhone Configuration Utility(*) to install it on your device
You should always perform two tests:
installing on a blank device after uninstalling your app *and any profiles in Settings -> General -> Profiles"
installing over the top of the previous version of your app, to make sure any files/preferences/etc are properly converted to the new format
(*) the iPhone Configuration Utility is mostly used for enterprise app deployment, but it's also useful for developers and is available as a free download for mac and windows at support.apple.com. You can also use iTunes instead, but it's convoluted.
As for why your app is crashing? No idea... it could be anything. Standard debugging advice applies.
The issue is related to the Framework. I had this exact error. It wasn't a case of logic as it was crashing before the AppDelegate was even called and my usage of NSMetadataQuery was much later in the life cycle than that.
It turns out that weak linking the Foundation framework was required.
Problem was solved by changing (under the Project Info in Xcode) the dependency option of the Foundation.framework from required to optional. Check for any such frameworks.
Try deleting any old versions of the app you have on your device, and reinstall. Also try on a different device, maybe with a different apple id to your developer account.
This happened to our app also, and apparently, other apps too.
Apple is aware of the problem and is currently working on a solution.
see this article:
http://techcrunch.com/2012/07/05/apple-responds-to-app-crashing-issues-has-a-dedicated-team-working-on-a-fix/
If you are using core data & you have updated database in your latest version without versioning core data in that case app crashes on launch after update.

Newbie: Errors in an iPhone app

I'm really newbie in iOS and I have to handle a complicated situation. I was given an iPhone app developed by someone and I have to make it work. The guy who developed it has told me that it worked, but sometimes crashed in an iPhone. I've never developed using iOS and I don't really know how this app works.
Well, when I open the app with Xcode, the first problem that I detect is some errors with the references. The app uses the project CorePlot-CocoaTouch.xcodeproj. I've added again this project and solved the references (I've followed some other posts like this one: http://www.jaysonjc.com/programming/pie-chart-drawing-in-iphone-using-core-plot-library.html).
I want to test it with the simulator (I don't have an iPhone yet). I have a doubt here...should I use iOS Device, or iOS Simulator as Base SDK? Firstly I chose iOS Simulator, but it appeared a problem with Cocoa.framework (it turned into red).
Anyway, using iOS Device as Base SDK, I build the project and it says "Build failed (59 errors, 3 warnings)". I check out the errors, and most of them are "Expected specifier-qualifier-list before ..."
Can anyone help me? This is more or less the situation, but I can provide more specific details if they're needed.
I'm sorry if I'm talking about something really basic, but I've been trying to solve it for 2 weeks and I give up. I've tried to talk to the guy, but he's not really helpful..
Thanks for the replies!
By the way, I didn't say it and I don't know if it's relevant or what it means. The guy has a directory called "Libraries" where it's stored the CorePlot. The files there are the same than if you download the CorePlot project from other source. The only exception is a folder called "SDKBuild", which contains files like "build.sh", "iphoneos-SDKSettings.plist" or "iphonesimulator-SDKSettings.plist". I'm really newbie, so it's probably obvious, but I have no idea...
just try to add CocoaTouch framework to your project.
and for base SDK use "latest iOS".
Right click on the project name in 'group & files' set on the left of xcode. Choose add -> Existing Frameworks.
Find Cocoa.framwork and click add. Do this to all red colored framework.
Choose IOS Simulator as base SDK.
Try run it..
If you want to run the app on simulator, you have to build with iOS simulator. The base SDK basically sets the OS version (this will be the same regardless of whether you are running the app on simulator or device). You should be chaining the build settings to device only if the device is connected and if you have installed the appropriate provisioning profiles.

iPhone release build is crashing

A project i'm working on is crashing when built with release configuration.
We need to send the application to apple for review and it is crashing before even entering the app.
Any idea how that could happen?
In last ressort, is it possible to send to apple a debug version of the app with some optimizations?
thanks.
The same thing happened to me when building my first iPhone app - after working on the project for a while when switching from debug to release the app would crash. I did a full clean rebuild of the project, deleted the app from the test phone and reinstalled it, and the app ran. It looked like XCode sometimes does not clean up/rebuild everything it needs to.
In my experience, 9 times out of 10 annoying, hard to track down crashes in a non-debug vs. debug build of anything, iPhone or otherwise, is caused by a memory management bug. I'd put money on your issue being caused by an improperly placed release or retain message, or lack thereof. If you haven't tried it yet, turn on the static analyzer in your debug build configuration (my XCode is updating right now, but I believe if you search for "analyzer" or "clang" in your build properties you should find the appropriate setting) and see if it points to anything telling. If it doesn't, you can use Instruments to help you check for problems, as well as attempting to isolate the problem area in the debugger.
It might help you to reproduce the problem in a not-actually-a-release-build by modifying your debug configuration or duplicating it to use a different set of compiler flags that more closely aligns with what happens in the release build (I don't recall what the differences are off the top of my head, but I would assume adding a "-O2" to your compiler flags would get you most of the way there).
If you build with Release configuration, make sure you keep a copy of the .dSYM file and the application bundle.
Then when the application crashes on the device, plug it into Xcode and download the crash reports.
Open Xcode and then open the Organizer from within Xcode. From there you can view crash reports from a device.
The crash reports will be symbolicated if (and only if) you saved the .dSYM file and the application bundle.
You can then use the crash reports to find out why it is crashing, and fix it.
You should look at your Crash Logs. Open Organizer, select your device, then the "Crash Log" tab. Scroll down to find your app's logs. The should be symbolicated, so you can see the stack trace.
Without actually debugging your app, it's really hard to say more. Are you using an #ifdef DEBUG macros? Are you using more than one thread? If you have a bunch of NSLog statements that slow down execution in debug mode, this can introduce subtle timing differences that can impact multi-threaded apps.
Did you try a 'make clean' on your debug version? Sometimes obscure bugs can be hidden when parts of your project are rebuilt while other parts are unchanged.

How to force application Settings bundle get updated?

Application Settings.bundle contains a version number, which is automatically generated during build. From build log I can see that new value is written there, also when looking inside the file itself in MacOS X Finder I see correct updated value.
Settings in iPhone simulator or in real iPhone shows me the old value. Removing application and reinstalling is so far the only way I've managed to get the new updated value visible.
Question: how can I force iPhone Settings application to read my new latest updated bundle file?
Some background info, which might or might not be related: I install application only via Xcode into both simulator and iPhone. Is this the problem? Just found this in Apple docs, not sure what it actually says. Seems to contradict itself (last chapter)...
Each time you reinstall your application, iPhone OS performs a clean install, which deletes any previous preferences. In other words, building or running your application from Xcode always installs a new version, replacing any old contents. To test preference changes between successive executions, you must run your application directly from the simulator interface and not from Xcode.
So Xcode always replaces old content, but to test changes I cannot use Xcode? What was that? Done both (after installation via Xcode) and didn't see new values in settings. Any ideas how does it actually work? Do I always have to make non-Xcode installation?
Try cleaning and building. It seems that xcode caches dates and doesn't notice the change that your script is making. I've had similar things happen, clean always fixes it, but it is indeed a nuisance.
Make sure to shut down the Settings app running in the background on device. It looks like Settings caches settings while it's running - but pulls the updated values when the Settings app is re-launched.
In my case, it seems that my modified root.plist, created/edited via the Xcode property list editor, just wasn't being saved.
There was no problem at all with the Settings Bundle being copied over to the iPad. A quick cmd-S followed by a rebuild and go/debug updated Settings on the iPad straight away - no app uninstall/reinstall even needed. You'd think there'd at least be a haven't-saved-it warning from Xcode, as there always is for code source files.
I just tried this and it worked.
In Xcode go to : Window->Organizer,
then view installed apps on the connected iPad/iPhone, remove the app, then recompile and run your app on the device.
I think the issue has something to do with the iPad's cache.

Static Libraries on iPhone device

I have two projects, a Cocoa iPhone application and a static library which it uses.
I've tested it successfully on the iPhone simulator, but when I try to deploy it to my iPhone device I get (symbol not found) link errors.
If I remove the dependancy of the library the project builds/runs fine.
I have made sure all the build settings are set to iPhoneOS not the simulator.
Im sure its something simple, but has anyone run into similar problems moving from iPhone simulator to device?
--EDIT: I have managed to create new projects (one for the application and one for the static library), and successfully get them to run on the iPhone or simulator. But I have a very strange problem... for each specific project I cannot get it working for BOTH the device and the simulator... I have double checked the build settings, made sure the libraries that are being references are for the matching build settings (I believe) but I cannot resolve these linking errors.
I think I must be doing something very wrong... all the apple documentation says 'its super simple - one click' but this is giving me a lot of problems.
This is probably something to do with xCode build settings, but I cannot seem to understand why selecting the different build platforms and rebuilding the libraries does not work.
Check out my answer to a similar question for a link to an article that might help. There is a link to an interesting article.
Eventually I realised what the problem was.
I changed my device target from simulator to iPhone device, then removed the old (simulator) static library and attached the new (device) library.
All fine, except the library search path (in the build configurations) still had the simulator directory listed first, which I assume cause it to be found and used rather than the device.
This also explains why I was able to make each setting work with a new project, but only had trouble changing between settings.
Its a simple and stupid problem, but one that caused me some grief and time. Im still not sure how to properly set target dependent build settings but at least if anyone is getting similar problems its something to look out for.
I've created a complete tutorial on how to create and use static libraries, this tutorial covers the the method that is also advised by apple, maybe people will find it usefull:
http://www.sodeso.nl/?p=822
Advantages of this methods is that it automatically recompiles the library according to your project settings (so no trouble with device / simulator builds)