Search code examples
iosobjective-cswiftios-chartsmach-o

Using (ios-charts) framework in obj-c project in xcode 8.2.1 cuasing apple mach-o linker error


I'm using

danielgindi/Charts

Framework version : 3.0.1 in my obj-c project.

All other frameworks are in swift ( like AFNetworking ) but at this Framework I get some errors like :

error: /Users/pooya/Library/Developer/Xcode/DerivedData/MY-Project/Build/Products/Debug-iphoneos/Charts.framework: No such file or directory

this error happens when I'm trying to build on my iPhone 7!

But when I'm trying to run it on some 64bit simulator ( like iPhone 6s ) I get this error :

ignoring file /Users/pooya/Library/Developer/Xcode/DerivedData/ZF_Vendor-cgqfmefljmubdqfloevghfslaasp/Build/Products/Debug-iphonesimulator/Charts.framework/Charts, file was built for i386 which is not the architecture being linked (x86_64): /Users/pooya/Library/Developer/Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/Charts.framework/Charts
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$__TtC6Charts12BarChartData", referenced from:
      objc-class-ref in ChartsViewController.o
  "_OBJC_CLASS_$__TtC6Charts15BarChartDataSet", referenced from:
      objc-class-ref in ChartsViewController.o
  "_OBJC_CLASS_$__TtC6Charts17BarChartDataEntry", referenced from:
      objc-class-ref in ChartsViewController.o
  "_OBJC_CLASS_$_ChartDefaultValueFormatter", referenced from:
      objc-class-ref in ChartsViewController.o
  "_OBJC_CLASS_$_ChartDefaultAxisValueFormatter", referenced from:
      objc-class-ref in ChartsViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

but in iPhone 5 and other 32bit simulators it work Fine :|

I'm searching for three days and find no good help for this!

I added this framework by cocapods with this config :

post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '3.0'
      end
   end
  end

Solution

  • The problem was Xcode catch !

    There was a default build for this framework (that was i386 ) and after building Xcode catches it to devel files !

    Try to clean by command + option + shift + k :)

    And don't forget to set the architecture SDK to iOS for charts in pods in Xcode !

    No need to add binary framework to your target ( as written in github )