Flutter Plugin Development native vendored_frameworks file not found - ios

I'm working on the flutter-webrtc plugin for iOS. Previously, the plugin use the prebuilt cocoapods dependency. But, in the WebRTC M80 Release Notes they state they are going to be deprecating the mobile libraries.
To stay up to date with the latest iOS native WebRTC bugfixes and features, we now need to build from source.
I've built from source and I was testing it with WebRTC's AppRTCMobile example app and it is working over there. Now I am trying to import the WebRTC.framework into the flutter plugin and I'm having trouble.
There is no flutter documentation on this, but I followed guidance from this github issue. I've copied the binary built from source into the plugin ios directory and modified the flutter_webrtc.podspec to include the framework, but I'm getting the error:
Xcode's output:
↳
In file included from /Users/corey/Workspace/flutter/flutter-webrtc/ios/Classes/FlutterWebRTCPlugin.m:1:
/Users/corey/Workspace/flutter/flutter-webrtc/ios/Classes/FlutterWebRTCPlugin.h:4:9: fatal error: 'WebRTC/RTCDataChannel.h' file not found
#import <WebRTC/RTCDataChannel.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/corey/Workspace/flutter/flutter-webrtc/ios/Classes/FlutterRTCVideoRenderer.m:1:
In file included from /Users/corey/Workspace/flutter/flutter-webrtc/ios/Classes/FlutterRTCVideoRenderer.h:1:
/Users/corey/Workspace/flutter/flutter-webrtc/ios/Classes/FlutterWebRTCPlugin.h:4:9: fatal error: 'WebRTC/RTCDataChannel.h' file not found
#import <WebRTC/RTCDataChannel.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Planning build
note: Constructing build description
I'm really new to flutter plugin development so I'm not sure if I'm doing this correctly. Any tips would be very appreciated!

After adding the binary to the plugin ios directory, I needed to manually go into my app's ios directory (the app depending on the plugin) and manually run pod install && pod update.
After that, the plugin import errors were fixed and I'm now using WebRTC built from source in the flutter-webrtc plugin :)

Related

Flutter Plugin -- build for iOS works in xCode, but doesn't work with flutter build because of package dependency

I am developing a Flutter plugin, which requires a third party library. This library is hosted on GitHub, and to add it to my project, they tell me to use XCode's package manager (File -> Add Packages). When I do it this way, I can use the package just fine, compile my code and run it on my iPad. However, when I try to use "flutter build ios", it doesn't work.
When building, I see a series of (with actual framework names and file names instead of ...):
note: Removed stale file ...
note: Removed stale file ...
note: Removed stale file ...
Then eventually I will see that the compilation has failed due to being unable to import the library I need. Additionally, when I go back into XCode, I find that the package dependency I had installed is no longer there.
So, what I suspect is happening, is when Flutter builds it is cleaning up all the old frameworks, and running its own pod install. However, since my package is not part of my podspec file, it is being left behind. I am unsure how to get this to work. I've tried adding a line in my podspec file like:
s.dependency 'PackageName'
s.source { :git => 'https://linkToTheGitRepo' }
and then running pod repo update, but when I go to build I still get "Unable to find a specification for PackageName depended upon by my_plugin".
At this point, I just build in XCode and then don't touch it, however this has also caused issues when I go to use the plugin later in another project -- I also cannot use flutter build ios in that project, and I have to do it through XCode. This is an annoying workaround, since I lose the hot reload ability and other nice features of working with Flutter. Any suggestions are appreciated. Thanks.

Missing kernel_blob.bin file in Release folder when build Flutter code into frameworks

I want to create a Flutter module, then I will embbed it to native iOS project.
I'm following Option B in this document of Flutter to create a module.
As in the document, I executed this command:
flutter build ios-framework --output=some/path/MyApp/Flutter/ to generate Flutter code into frameworks.
But when I imported App.xcframework and Flutter.xcframework (from same folder Release), I got this error:
After researched, I followed this document of Flutter, I updated Thin Binary script and add Other Linker Flags.
But when I build Flutter's code into frameworks, only App.xcframework in Debug folder have kernel_blob.bin file.
This is my flutter config:
How to make App.xcframework in Release folder have kernel_blob.bin file?
Thank in advance for your help

libPhonenumber (from Google) on iOS in a Kotlin Native project

I've been struggling to solve a problem.
I'm building a cross platform app (iOS and Android) using Kotlin Multiplatform (KMP) where I need a library from Google (https://github.com/google/libphonenumber).
For Android, I can point to a Maven repo (https://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/8.12.6/).
For iOS, I can use a ObjC port of libPhonenumber via Cocoapods.(https://cocoapods.org/pods/libPhoneNumber-ios).
But, I can't use Kotlin's (cocoapod plugin) to properly recognize the Pod. The plugin appears to fail to build.
Here's the details of my setup:
Xcode v11.5
IntelliJ IDEA v2020.1.2
Cocoapods v1.9.1
Gradle 6.0.1
Sample repo (https://github.com/touchlab/kotlin-native)
NOTE: Within the repo, I'm using ./samples/cocoapods
modify ./samples/cocoapods/kotlin-library/build.gradle.kts
commented out AFNetworking, remove AFNetworking pod
pod("AFNetworking", "~> 3.2.0")
add a new pod
pod("libPhoneNumber-iOS")
modify ./samples/cocoapods/kotlin-library/gradle.properties
change this line:
kotlin.native.home=../../../dist
to this:
#kotlin.native.home=../../../dist
in Terminal in this folder: ./samples/cocoapods/kotlin-library/
./gradlew podspec
This creates a podspec file (libPhoneNumber-iOS.def) in ./samples/cocoapods/kotlin-library/build/cocoapods/defs/
cd from kotlin-library to ios-app folder
cd ../ios-app/
Pod install using the command:
pod install
You'll see something like:
Downloading dependencies
Installing kotlin_library (1.0)
Installing libPhoneNumber-iOS (0.9.15)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
When I build the sample 'ios-app' target: simulator in Xcode, I get the error:
fatal error: module 'libPhoneNumber' not found
I have tried other libPhoneNumber pods, such as:
libPhoneNumberSwift
LTPhoneNumberField
Both fail to build using Kotlin's cocoapods plugin, but work as a Pod without Kotlin's cocoapod plugin.
What am I missing?
This particular problem seems to be caused by the dash in the pod's name. There was already an issue reported on GitHub. For now, it's recommended to workaround this problem by re-naming the module. Changing your kotlin-library/build.gradle.kts like
pod("libPhoneNumber-iOS", moduleName = "libPhoneNumber_iOS")
should help. Please give it a try and tell here or on GH if it works.
I have obtained excellent results by adding the unchanged Javascript version of libphonenumber using JavaScriptCore in IOS. The only part of the library not available yet in Javascript is the geocoder.
I used the concept explained here: https://www.appcoda.com/javascriptcore-swift .
Performance is great and there is no porting involved. Always the latest version available.

Xcode showing error 'No such module' even though I've installed Cocoapods and installed pod file of Dialogflow

I've been making a chatbot using Dialogflow formerly Api.AI but now encountering error while integrating the project to my app written in Swift in Xcode. I'd installed cocoapods using terminal "sudo gem install cocoapods" and using this version of Dialogflow to create the podfile.
All gone well but now when I'm importing inside Xcode in my app's AppDelegate.swift file using import ApiAI or import AI Xcode is showing me error that No such module. Please refer to image.
And on GitHub this library which is written in Swift, showing that it has depreciated and asking me to refer to API.AI's Apple Client library which is in Obj-C and unfortunately I've no expertise in Obj-C.
After installing a pod using Cocoa Pods, you must from that point forward open the workspace rather that the project file. The icons will appear differently in your project like so:
In the image you provided is clearly showing that you have opened the project file not the workspace one.
Go to Pods Build settings and set Build Active Architecture Only to NO. This always helps while using pods. After that clean the project once and then build.
After installing pod you should clean project (shift + command + k) and then builds (command + b) in it a few times. Repeat it a few times if it is not still working.
Hope this help!

RN 0.38.0 React/RCTBridgeModule.h' file not found

This is a long shot, but I've taken over a project done in RN v .38 and I need to update a library and resolve the build issues without updating the version of react native. I'm trying to update the react-native-aws-cognito-js library and while it looks to be compatible with the formatting change of import statements, I'm still not able to get it to build on IOS. Android is fine.
To reproduce my issue I did the following:
react-native init sample --version 0.38.0
cd sample
npm install react-native-aws-cognito-js
react-native link react-native-aws-cognito-js
react-native run-ios
Which fails with:
/node_modules/react-native-aws-cognito-js/ios/RNAWSCognito.h:4:9:
fatal error: 'React/RCTBridgeModule.h' file not found #import
Mobile and RN development is not my wheelhouse, but I'm hoping there is some sort of xcode configuration or tricks I can do to get this working and avoid a major overhaul. Running an upgrade to >.40 would probably take too long and also cause other compatibility issues that I don't have the time to resolve.
Note: I have tried the suggestions in `React/RCTBridgeModule.h` file not found

Resources