What is the best practice to include third party ios sdk framework in react-native module library? - ios

I am trying to include ios sdk framework in my react-native module library. I turned always embed swift standard library to Yes in build setting. Everything compiles fine.
Then I include the node module in an app using npm i react-native-my-framework, open sampleapp.xcworkspace and build in XCode, I get an error MyFramework/MyFramework-Swift.h not found. I tried following permutation combinations:
Put MyFramework to Frameworks, Library and Embedded Contents. and tried some other combination of build settings.
Set the framework search path in the library project - $(PROJECT_DIR)/../node_modules/react-native-my-framework/ios/
I manually included libMyFramework.a to Libraries group.
But I am still facing the same issue. What am I missing here?
Also, MyFramework is not on Cocoa pods
Update:
Now MyFramework is available on Cocoapods

Related

Exposing flutter module as IOS framework results in "Failed to find assets path for "Frameworks/App.framework/flutter_assets"

I am receiving Failed to find assets path for "Frameworks/App.framework/flutter_assets when trying to expose a Flutter project via a framework to another IOS project (Add to App via a Framework).
I created a Flutter project that i now want to expose as a native Framework for IOS. We want to share our project with other companies so that they can integrate it in their IOS application.
I followed the documentation described on https://flutter.dev/docs/development/add-to-app/ios/project-setup and i used option C. This will create an XCFramework of our Flutter module and integrate it in our native IOS Framework which will have an API to work with the flutter project. In that way our IOS Framework can be seen as an Umbrella kind of Framework but also with an exposed API.
So what i created is:
A Flutter module
An IOS Framework
An IOS Project
I build the flutter module using ./flutterw build ios-framework --cocoapods --xcframework --no-universal --output=../WhiteLabelIOSFrameWork/Flutter --verbose into the IOS Framework. I added the libraries to the Framework and i created a codespec file for the Framework with only Flutter as a dependency. Afterwards i added a Podfile to the project and added the Framework as a dependency.
All of this is working (i only needed to upgrade to Flutter 1.24.X to have this fix available https://github.com/flutter/flutter/pull/69736). But when i start my Flutter engine it's unable to find the flutter_assets (Failed to find assets path for "Frameworks/App.framework/flutter_assets).
I tried building the ios-framework directly into our IOS project and skip the in between Framework and then it seems to work. So i think it cannot find the flutter_assets since the App.framework is not in the IOS project itself, but in a Framework in between.
Is there a way to move the flutter_assets path or so? Or any other idea on how to solve this?
Kind regards,
Daan
This issue cause when you create Flutter Engine without FlutterDartProject.
Just add FlutterEngine(name: "your name", project: FlutterDartProject(precompiledDartBundle: Bundle.init(for: Self.self)))

Module 'SocketIO' was not compiled with library evolution support; using it means binary compatibility for framework can't be guaranteed

When I install SocketIO in my Framework project using Swift Package Manager the build is successful but there is a warning "Module 'SocketIO' was not compiled with library evolution support; using it means binary compatibility for 'framework name' can't be guaranteed".
Note: I enabled Build Libraries for Distribution to YES in both project target. Socket IO framework I installed in my framework project using Swift Package Manager.(Using cocoa pods xcframework generation is not working for SocketIO).
Eventually I have to generate XCFramework out of this framework project, even If I generate XCFramework with the warning the final .xcframework is not support when I import it any project. Xcode says "Fail to load module SocketIO"
Can any one help me on this? I tried many possibilities from last one week.
Thanks in advance.
I have the same problem. I think, that we have to wait for Xcode 11.4 and Swift 5.2 release. Then, we can try to create Package.swift for our xcframework and list all dependencies there e.g. SocketIO.
The client app will fetch this manifest and resolve all dependencies.

How to import external iOS framework in flutter plugin?

I'm doing a flutter plugin for stream video by using RTSP protocol. I had no problem develop it for Android, but in iOS things are more complex. I have to use an external library (SGPlayer) for getting the player work. I also downloaded the demo that uses this library and seems to work. This library is NOT on Cocoapods and I need to import it directly into the plugin project from my file system. the downloaded and compiled file structure of the plugin that I would like to use looks like this:
My problem is adding the ".framework" extension file correctly to the iOS project in a way that I can use it to develop the flutter plugin (iOS part).
UPDATE:
I built the project with the framework by using instructions at this link: https://github.com/flutter/flutter/issues/17978
The problem now is that while compiling the framework it change the umbrella header because, I think, it's not using the framework module.modulemap but another one. The result is that is importing just some header and implementations, and not all.
1.Place myFramework.framework to iOS plugin folder /ios ex: myPlugin/ios
2.Update iOS plugin file: myPlugin/ios/myPlugin.podspec
Adding the below line at the bottom of the file, above 'end'
s.vendored_frameworks = 'myFramework.framework'
In Terminal : cd to myPlugin/example/ios
run command
pod install
or
pod update
Now we can find the iOS plugin code by open iOS project (example/ios/Runner.xcworkspace) in XCode and go to
#Lorenzo you can pack your plugin and make private CocoaPod or Carthage repo.
Here is a good article howtos

can't find ios framework headers in react native module library

I've included an iOS framework in the xcode project for the React Native module library I'm creating. Everything compiles fine when I build the ios project in the RN library itself, but once I npm install the library into my main RN project, running react-native link <project-name>, and then build in xcode, the included framework headers are not found.
I checked the normal build settings (Header, Framework, and Library search paths) and they all have $(inherited) listed.
Repo for the react native library that is WIP https://github.com/bsy/react-native-pollfish
Download SDK file from here . May be owner removes the SDK from github.
Please add this line in your package.json file.
"rnpm": {
"ios": {
"sourceDir": "./ios"
}
}
Also, unable to install your plugin with "npm install".
The solution to this issue was to make sure that both your Xcode subproject and your main Xcode project both point to a relative path to the SDK.
Steps to take:
Open your application's Xcode project.
If you don't have a Frameworks group in your project, create one.
Open ~/Documents/PollfishSDK using Finder.
Drag the pollfish.framework file into the Frameworks group of Xcode's Project Navigator. In the displayed dialog, choose Create groups for any added folders and deselect Copy items into destination group's folder. This references the SDK where you installed it rather than copying the SDK into your app.
For 3rd party framework set the framework search path in the library project-
$(SRCROOT)/../../../ios/Pods/3rd_party_framework_folder_name

Include of Non Modular Header and file not found for sqlite3.h in Swift with AWS SDK

I'm caught between two very peculiar errors in an iOS Swift project. When I attempt to compile my project, I receive a "Include of Non-modular header" error due to several files in the AWSCore framework of the AWS iOS SDK requiring "sqlite3.h" as an import.
After spending several hours looking for solutions, I eventually copied a copy of the file into the AWSCore folder in my project from Cocoapods, and this removes the issue, compiling my project successfully. However, when I clean the build and attempt to rebuild, I receive a "Lexical or Preprocessor issue - file not found" due to the extra SQLite3.h file.
When I remove it, the compile process will go up to the "include of Non-modular header" error again.
I have already tried nearly all of the common solutions - set include of modular headers to yes, removing the framework and readding, adding "." to the header/framework search paths recursively. I'm now completely stumped, so any help would be greatly appreciated. Thanks!
could you provide more details about this problem?
"several files in the AWSCore framework of the AWS iOS SDK requiring "sqlite3.h" as an import." could you provide a list of files that causes the error? May I know what version of AWS Mobile SDK are you using? Did you installed it by using Cocoapods or downloaded from Amazon Website?
Have you tried changing the build setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES or 'Allow Non-module includes In Framework Modules' to Yes? Just search 'module' in the Frameworks Build Settings to find it. You may need to clean the build first before change this setting.

Resources