Using Cocoapods libraries in Flutter iOS platform specific code
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.
julient-monisnap
Updated on June 07, 2022Comments
-
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 inAppDelegate.swift
file.What I tried so far is run
pod init
inios/
folder and then add my pod (pod 'Charts'
for example) and runpod 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
toPods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig
or include thePods/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 over 5 yearsHi, 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 over 5 yearsThanks ! It's been a while so i already solved the issue but i forgot to add it to my original post ^^'
-
Praveena almost 5 yearsIn my case, these are automatically added.
-
Oliver Dixon about 4 yearsThis will get deleted on project clean.