How to use cocoapods with a Flutter plugin? - dart

First, I would like to say that I am not a iOS developer.
I am trying to develop a VLC plugin for Flutter. For so, I need to add its pod (pod "MobileVlcKit") to a podfile, right?
But when I create the project (via the command flutter create -t plugin flutter_vlc_kit), the iOS folder inside the project has no podfile.
Also, it does not have any of the .xworkspace or .xcodeproj files that I can open on XCODE for code editing:
How can I add the vlc kit dependency pod (pod "MobileVlcKit") to this plugin?

Add your pod dependency modifying your ios/flutter_vlc_kit.podspec
s.dependency 'MobileVLCKit'
or with the wanted version
s.dependency 'MobileVLCKit', '3.2'
References:
Flutter Plugins
Cocoapods
Then go to your example/ios folder and run pod install.
Then open your Runner.xcworkspace and build your plugin from there.
Note: probably you could encounter this issue - tl;dr (not the best choice) change the build system of XCode to the legacy one.

Related

Install native iOS pod in flutter

I am facing an error while making a flutter plugin on the iOS side while using pods. The pods are installed successfully then also I am able to import them in the file.
The pod in my case which I am trying to use is Freshchat iOS SDK
Steps I have followed to install the pod
Start a new Flutter plugin project.
In .podspec file add s.dependency 'FreshchatSDK'
Run pod install in example/ios folder.
I got an error
The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/nimish/FlutterProjects/freshchat_flutter/freshchat_flutter/example/ios/Pods/FreshchatSDK/FreshchatSDK/libFDFreshchatSDK.a)
I removed use_frameworks! from podfile following this comment .
I ran pod install again and the pods were successfully installed and Pods folder was created which had FreshchatSDK folder in it.
Now I need to have use_frameworks! in my project because other plugins are not compiling because of this.
I added s.static_framework = true in .podspec and use_frameworks! in podfile. Now pod install ran successfully,
After I added the import #import "FreshchatSDK.h" in my Plugin.h file I got the error
error: include of non-modular header inside framework module
I tried this answer but was not able to resolve it.
Please help me resolve this. I'll be respectful of your time.
There is another flutter plugin available here but it has many issues and one unhandled case is making my iOS app crash so I want to make it my own.
There may be problems in the PodFile due to unmatched Targets.
When this happens to me, I used these simple steps.
Delete Podfile
Open Terminal at the specific file
Pod init
Open Podfile and adds Dependencies
Pod install

Running a Github iOS project containing Cocoapods

I'm quite new to iOS development. Let's say I want to use a UI element from Github that uses Cocoapods.
Like this one:
Whisper by hyperslo
After downloading the zip file from Github:
Could someone give a step-by-step guide to
Run the demo project
Integrate the UI element into my own project
Thanks!
Running the demo is a little tricky. Apparently you have to first do a pod install, then open the workspace.
Make sure you have cocoa pods installed. For how to install it, go to https://cocoapods.org
Use the command line to navigate to the directory where the .xcworkspace file is located i.e. /Whisper-master/Demo/WhisperDemo
Run pod install
After that, open up WhisperDemo.xcworkspace in Xcode and you can run the demo.
To install this as a pod of your own project, you first navigate to your project's directory and do a pod init. A Podfile will be generated. Write in the Podfile the following:
platform :ios, '10.0' # or whatever your target platform is
target 'Your target's name' do
use_frameworks!
pod 'Whisper'
end
Then do a pod install. From now on, do not open the .xcodeproj file. Instead, open the .xcworkspace whenever you want to work on the project.

Parse SDK / CocoaPods

I have an objective C iOS app using the Parse SDK.
In the process of moving this app from Parse.com to a self hosted Parse-Server, I need to update the Parse SDK to the latest version. For this update I decided to go with CocoaPods.
This is the first time I touch CocoaPods (after reading and hearing so much good about it).
I found my way, following what I could read here and also based on a few CocoaPods tutorial I quickly viewed.
Having my project "ready", when buiding it I get this error:
#import <ParseUI/ParseUI.h> -----> File not found.
Obviously things have changed place. And I tried a couple of unsuccessful solutions.
So here is my question:
How do I need to change the settings of my project, now that I am using CocoaPods?
In order to use Cocoapods with parse and Parse UI you need to do the following steps:
Create a new file and name it Podfile. This file should be located on your IOS project root folder.
The Podfile should contain at least the following structure if you want to use parse IOS SDK and ParseUI
platform :ios, '8.0'
use_frameworks!
pod 'Parse'
pod 'ParseUI'
# Put more pods in here..
Notice to the platform, you may change it to the minimum version that your app can run on and the use_frameworks! will install all your pod as frameworks and this is mandatory if you like to consume Swift libraries.
Open terminal and navigate to your IOS root directory and enter pod install. This command will install all the pods and dependencies into your project.
After installing you will no longer use the IOS project file from now on you will use a new file which called workspace. The workspace will contain both your project files and the pods project/frameworks files.
Build your project, fix some error (if there are) and run it to make sure that it works as expected .
More CocoaPods commands that you need to know are:
pod update - update all your pods to the latest release or to the release that was mentioned in the Podfile
pod update update specific pod to the latest release or to the release that was mentioned in the Podfile
pod outdated - display out to date pods that are being used inside your project.

Workspace does not build after pod install

I have two swift projects, application and library, where library is a dependency of application. I have a Podfile configured as so;
workspace 'myworkspace'
platform :ios, '9.0'
use_frameworks!
target :library do
project 'library/library.xcproject'
pod 'GCDWebServer', '~> 3.0'
target :application do
project 'application/application.xcproject'
end
end
After running pod install successfully, I open myworkspace in Xcode, and find application as the currently selected scheme. Immediately building results in failure, due to;
No such module 'library'
To solve this I need to change the current scheme to library, build, then switch the scheme back to application and it will successfully build.
Questions;
Is this expected, or a bug in xcode and/or CocoaPods, or have I configured something incorrectly?
Does this mean I need to separately build library anytime library source changes occur to reflect those changes in application builds?
Xcode 7.3, CocoaPods 1.0.1, repo
Try do the followings:
1.Open the 'xxx.xcworkspace' file to run your project. Do not open 'xxx.xcodeproj' to run your project again.
2.Product->Clean->Run
3.Add all the pod targets to 'Linked Frameworks and Libraries' in Project -> General

iOS project not seeing local changes when developing a Cocoapod project

I'm working on a framework that is available via Cocoapods.
I have my project set up using their suggested setup, and their development page says "You can work on the library from its folder on your system." but when I make changes to the files in the "Development Pods" folder and build my project, the changes do not show up.
I've tried running $ pod install on the project, which regenerates the xcworkspace file, but the changes still don't show up. I'm unsure how the changes are being missed, as I've commented out a large chunk of code and added a few NSLogs, but it still runs as if I never made the changes.
I've also tried cleaning the project via xcode.
Any ideas?
Bonus q: What is the correct way to work on a cocoapod framework? The documentation is rather lacking when it comes to setting up a project like this.
Edit: Here's the podfile:
platform :ios, "6.0"
pod "MyFramework", :path => "../"
(using an example name as the pod is't published yet)
The fix was to delete my xcworkspace [rm -rf MyFramework.xcworkspace] and recreate it via pod install.
The only difference I can see is that Pods is now included in the build targets for my demo app's scheme.
Here's the general process for developing a cocoapod.
Run pod lib create <Pod Name> to create your project.
cd MyDirectory
pod lib create MyPod
Make sure to run pod install inside your example project. This will generate a .xcworkspace file.
cd MyPod/Example
pod install
Open your example project via the .xcworkspace file.
Xcode -> File -> Open -> MyPod.xcworkspace
Edit your pod via Pods/Development Pods.
Project Navigator -> Pods -> Development Pods -> MyPod -> <file>
Clean, build, & run your example project.
Make sure to clean (cmd+shift+k) your project before running, otherwise changes made to your pod will not be captured.

Resources