iOS 图表未构建

iOS chart not building

我遵循了关于 IOS 图表的第 3 方教程(如何使用 iOS 图表 API 在 Swift 中创建漂亮的图表)

IOS charts tutorial

演示应用程序一切正常,还可以从头开始创建图表应用程序。

但是我也有一个工作的应用程序,我正在尝试向它添加一个图表,但是当我将嵌入式二进制文件添加到我的工作应用程序时,我的项目将不再构建并且我收到错误消息...

clang: error: linker command failed with exit code 1 (use -v to see invocation)

有没有人知道为什么会发生这种情况以及如何解决它?

谢谢

嗯,我已经成功集成了 iOS 图表并绘制了折线图。

Please download project.

import UIKit

class ViewController: UIViewController {

    
  @IBOutlet weak var lineChartView: LineChartView!
    
        override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let months = ["1", "2", "3", "4", "5", "6", "7"]
        let unitsSold = [5.0, 1.0, 2.0, 9.0, 15.0, 3.0, 4.0]

        
        setChart(months, values: unitsSold)
        
    }

    
    func setChart(dataPoints: [String], values: [Double]) {
        
        var dataEntries: [ChartDataEntry] = []
        
        for i in 0..<dataPoints.count {
            if !values[i].isZero {
                let dataEntry = ChartDataEntry(value: Double(values[i]), xIndex: i)
                dataEntries.append(dataEntry)
            }
        }
        
        var colors: [UIColor] = []
        
        for i in 0..<dataPoints.count {
            let red = Double(arc4random_uniform(256))
            let green = Double(arc4random_uniform(256))
            let blue = Double(arc4random_uniform(256))
            
            let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)
            colors.append(color)
        }
        
       
        
        
        let lineChartDataSet = LineChartDataSet(yVals: dataEntries, label: "")
        lineChartDataSet.drawValuesEnabled = false
                        lineChartDataSet.drawFilledEnabled = false

        lineChartDataSet.cubicIntensity = 1.0
        
        let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
        
        
        lineChartView.data = lineChartData

        lineChartView.leftAxis.enabled = false

        lineChartView.xAxis.labelPosition = .Bottom

        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

   
}

很少检查设置如下。

(1) 位码

(2) 编译源

(3) 有效架构

希望这对您正确集成它有所帮助。

我已经通过编辑 > 转换 > 到当前 swift 语法将我的工作应用程序转换为 Swift 3,以便使用 IOS 图表。现在可以完美运行了。