App crash on device but works on simulator iOS
The problem was in pods frameworks. Script generated by pods can't embed some frameworks correctly. I removed "[CP] Embed Pods Frameworks" script and add frameworks to "Embedded Binaries" by myself. And problem was solved.
Swift app crashes on real device but works on simulator
I recently had a similar error.
I suspect you're trying to run the code on a pre 8.0 device. If that's the case, dateByAddingUnit
is not available on your device (see the header)
@availability(iOS, introduced=8.0)
You can achieve what you're trying to do by using `dateByAddingComponents' - it's a little more cumbersome but should give you the same result. Try the following playground
import UIKit
import Foundation
var tuple:( Int, NSCalendarUnit) = (1, NSCalendarUnit.CalendarUnitDay)
var date = NSDate()
/* 8.0+ */
var yesterday = NSCalendar.currentCalendar().dateByAddingUnit(tuple.1, value: (-tuple.0), toDate: date, options: NSCalendarOptions.SearchBackwards)
/* 7.1 + */
let component = NSDateComponents()
if tuple.1 == NSCalendarUnit.CalendarUnitDay {
component.day = -tuple.0
}
var alsoYesterday = NSCalendar.currentCalendar().dateByAddingComponents(component, toDate: date, options: NSCalendarOptions.SearchBackwards)
Hope this helps! :)
iOS App Crashes on Phone but works fine on simulator
Try:
get{
println("display.text =\(display.text!)")
let formatter = NSNumberFormatter()
formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
return formatter.numberFromString(display.text!)!.doubleValue
}
Because, NSNumberFormatter
uses devices locale by default, it's possible that the decimal separator is not "."
. For example:
let formatter = NSNumberFormatter()
formatter.locale = NSLocale(localeIdentifier: "ar-SA")
print(formatter.decimalSeparator!) // -> outputs "٫"
formatter.numberFromString("6.0") // -> nil
The formatter that uses such locales cannot parse strings like "6.0"
. So if you want consistent result from the formatter, you should explicitly specify the locale
.
As for en_US_POSIX
locale, see the document:
In most cases the best locale to choose is
en_US_POSIX
, a locale that's specifically designed to yield US English results regardless of both user and system preferences.en_US_POSIX
is also invariant in time (if the US, at some point in the future, changes the way it formats dates,en_US
will change to reflect the new behavior, buten_US_POSIX
will not), and between platforms (en_US_POSIX
works the same on iPhone OS as it does on OS X, and as it does on other platforms).
App crashes on iPhone but not on simulator
I think this is a memory problem with the iPhone 4S (200 mb for 4S is a lot). You should read the crash logs in Xcode.
In Xcode with the iPhone connected you can go to Window->Devices, select your phone and press 'View Device Logs'. You will see a list with all the last crashes of the apps and with the information of the crash.
Regards
Application crashes on device - works perfectly on Simulator
Even it's old question. I found my issue by deleting derived data from xcode.
Xcode -> window->Projects then select and delete your project derived data.
iOS App Crash On Launch With Only LLDB() (The App Works In Simulator)
The long and the short of it was when I embedded the framework into the main app, it caused some other obscure bug. When I removed a runscript from the build phases, it allowed the embedding to actually work and it fixed the issue.
So by deleting the run script phase seen below in the build phases:
I was able to embed the framework and the app began to compile on devices.
So if you have this type of error in the future the solution is still to embed it, but in my case, there was another problem preventing that embedding from working.
Related Topics
Swift/How to Call Delegate with Popviewcontroller
Is Weak Self Needed for Table View Cell Button Closure
Vnfaceobservation Boundingbox Not Scaling in Portrait Mode
Get Total Include Months Between 2 Date in Swift
Swift:'(Nsobject, Anyobject)' Does Not Have a Member Named 'Subscript'
Swift Save Viewcontroller State Using Coder Beyond App Close
Change Push Notifications Programmatically in Swift
Wkwebview: How to Preload Multiple Urls
Swift Conform to Protocol Subclass
Get "No Keychain Available" Error When Try to Access Keychain from App Extension
Custom Uibutton Class for Button Touch Event
How to Send Request from iOS (Swift) to Dialogflow V2 API Without Cloud Functions
Why Print() Is Printing My String as an Optional
Give Thumbnail Image with Uiactivityviewcontroller
How to Set Response Data into Todayextenstion Widget