Using Cocoapods libraries in Flutter iOS platform specific code

julient-monisnap picture julient-monisnap · Dec 5, 2018 · Viewed 15.4k times · Source

I'm trying to use a Cocoapods library (for an external SDK) but I haven't found any documentation to do it. I've already integrated it in the Android part by just adding a line to the Gradle file.

Simply, I would like to create (or maybe find) a podfile where I could add my dependency and use it in AppDelegate.swift file.

What I tried so far is run pod init in ios/ folder and then add my pod (pod 'Charts' for example) and run pod install but it says:

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target Runner to Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig or include the Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig in your build configuration (Flutter/Release.xcconfig).

And then when I try to build on Xcode, it gives me this error:

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

I think I'm doing it the right way and I've found nothing to help me on Flutter.io documentation.

Thanks in advance for your help!

Answer

dadougster picture dadougster · Jan 24, 2019

After you run pod init and pod install in the ios/ folder, add

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

to ios/Flutter/Debug.xcconfig

and add

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

to ios/Flutter/Release.xcconfig