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

Jeef picture Jeef · Sep 17, 2014 · Viewed 57.5k times · Source

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?

Answer

Kampai picture Kampai · Dec 3, 2014

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)