Search code examples
iosxcodecompilationlinkerios-charts

ios-charts: unable to import library to a new project


I am unable to integrate the iOS-chart project / library in a custom project.

Here are the steps I do:

  • open the demo application on Xcode
  • locate the charts library in the original demo code

enter image description here

  • click on show in finder and copy the items to the new project
  • the new project has now 2 targets. I check that the target containing the view (ChartIn) does actually link to the library. It does.
  • I compile the library (in the new project)
  • I then compile and run the ChartIn but I get the following error:

dyld: Library not loaded: @rpath/Charts.framework/Charts Referenced from: /private/var/mobile/Containers/Bundle/Application/0C7EC6DC-94B6-4205-8E71-0F704B2A7523/ChartIn.app/ChartIn Reason: image not found

enter image description here


Solution

  • I can only quote:

    In order to correctly compile:

    Drag the Charts.xcodeproj to your project
    Go to your target's settings, hit the "+" under the "Embedded Binaries" section, and select the Charts.framework
    Temporary workaround: Xcode 6.3.1 has a bug, where you have to build your project once before actually writing the @import line. So hit "Build" now!
    @import Charts
    When using Swift in an ObjC project:
        You need to import your Bridging Header. Usually it is "YourProject-Swift.h", so in ChartsDemo it's "ChartsDemo-Swift.h". Do not try to actually include "ChartsDemo-Swift.h" in your project :-)
        Under "Build Options", mark "Embedded Content Contains Swift Code"
    

    If you want to compile for iOS 7:

    Drag the code itself (.swift files) to your project. As sadly, Swift currently does not support compiling Frameworks for iOS 7.
    Make sure that the files are added to the Target membership.