Swift应用程序仅在归档(导出)时崩溃。 NSLog相关

时间:2017-02-08 12:10:45

标签: swift macos

我在swift中有一个macOS应用程序仅在归档时崩溃(不是从XCode运行)。

它崩溃了以下代码:

IF EXIST "%%~a\" ECHO FOLDER %%a EXISTS

这是DLog函数(导出时,未设置DEBUG标志,因此不会执行NSLog):

// dataTables.editor.js

Editor.prototype._submit = function ( successCallback, errorCallback, formatdata, hide )
{
...
    // Submit to the server (or whatever method is defined in the settings)
    this._ajax(
        submitParams,
        function (json) {
        ...
            // the following line forces the table to completely reload
            that._dataSource( 'commit', action, modifier, json.data, store );
        ...
        }
    )
...
}

导致应用程序崩溃的private static func myFunc(originalValue: String) { DLog("Starting myFunc on: '\(originalValue)'") // CRASHES when app is exported } 是一个包含基本字符(字母或数字),没有func DLog(_ message: String, function: String = #function) { #if DEBUG NSLog("%@, %@", function, message) #endif } 或其他格式字符串的字符串。

现在最有趣的部分,如果我在调用originalValue之前打印(使用Swift.print)%@,它就不会崩溃:

originalValue

对这种奇怪行为的任何合理解释?

谢谢!

0 个答案:

没有答案