Using Cocoapods libraries in Flutter iOS platform specific code
Asked Answered
S

3

12

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!

Sluggard answered 5/12, 2018 at 10:27 Comment(2)
Can you post your Podfile content please?Dinosaurian
I just added some details to specify what i've tried but my problem is that i don't know the correct way to add cocoapods libraries to ios side of Flutter app.Sluggard
P
51

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

Proline answered 24/1, 2019 at 16:30 Comment(3)
Thanks ! It's been a while so i already solved the issue but i forgot to add it to my original post ^^'Sluggard
In my case, these are automatically added.Supersonics
This will get deleted on project clean.Diadiabase
K
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.

Kale answered 6/8, 2019 at 0:54 Comment(0)
D
0

Did you add your project target to your Podfile? Something like that:

def swift_frameworks
  pod 'PodName', 'X.X'
end


target 'My Project' do
  swift_frameworks
end
Dinosaurian answered 5/12, 2018 at 14:1 Comment(1)
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 ?Sluggard

© 2022 - 2024 — McMap. All rights reserved.