Using Cocoapods libraries in Flutter iOS platform specific code

15,202

Solution 1

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

Solution 2

Just put your pods at the end of Podfile file which is under the ios folder, like:

pod 'UMCAnalytics'

By default there are some codes in this file but just ignore them and add your pod to below them. After that, run:

pod update 

then you will see the pods installed.

Share:
15,202
julient-monisnap
Author by

julient-monisnap

Updated on June 07, 2022

Comments

  • julient-monisnap
    julient-monisnap almost 2 years

    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!

  • julient-monisnap
    julient-monisnap over 5 years
    Hi, thanks for the answer. However, my problem is that i cannot find any Podfile in the flutter generated app (in ios/ folder for example). Should i create one with pod init ? Or there is another way of doing it ?
  • julient-monisnap
    julient-monisnap over 5 years
    Thanks ! It's been a while so i already solved the issue but i forgot to add it to my original post ^^'
  • Praveena
    Praveena almost 5 years
    In my case, these are automatically added.
  • Oliver Dixon
    Oliver Dixon about 4 years
    This will get deleted on project clean.