Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for share extension in iOS Flutter app #16712

Closed
mrbm opened this issue Apr 18, 2018 · 21 comments
Closed

Support for share extension in iOS Flutter app #16712

mrbm opened this issue Apr 18, 2018 · 21 comments
Labels
d: examples Sample code and demos p: share The Share plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically

Comments

@mrbm
Copy link

mrbm commented Apr 18, 2018

https://flutter.io/flutter-for-android/#how-do-i-handle-incoming-intents-from-external-applications-in-flutter

Got this to work...but https://flutter.io/flutter-for-ios is empty....

One of the exciting things of flutter is the write once run ios/android...been working magically...until this road block.

Wondering if one of the people on the flutter team more knowledgable than me could add the recipe of how to handle incoming data from external applications into my flutter app in ios.

An example of what I am looking to do in ios that matches the handling incoming intents in android, can be found here:

https://medium.com/@ales.musto/making-a-share-extension-that-accepts-text-and-urls-in-combination-with-coredata-swift-3-a0139c0f9800

Thanks for all your hard work, its been fun!

@zoechi zoechi added platform-ios iOS applications specifically d: examples Sample code and demos p: first party labels Jul 16, 2018
@chetdeva
Copy link

chetdeva commented Aug 5, 2018

I've the same issue. I want to share the browser url into my app. A Share Extension might help. But how to integrate that with Flutter?

@eseidelGoogle
Copy link
Contributor

It looks like the answer is:
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1

I'm not sure there is much to use Fluter for here. The Share Extension shows up in another process, so I suspect it would not be wise to try and bring Flutter code along with, but rather the entire Share Extension should probably be written in Obj-C or Swift.

As far as I can tell this is very different from how Android works, where your actual app would receive the intent (rather than just an extension, paired with your app, which gets loaded briefly into another process during the share action).

@pulyaevskiy
Copy link
Contributor

Wondering if anyone had experience implementing share extensions in Flutter apps? I'm gonna need this feature as well.

@romaluca
Copy link

romaluca commented Sep 20, 2018

I implemented a share extension in my flutter app time ago and it worked till about a month ago.
After that if i try to launch my app in ios, i receive this error:

ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/FBSDKCoreKit'
    ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/FBSDKLoginKit'
    ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/FirebaseMessaging'
    ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/firebase_messaging'
    ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/flutter_facebook_login'
    ld: warning: directory not found for option '-L/Users/luca/IdeaProjects/shuttertop/build/ios/Debug-iphonesimulator/google_sign_in'
    ld: library not found for -lFBSDKCoreKit

If i remove the share extension, my app reworks.
how can I do?
Thanks

Anyway this night i'll post the steps for create it

@pulyaevskiy
Copy link
Contributor

@romaluca you probably need to check Build Settings of your share extension and remove everything that tries to import Cocoapods from your main project.

At least that's how I solved it in my case. What I managed to get:

  1. Created share extension with Obj-C instead of Swift, for some reason it was failing to compile with Swift core libraries not being included in the build. Couldn't figure out how to get it to work.
  2. When XCode creates a share extension it copies a lot of Build Settings to it from the main app so I had to manually delete all references to Cocoapods as well as Flutter stuff from there.
  3. I used NSUserDefaults to share data between extension and the app, which seems to be a recommended way to do it. But also a fairly simple approach.

If anyone can figure out how to use plugins like Firebase in the extension it would be really great.

The best solution would probably be to embed Flutter into the platform view of share extension. ReactNative guys seems to have figured out how to achieve this so I can imagine it should be doable with Flutter too?

@bagintz
Copy link

bagintz commented Nov 6, 2018

I also need something like this. Does anyone have any news on available plugins?

@zoechi zoechi added the plugin label Jan 8, 2019
@zoechi zoechi added this to the Goals milestone Jan 8, 2019
@amirh amirh modified the milestones: Goals, Near-term Goals Jan 10, 2019
@collinjackson collinjackson changed the title Love the android intent example, however we need example for ios too! Support for share extension in iOS Flutter app Feb 13, 2019
@zoechi zoechi added the p: share The Share plugin label Feb 14, 2019
@eqwalker
Copy link

eqwalker commented Mar 4, 2019

I've edited the Runner workspace to add an Action Extension. When I 'flutter build ios' it just builds the extension and not the runner app. It looks like they are looking for the last target in the project and building that? Seems like they should just build the entire Runner app workspace which should allow the developer to do everything they would in a regular Xcode project (frameworks, extensions etc..).

@eqwalker
Copy link

eqwalker commented Mar 4, 2019

or expose the invocation of xcrun in a script so iOS developers can control the process

@eqwalker
Copy link

eqwalker commented Mar 4, 2019

found it in flutter/packages/flutter_tools/bin/xcode_backend.sh

@S60bishoyhanna
Copy link

Any update for this issue ?

@cdharris
Copy link

Does anyone have any pointers for implementing this?

@KasemJaffer
Copy link

KasemJaffer commented May 30, 2019

I also need something like this. Does anyone have any news on available plugins?

I just built a library for this and it's working good so far.

here is the link https://pub.dev/packages/receive_sharing_intent/

@cdharris
Copy link

here is the link https://pub.dev/packages/receive_sharing_intent/

Amazing @KasemJaffer does it support sharing urls from the browser too?

@KasemJaffer
Copy link

@cdharris not for now. The library supports sharing photos only.

@berkayoztunc
Copy link

is there any documentation "How do I handle incoming intents from external applications in Flutter" for ios ?

@dctoai
Copy link

dctoai commented Jun 20, 2019

@cdharris not for now. The library supports sharing photos only.

Hi @KasemJaffer
I downloaded the example in the link https://github.com/KasemJaffer/receive_sharing_intent/tree/master/example and I have some issues:

  1. I cannot built project in flutter and it shows error
    Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ === BUILD TARGET receive_sharing_intent OF PROJECT Pods WITH CONFIGURATION Debug === ld: framework not found receive_sharing_intent clang: error: linker command failed with exit code 1 (use -v to see invocation) Could not build the application for the simulator. Error launching application on iPhone XR.

, but I can build it and run in XCode however when I share images to the app, it does not show anything "the number of shared file" is still 0
Screen Shot 2019-06-20 at 1 48 27 pm

Did I config wrong somewhere?

@jerryzhoujw
Copy link

jerryzhoujw commented Aug 10, 2019

@pulyaevskiy I have create an empty flutter project and add ShareExtension using Xcode. But how to clean Cocopods for the building errors for device only bellow?

Run Target: Share Extension on device

ld: '[Project_Path]/ios/DerivedData/Products/Debug-iphoneos/FMDB/libFMDB.a(FMDatabase.o)' 
does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting 
ENABLE_BITCODE)

Run Target: The Container App on device

* Run custom shell script '[CP] Embed Pods Framworks'....
* Validate [Project_Path]/ios/DerivedData/Products/Debug-iphonos/Runner.app/PlugIns/
  ShareExtension.appe(in target: Runner)
* cd [Project_Path]/ios
* builtin-embeddedBinaryValidationUtility [Project_Path]/ios/DerivedData/Products/
  Debug-iphonos/Runner.app/PlugIns/ShareExtension.appex 
    -siging-cert [someID] 
    -info-plist-path [Project_Path]/ios/DerivedData/Products/Debug-iphonos/Runner.app/Info.plist
* error: Embedded binary is not signed with the same certificate as the parent app. 
  Verify the embedded binary target's code sign settings match the parent app's.
    * Embedded Binary Signing Certificate:    Not Code Signed
    * Parent App Signing Certificate:  iPhone Developer: MyName (XXXXX)

I have create a pure iOS project, and add Pod into it, after change. I open project with workspace and add ShareExtension, it works well on device.

So I think maybe some script related to Flutter setup cause this error ? Or the script in Podfile ?

@pulyaevskiy
Copy link
Contributor

If I remember correctly when you add share ext to flutter project it inherits a bunch of configuration, including importing cocoapods. I had to go over all include paths for share extension and remove cocoapods from there.

Not s huge expert in Xcode though.

@jerryzhoujw
Copy link

jerryzhoujw commented Aug 10, 2019

@pulyaevskiy Thank you,

Because the setting is same as a simple iOS project after setup Pods, then include ShareExtension which works fine.

So I confused which part would cause build different. That's why I was guess if it's related to any flutter script.

Update(Workable Solution)

After overwrite setting in Target: Share Extension: (git diff sample)

LIBRARY_SEARCH_PATHS = "";
OTHER_LDFLAGS = ""; or OTHER_LDFLAGS = "-ObjC";

Run Target: ShareExtension & Target: Container App both works on device.

@iapicca
Copy link
Contributor

iapicca commented Mar 11, 2020

Hi @mrbm
share plugin appear to work with most (ipad issue) of ios devices,
I feel safe to close this issue,
if you disagree please write in the comments
and I will reopen it.
Thank you

@iapicca iapicca closed this as completed Mar 11, 2020
@lock
Copy link

lock bot commented Apr 4, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 4, 2020
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
d: examples Sample code and demos p: share The Share plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically
Projects
None yet
Development

No branches or pull requests