ios - LLVM 错误 : Broken function found, 编译中止!存档时

标签 ios xcode swift ios8

我在 Today Extension 中有这段代码,但我仍然收到来自“存档产品”的错误

isvolatile argument of memory intrinsics must be a constant int call void @llvm.memcpy.p0i8.p0i8.i64(i8* %550, i8* getelementptr inbounds ([2 x i8]* @6, i64 0, i64 0), i64 %549, i32 0, i1 %68), !dbg !1307 LLVM ERROR: Broken function found, compilation aborted!

这有什么帮助吗?

import UIKit
import NotificationCenter
import CoreData
import SwiftWidgetKit


class TodayViewController: UIViewController, NCWidgetProviding {

    var data : NameForToday?
    var user_data : UserInfo?
    let context = CoreDataStore.mainQueueContext()


    @IBOutlet weak var label: UILabel!

    override func viewDidLoad() {
        //self.preferredContentSize = CGSizeMake(0, 50);
        super.viewDidLoad()

        label.textAlignment = NSTextAlignment.Left
        self.view.addSubview(label)


    }

    override func viewWillAppear(animated: Bool)
    {
        self.preferredContentSize = CGSizeMake(0, 40);
        if (NSUserDefaults(suiteName: "group.sk.freetech.Meniny-Widget")?.boolForKey("my_first_launch") == false)
        {
            label.text = "Zapnite aplikáciu"
        }
        else
        {
            let name_data = GetName()
            if (name_data.name_today == "NULL")
            {
                label.text = "Dneska neoslavuje nikto."
            }
            else
            {
                label.text = "🎁  " + name_data.name_today
            }
            println("mena \(name_data)")
        }


    }

    func GetName() -> (name_today: String, name_tommorow: String)
    {
        let date = GetDate()
        println("datumy \(date)")

        var request_for_today = NSFetchRequest(entityName: "ListOfNames")
        request_for_today.predicate = NSPredicate(format: "(month == \(date.actual_month)) AND (day == \(date.actual_day))")

        var request_for_tommorow = NSFetchRequest(entityName: "ListOfNames")
        request_for_tommorow.predicate = NSPredicate(format: "(month == \(date.tommorow_month)) AND (day == \(date.tommorow_day))")

        var result_today:NSArray = context.executeFetchRequest(request_for_today, error: nil)!
        var name_today:NSString

        var result_tommorow:NSArray = context.executeFetchRequest(request_for_tommorow, error: nil)!
        var name_tommorow:NSString

        switch result_today.count
        {
        case 1:
            var res = result_today[0] as NSManagedObject
            name_today = res.valueForKey("name") as String
            break
        case 2:
            var res_1 = result_today[0] as NSManagedObject
            var res_2 = result_today[1] as NSManagedObject
            name_today = (res_1.valueForKey("name") as String) + ", " + (res_2.valueForKey("name") as String)
            break
        case 3:
            var res_1 = result_today[0] as NSManagedObject
            var res_2 = result_today[1] as NSManagedObject
            var res_3 = result_today[2] as NSManagedObject
            name_today = (res_1.valueForKey("name") as String) + ", " + (res_2.valueForKey("name") as String) + ", " + (res_3.valueForKey("name") as String)
        default:
            var res = result_today[0] as NSManagedObject
            name_today = res.valueForKey("name") as String
            break
        }

        switch result_tommorow.count
        {
        case 1:
            var res = result_tommorow[0] as NSManagedObject
            name_tommorow = res.valueForKey("name") as String
            break
        case 2:
            var res_1 = result_tommorow[0] as NSManagedObject
            var res_2 = result_tommorow[1] as NSManagedObject
            name_tommorow = (res_1.valueForKey("name") as String) + ", " + (res_2.valueForKey("name") as String)
            break
        case 3:
            var res_1 = result_tommorow[0] as NSManagedObject
            var res_2 = result_tommorow[1] as NSManagedObject
            var res_3 = result_tommorow[2] as NSManagedObject
            name_tommorow = (res_1.valueForKey("name") as String) + ", " + (res_2.valueForKey("name") as String) + ", " + (res_3.valueForKey("name") as String)
        default:
            var res = result_tommorow[0] as NSManagedObject
            name_tommorow = res.valueForKey("name") as String
            break
        }

        return (name_today, name_tommorow)
    }

    // Zistenie datumu
    func GetDate() -> (actual_month: integer_t,actual_day: integer_t,tommorow_month: integer_t,tommorow_day: integer_t)
    {
        let date_today = NSDate();
        let date_tommorow = NSDate(timeIntervalSinceNow: 60*60*24)

        var format_month = NSDateFormatter()
        format_month.dateFormat = "MM"
        let actual_month : NSString = format_month.stringFromDate(date_today)
        let tommorow_month : NSString = format_month.stringFromDate(date_tommorow)

        var format_day = NSDateFormatter()
        format_day.dateFormat = "dd"
        let actual_day : NSString = format_day.stringFromDate(date_today)
        let tommorow_day : NSString = format_day.stringFromDate(date_tommorow)

        var actual_month_int = actual_month.intValue
        var actual_day_int = actual_day.intValue
        var tommorow_month_int = tommorow_month.intValue
        var tommorow_day_int = tommorow_day.intValue

        return (actual_month_int, actual_day_int,tommorow_month_int, tommorow_day_int)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
        // Perform any setup necessary in order to update the view.

        // If an error is encountered, use NCUpdateResult.Failed
        // If there's no update required, use NCUpdateResult.NoData
        // If there's an update, use NCUpdateResult.NewData

        completionHandler(NCUpdateResult.NewData)
    }

}

最佳答案

我的解决方案只是在 info.plist 中更改 Swift Compiler Code Generation -> Optimization level -> Debug -> change all to None[-Onone]

关于ios - LLVM 错误 : Broken function found, 编译中止!存档时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28552027/

相关文章:

ios - 如何在 cellForRowAtIndexPath 方法中判断滚动方向(右上左下)

ios - 在swift中点击一个颜色 Sprite 后如何返回到之前的场景?

ios - 如何禁用选项卡栏项目以及如何更改禁用项目的颜色和透明度

ios - 只允许一个 View Controller 的所有方向

objective-c - Objective c 不喜欢我的 unichars?

ios - 当我更改 ViewController 时 UIImageView 不旋转

ios - Swift:dispatch_async is effect is inconsistent for animation

ios - 如何根据单元格内部的文本自动调整单元格的高度?

iphone - iOS 上的 Scala 使用 Avian

ios - Swift 中开关盒的详尽条件