ios - swift 在 Xcode 中编译时出现退出代码 1 失败 - 可能与 Bridging-Headers 有关

标签 ios objective-c swift core-plot

我有一个正在尝试迁移到 Swift 的 Obj-C 项目。我确实在各种类(class)上取得了成功,但最近遇到了一个我似乎无法理解的问题。当我尝试编译我当前的代码库时,我得到以下信息( super 无用的错误消息)

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

enter image description here

我唯一的假设是它在某种程度上与我的桥接头有关,但 Xcode 没有给我足够的信息来确定这是否真的是真的。

我正在使用 Cocoapods添加 CorePlot到我的项目。我正在尝试将以下类迁移到 Swift:

Obj-C 类 (ScatterPlotContainer.h)

#import <Foundation/Foundation.h>

@class CPTScatterPlot;

@interface ScatterPlotContainer : NSObject
@property (nonatomic, strong) CPTScatterPlot *ahrsAlt;
@property (nonatomic, strong) CPTScatterPlot *calibration;
@property (nonatomic, strong) CPTScatterPlot *coreAlt;
@property (nonatomic, strong) CPTScatterPlot *pitch;
@property (nonatomic, strong) CPTScatterPlot *roll;
@property (nonatomic, strong) CPTScatterPlot *slip;
@end

Obj-c 类 (ScatterPlotContainer.m)

#import <CorePlot/CPTScatterPlot.h>
#import "ScatterPlotContainer.h"


@implementation ScatterPlotContainer {

}
@end

快速转换

import Foundation

 class ScatterPlotContainer : NSObject {
    public var ahrsAlt : CPTScatterPlot;
    public var calibration : CPTScatterPlot;
    public var coreAlt : CPTScatterPlot;
    public var pitch : CPTScatterPlot;
    public var roll : CPTScatterPlot;
    public var slip : CPTScatterPlot;
}

我的桥接头文件

#import <CorePlot/CPTScatterPlot.h>

到目前为止我已经尝试过什么

当我注释掉 #import <CorePlot/CPTScatterPlot.h>来自桥接头文件 - 我在 swift 中遇到错误,因为它不知道 CPTScatterPlot 是什么

我也试过 #import <CPTScatterPlot.h>这也不起作用。

想法

所以我唯一能想到的可能是因为我使用的是 cocoa pod ,所以我需要添加某种模块名称。错误信息真的没那么有用。是否有人对我犯的一些明显错误或如何获得更具描述性的错误消息以了解发生了什么有任何建议?

最佳答案

我做了同样的所有答案,但我的问题没有解决。我确实发现这个问题与函数调用中断有关。

函数语法没有错,但调用机制错了。

要检查此问题的确切错误,请检查以下内容:

选择问题导航器 > 单击错误将显示错误日志 > 在其中选择所有消息选项卡。

这将显示此错误的所有详细日志。

enter image description here

向下滚动,你会得到类似的日志,在我的例子中

enter image description here

所以,通过阅读本文,我发现函数调用有问题。我浏览了我的代码并解决了它,下面是正确和错误的代码。

错误的方式:

var region = MKCoordinateRegionMake(self.mapView.userLocation.coordinate, span)
// It will not shown error here but when you build project compiler shows error.

正道:

let region = MKCoordinateRegion(center: self.mapView.userLocation.coordinate, span: span)

关于ios - swift 在 Xcode 中编译时出现退出代码 1 失败 - 可能与 Bridging-Headers 有关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25889723/

相关文章:

ios - 重新排序 NSSet UITableView

iphone - 当 addSubview 和 release 在添加的 View 中无法正常工作时

objective-c - UIWebView 不会在 Xcode6 中加​​载

swift 4 : Local Dependencies with Swift Package Manager?

ios - Iphone App图标错误57 x 57 iOs版本<7.0

ios - 选项卡栏项目 - 选定/未选定图标

swift - 导航栏下的UISementControll

ios - 使用自动布局时如何使 UIScrollView 仅在一个方向上缩放

ios - 自动调用用户位置

ios - @try@catch block 不捕获内部异常