Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

ios - swift failed with exit code 1 while compiling in Xcode - possibly related to Bridging-Headers

I have an Obj-C Project I'm trying to migrate to Swift. I did succeed with various classes but recently ran into an issue I can't seem to make sense of. When I try to compile my current code base I get the following (SUPER UNHELPFUL ERROR MESSAGE)

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

enter image description here

My only assumption is its somehow related to my bridging-headers but Xcode isn't giving me enough information to figure out if this is actually true.

I'm using Cocoapods to add the CorePlot to my project. I'm trying to migrate the following class to Swift:

Obj-C Class (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 Class (ScatterPlotContainer.m)

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


@implementation ScatterPlotContainer {

}
@end

Swift Conversion

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;
}

My bridging headers file

#import <CorePlot/CPTScatterPlot.h>

What I've tried thus far

When I comment out the #import <CorePlot/CPTScatterPlot.h> from the Bridging headers file - I get an error in swift because it doesn't know what CPTScatterPlot is

I've also tried #import <CPTScatterPlot.h> which didn't work either.

Thoughts

So the only thing I can think of is perhaps because I'm using a cocoa pod there is some sort of module name I need to add. The error message really isn't that useful. Does anybody have a suggestion about some blaring error I've made or how to get a more descriptive error message to figure out what is going on?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I did the same all answer says but mine issue was not resolved. I did figured out that issue was related to broken function call.

A function syntax was not wrong but its calling mechanism was wrong.

To check the exact error for this issue check following:

Select issue navigator > Click on error will show logs for error > In that select All Messages tab.

This will show all detail logs for this error.

enter image description here

Scroll down and You got logs like, in my case

enter image description here

So, by reading this I figure out that something wrong with function calling. I browse my code and resolved it, Below was correct and wrong code.

Wrong Way:

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

Right Way:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...