gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 11:38:42 27 4
gpt4 key购买 nike

我有一个正在尝试迁移到 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com