KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
325 stars 374 forks source link

Cannot build ios #69

Open monsieurtanuki opened 4 years ago

monsieurtanuki commented 4 years ago

I had no problems with the debug mode, but I cannot build a release because of "bitcode" (or whatever) issues.

At the end of the README there are some suggestions about what to do if we cannot build in iOS.

My own suggestions about that:

Unfortunately today I cannot use your package because I cannot afford to waste too much energy in that iOS nonsense. It would be a valuable, but not an essential feature, for my app.

I hope I'll be able to use this package soon. Thank you and good luck!

mohamedazher commented 4 years ago

I just managed to build my app with this plugin on IOS and managed to upload it. The plugin works well both on Android and iOS with the below setup.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.14.6 18G4032, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)

• No issues found!

The issues mentioned in the readme are more to do with how xcode and iOS building works than the plugin itself.

The following is what worked for me on iOS

  1. Under Build Settings for the overall project (Runner inside the Project Section), set Enable Bitcode = Yes. For all of the Targets below set Enable Bitcode as No
  2. Under Build Settings for the overall Project and the Runner Target (The first under under the Target section), set Always Embed swift standard libraries = Yes. Set this as NO for the Sharing Extension or any other Extension under Targets

Regarding App Groups If you follow the Readme, there is a section asking you to add the Share Extension and the Runner Target to the same App Group and it asks you to create an App Group. This is where i had the biggest issue. If you mess this step, the app builds but sharing does not seem to work. In fact nothing happens when you share to your app. Only Sharing Text works, even that just opens the app and does nothing.

Since my app also uses OneSignal for notifications, i already had an App Group so i just added the same to the Share Extension. This does not work. In fact the following steps are needed for it to work

1) Select the Share Extension from the Target section -> Under Signing & Capabilities -> Click + -> Add App Group. If you already have an App Group added, then simply click on the + Sign below and you would need to name the app group in this format group.YOUR_BUNDLE_IDENTIFIER. eg: group.com.company.app. You can simple copy paste your Bundle Identifier from your Runner target and prefix it with group. 2) Add the same app group to your Runner Target as well. So in the end you would have the Runner Target and the Sharing Extension Target both have the same app group checked/selected. 3) You would need to also update ios/Share Extension/ShareViewController.swift file with your Bundle Identifier. You can see the TODO mentioning the same in the code. Update it as let hostAppBundleIdentifier = "INSERT BUNDLE IDENTIFIER" eg let hostAppBundleIdentifier = "com.company.app" the plugin code simply prepends group. to get the App Group Name so having any other group name does not work.

Also for anyone wanting to debug the Extension on XCODE. You would need to click on the Runner select the Sharing Extension and then click Run. When you do that, it will ask you to select an app to run, you need to select your app, it would then build the app and run it as always but you can now set breakpoints on the ShareViewController.swift file and it would stop there when you attempt to share files from a different app. I had reverted the code to the default one to check if the extension even works.

image

It took a lot of fiddling to find this out as i have very little experience with Xcode and iOS native development. Hope this helps someone.

monsieurtanuki commented 4 years ago

@mohamedazher Thank you, I'll give it a try when I finally implement this extension.

filippkowalski commented 3 years ago

@mohamedazher thank you! That helped me progress with this issue. One more thing that I needed to do was to set the same iOS Development Target. In my case Runner was set to 13.2 and Extension was set to 14.2. Setting them to the same target allowed me to see my app in Share popup.

DamonChen117 commented 3 years ago

For me, to fix the issue "Undefined symbols for architecture armv7" of Share Extension target, when building for real device.

  1. delete Share Extension

  2. modify the podfile: post_install do |installer| installer.pods_project.targets.each do |target| if target.name != "Share Extension" flutter_additional_ios_build_settings(target) end end end

  3. recreate Share Extension

  4. update info.plist

    <key>CFBundleVersion</key>
    <string>1.0</string>
beriaanirudh commented 1 year ago

For bookkeeping, I had a working Share Extension, and I upgraded flutter and this error started popping. I used @mohamedazher but changed all of them to "NO", and it worked for me. Details here https://stackoverflow.com/a/76080055/2464822