I was able to follow the instructions on https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps to add Flutter as a dependency to a simple single view app and display a FlutterViewController, but did not have success trying the same process for a cocoa touch framework that depends on Flutter.
Is this currently possible? My hope was to be able to build a standalone iOS SDK that is powered by Flutter that other iOS apps could depend on with no direct dependency on Flutter.
Specifically when I tried the SDK approach, Flutter imports failed to resolve with errors relating to not being able to find the Flutter module imports:
[Xcode build error][1]][1]
error: no such module 'FlutterPluginRegistrant'
import FlutterPluginRegistrant
error: no such module 'Flutter'
import Flutter
Update:
These are the error logs I was seeing initially, but was able to get around them by vendoring the FlutterPluginRegistrant.framework and Flutter.framework with Cocoapods. With that my main app compiles fine when linked to my FlutterSDK framework that includes the flutter dependencies. The issue I'm running into now is with setting up FlutterViewController and it's FlutterEngine / FlutterDartProject to point to the correct paths within the framework for the flutterAssets / dartMain / packages urls. I'm not sure how to pull these in from the framework.
If you want to build a Framework that is essentially _just_ a Flutter module, where other iOS apps can use it without having to install/depend on Flutter SDK themselves, then yes, this can be done via one of the flutter/add-to-app options for iOS:
Option B - Embed frameworks in Xcode
also refer to the github/flutter/ios_using_prebuilt_module sample
On the other hand, if you are talking about integrating Flutter into an existing Framework, Flutter + Cocoa Touch, then no, this is currently not supported, but is being explored:
https://github.com/flutter/flutter/issues/39027
note that this would be termed “add-to-library” as opposed to "add-to-app"
also mentioned, flutter/add-to-app:
Packing a Flutter library into another sharable library or packing multiple Flutter libraries into an application isn’t supported.
Related
Assuming I have a basic flutter app and I add a target in xcode for the ios app. Would there be any way to link it to the main Flutter folder so I can do an "import Flutter" in the extension the same way it's done in the AppDelegate then start a FlutterEngine, MethodChannel etc locally in the extension ?
I partially succeded adding a module compiled as an "ios-framework" (otherwise with cocoapods there's a dependency conflict error) to the extension xcode target, yet this means including a redundant Flutter dependency and although it runs, I'm not sure at this point this is very stable... For this reason I'm wondering if there's a way to make an import of the main Flutter directly ?
Thanks
I'm trying to integrate IronSource SDK in a iOS Flutter project (Swift project), but I am unable to do that. According to the IronSource documentation, I must point to IronSource.h file to include the bridge I need. And I am able to implement it in normal Xcode swift project, but I am unable to do that in flutter project since this bridge is already used by the flutter and it can be only one file.
So the question is: How can I integrate another ObjC library (IronSource) in the existing flutter ios project?
I am new to iOS development and Im battleing this for about a week now. I cant find anything on the internet that would work so any help will be much appreciated. Thanks
I managed to resolve my issue. It turns out that build paths are not case sensitive and I was using 'ironsource' for my plugin name but IronSourceSDK is using 'IronSource' so it looks like at build time it did not find the correct files.
And when this was working, I had to add 'use_frameworks! :linkage => :static' in the pod file of the plugin.
Then I could depend on it in my swift flutter app normally as any other plugin.
I have an iOS app using AWS amplify for the backend. I am using Xcode 13 and SwiftUI.
I previously added the Amplify framework using Cocoapods however I was unable to get the framework to work with the extension.
So I recently switched to Swift Package Manager. I added the package to my main project. Then I went to my Share Extension and in General - Frameworks and Libraries and manually added the libraries.
After doing this the app builds and runs and both the main app and extension work fine and are able to use the libraries.
The problem is that I cannot archive and upload the app to the App Store. I get the following error:
CFBundleIdentifier Collision. There is more than one bundle with the
CFBundleIdentifier value 'com.amazonaws.AWSAuthCore' under the iOS
application 'MyAPP.app'. With error code
STATE_ERROR.VALIDATION_ERROR...
I went on many forums and spent many hours trying to fix this but to no avail. The suggestions are to click 'do not embed' for the libraries but that option is not available for me.
I wonder if there is anyway to resolve this?
Below are my General and Build Phases for the Share Extension:
Just remove explicit Amplify dependency from extension, ie. next section should be empty
Make sure (it should be automatically, but anyway)
Link Frameworks Automatically parameter (in Build Settings) is true
Runpath Search Path parameter is related to main bundle
So as targets from SPM are built in same location as product and extension and automatic framework linking is enabled the imported modules in extension will available and linked automatically and due to run paths are set the frameworks will be found in run-time as well.
Note: of course in main app target all should be included
Tested with Xcode 13.1 / iOS 15.1
My app has Service & Content Extension Notifications targets for
supporting Rich Remote Notifications which work as expected on
iPad/iPhone iOS 13 & below
I have installed Xcode 11-beta & macOS Catalina 10.15-beta
On building with the new UIKitForMac I get the following error -
"UserNotificationsUI" is not available when building for UIKit for
Mac. You may need to restrict the platforms for which this framework
should be linked in the target editor.
First tried adding #if canImport() ... #endif around instances of UserNotificationsUI which didn't work
Then removed the Extension Targets which is also not working.
Anyone facing a similar issue?
A closed source Third party framework that I was using had UserNotificationsUI linked.
The build error was because UIKitForMac doesn't support Mobile specific frameworks like UserNotifications which is the correct behaviour.
Removing the Third Party dependency resolved the issue for me.
It seems like just about every tutorial and blog post out there has you integrating RN into an existing app using CocoaPods. Adding CocoaPods support isn't a possibility for our existing iOS app - we are relying on Carthage for dependency management already which doesn't seem to be supported by RN.
So, I went through the process of adding the dependencies manually by attempting to recreate the iOS app that is produced when using the RN CLI (react-native init):
-Add the React.xcodeproj from node_modules/react-native to my Libraries folder, and also add the other Libraries from node_modules/react-native/Libraries, such as RCTActionSheet.xcodeproj. Then, I added all of those to the 'Link Binary With Libraries' section in Build Phases.
-Updated 'Other Linker Flags' to -ObjC -Ic++.
...My app build is still failing with "RCTRootView.h file not found".
Does anyone have experience with just adding RN manually to an existing iOS project, that might be able to provide a definitive list of steps for adding it manually to an existing project?
In addition to the other steps, I also needed to update the HeaderSearchPaths setting to point to the React folder in node_modules: http://i.imgur.com/jK0IMZN.jpg