I have created a flutter module and after running flutter build ios-framework it generates App.xcframework and Flutter.xcframework
How can I specify to something else like MyFlutter.xcframework instead of App.xcframework for my framework
Related
I'm trying to run a flutter app - iOS with the following environment
Xcode Version 13.2.1 (13C100)
flutter sdk: 2.10.5
dart: 2.16.2
mac processor: Intel Core i7
but I get "No such module 'Flutter'" inside a file in extension Target beside my Runner Target so how can I fix that issue?
FINALLY I SOLVED IT.
The problem was there is no "Flutter.xcframework" in my app's flutter module.
The solution
Create a new flutter module in the root of my app using "flutter build ios-framework
--output=Flutter" command inside your app like in "https://docs.flutter.dev/development/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode" and it will create Debug files (if you wanna create Release Files, you should use command "flutter build ios-framework --no-debug --no-profile --release --output=Flutter").
Go to your target > Build Phases > Link Binary With Libraries then drag and drop Flutter.xcframework folder into it like in
"https://docs.flutter.dev/development/add-to-app/ios/project-setup#link-on-the-frameworks".
Go to your target > Build Setting > Framework Search Paths and add $(PROJECT_DIR)/Flutter/[Build-mode]/Flutter.xcframework
respectively.
Clean your build folder & run again.
You try it run flutter clean and flutter pub get and in ios folder run pod install. Good luck!
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
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)))
Hi I just found out that it is possible to create Flutter project with Swift and Kotlin. However, I'm already invested in my current projects and want to recreate the ios and android as Swift and Kotlin (currently they are default to Java and ObjC).
Thanks.
use -i and -a to create new project, like this:
flutter create -i swift -a kotlin project_name
see also:https://docs.flutter.dev/development/platform-integration/platform-channels#example-project
then replace with lib folder from old project.
update 2020.01.13
swift and kotlin are default now. you can use those command to update exist project:
cd project
flutter create .
this command will update your project. then you can merge you old code into new project, and remove old code.
make sure you backup your project before run it, and you know what are you exactly doing
You can also run flutter create -i swift . inside your app folder, to regenerate ios folder.
I've not tested android, but I guess the same should work for it too - flutter create -a kotlin .
I just deleted default ios and android folder in my flutter project.
now in order to generate these default folder again you can use this below command :
flutter create .
Note : "." is also part of command , also make sure that your project folder name should not contain spaces or special characters which are invalid for package name.
How to use local flutter package in another flutter application?
I created a package using following command:
flutter create --template=package my_new_package
and then in my application source code => main.dart
import "package:my_new_package/my_new_package.dart" // can not find the package
Find this file in your flutter application => pubspec.yaml
Use local dependency
dependencies:
flutter:
sdk: flutter
my_new_package:
path: ./my_new_package
Note: The ./my_new_package above means that the my_new_package directory containing the pubspec.yaml for the package is a sub-directory of the app.
If you have the package as a directory at the same level as the app, in other words one level higher up in the directory tree, you can use ../my_new_package (note the double dot) or a full path to the package directory.
Path dependency: A Flutter app can depend on a plugin via a file system path: dependency. The path can be either relative or absolute. For example, to depend on a plugin plugin1 located in a directory next to the app, use the following syntax:
dependencies:
plugin1:
path: ../your_package/
For the full process:
Download the code for the plugin you want to use and place it at the "same" level as your flutter project directory
-- plugin-name
-- your flutter directory -- lib
-- android
-- ios etc etc
Add the plugin path to pubspec.yaml. *If you are unsure of the correct plugin name to use, look at the name: attribute in the plugin's pubspec.yaml file. The plugin directory must also be saved with the same name:
dependencies:
plugin-name:
path: ../plugin-name
Run Pub get and you can import just like any other plugin. Only difference is when you click on any of the plugin classes during development, it will point to the local file.
Hey I had same problem once I started using flutter.
I have implemented example of pdf_view plugin in my app for making changes for Shimmer effect instead of CircularProgressIndicator().
Some Knowledge
You can edit plugins which are get by flutter pub get but they might be replaced when you create app bundle by flutter.
Now your answer with sample plugin suppose take an example of advance_pdf_viewer
GitHub Link
Download zip file and extract it in pdf_viewer/
Make sure pdf_viewer/ has all files including lib, Android, iOS and all related files.
Copy your pdf_viewer folder in your project directory for example
my project is invoice_viewer so it's root directory have all folders such as lib, Android, iOS etc. copy it in this root directory along with lib, Android, iOS.
Now open your pubsec.yaml and write code as follows
dependencies:
flutter:
sdk: flutter
# advance_pdf_viewer: ^2.0.0
advance_pdf_viewer:
path: ./pdf_viewer
In comment I have replaced server version with local one and make changes in plugin's viewer.dart file to achieve desired changes.
Hope you and other got some information from this finding!