我正在开发一个小型 Swift 应用程序。在 Xcode 中,当我按下 run
按钮或使用 cmd + R
键盘快捷键时,模拟器和我的应用程序按预期运行。但是在模拟器中,当我点击我安装的应用程序的图标来运行它时,我的应用程序出现一秒钟然后崩溃/失败,没有错误消息或没有日志。
我是 iOS 开发的新手,不知道这是一个常见问题还是我哪里做错了。
我已通过 iOS Simulator Menu -> Reset Content and Settings...
选项重置模拟器内容和设置。
我已经重新启动了 iOS 模拟器、Xcode 和操作系统 (OS X),但问题仍然存在。
我基本上想在模拟器中单击我安装的应用程序的图标并运行它。我该如何解决这个问题?
--
编辑到期评论:
我不碰 AppDelegate.swift
文件。它与第一次生成相同。我只有一个 ViewController 类,ViewController.swift
,方法是:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
login()
}
/// Login method
func login() {
// login methos's body
}
最佳答案
好的,我有解决方案。感谢@Phillip Mills 的评论。该评论帮助我找到解决方案。
在System Log Queries
中,我发现报告崩溃,如下所示:
Dyld Error Message:
Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/79ECB6DD-8AF9-42F7-8543-AF9F689258C0/data/Containers/Bundle/Application/126E829F-A5D3-48CE-B65A-C06CE811A679/MyAwesoneApp.app/MyAwesoneApp
Reason: image not found
用谷歌搜索,然后从 github 上发现了这个问题: dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire on my iPhone(iOS8) while debuging #101
我试过我从屏幕截图中看到的,它有效!
我忘记将 Alamofire
框架添加到 Link Binary With Libraries
部分。
关于ios - 为什么我的 iOS 应用程序在我从 iOS 模拟器打开时失败/关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28025220/