I am trying to implement a share extension to my Xamarin.Forms
app. And I followed these:
https://docs.microsoft.com/tr-tr/xamarin/ios/platform/extensions
https://docs.microsoft.com/en-us/samples/xamarin/ios-samples/ios8-share/
https://github.com/xamarin/ios-samples/tree/master/ios8/Share
And git repo above works when I run it. But I need to implement this for my xamarin forms project. So I did this steps:
I right clicked to my xamarin forms solution. After I select add, new project. And I created "Share Extension (iOS)" project. (I choosed .Net Framework 4.7.2)
A Share extension project is created with ShareViewController. I didn't do any change this.
I opened info.plist of new created ShareExtension project. And I paid attention bundle identifier. For example my xamarin project's bundle identifier is "com.xamarin.test" and my share extension project's bundle identifier is "com.xamarin.test.share-extension"
I selected MinimumOSVersion 10.0 of my main project and my share extension.
In my project,NSExtension is following:
NSExtension NSExtensionAttributes NSExtensionActivationRule NSExtensionActivationSupportsFileWithMaxCount 1 NSExtensionActivationSupportsImageWithMaxCount 1 NSExtensionActivationSupportsMovieWithMaxCount 1 NSExtensionActivationSupportsText NSExtensionActivationSupportsWebURLWithMaxCount 1 NSExtensionMainStoryboard MainInterface NSExtensionPointIdentifier com.apple.share-services
After I cleaned whole solution and rebuilt it, I added to reference shared extension project's DLL to my Xamarin iOS project. After that I run the project (on iPhone 7 iOS 12.0 simulator).
When I open photos and I click share for a photo, I expect to see my app on share menu. But it doesn't work. I guess I missed a step but what is this, I don't know.
Your problem is here:
After I cleaned whole solution and rebuilded, I added to reference shared extension project's dll to my xamarin ios project.
In the document, when it says about Container app project requirements :
It must maintain a reference to the Extension project.
You should right click the xamarin ios project
--> Add a reference
--> Choose the shared extension project
. What you are doing is a opposite way.
So remove the wrong reference and add the new reference, clean and rebuild your solution, run again.
Update:
Can Deployment Targets be different?I added Share extension it worked directly. Info.plist also looks correct. Is Deployment Target iOS 12+?
Edit: First answer is another question's answer. Let's think as if it didn't never exist :)
As stated here , you want to make sure all the project references are correct. Another important thing when testing on a device, make sure you do so in release configuration with the linker on, as it is clarified here .
And finally, if you want to use your Xamarin.Forms UI (Xaml pages) in your extension, follow this recently published walkthrough .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.