如何实现Xamarin.Forms-iOS项目的共享扩展? [英] How to implement Share Extension to Xamarin.Forms - iOS project?
问题描述
我正在尝试对我的Xamarin.Forms
应用程序实施共享扩展.我遵循了这些:
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
当我运行它时,上面的git repo可以正常工作.但是我需要为我的xamarin表单项目实现此功能. 因此,我执行了以下步骤:
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:
1)我右键单击我的xamarin表单解决方案.选择添加后,新项目.我创建了"Share Extension(iOS)"项目. (我选择了.Net Framework 4.7.2)
1) 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)
2)使用ShareViewController创建一个共享扩展项目.我对此没有做任何更改.
2) A Share extension project is created with ShareViewController. I didn't do any change this.
3)我打开了新创建的ShareExtension项目的info.plist.并且我注意了束标识符.例如,我的xamarin项目的捆绑包标识符是"com.xamarin.test",而我的共享扩展项目的捆绑包标识符是"com.xamarin.test.share-extension"
3) 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"
4)我选择了主项目的MinimumOSVersion 10.0和共享扩展.
4) I selected MinimumOSVersion 10.0 of my main project and my share extension.
5)在我的项目中,NSExtension如下:
5) In my project,NSExtension is following:
> <key>NSExtension</key>
> <dict>
> <key>NSExtensionAttributes</key>
> <dict>
> <key>NSExtensionActivationRule</key>
> <dict>
> <key>NSExtensionActivationSupportsFileWithMaxCount</key>
> <integer>1</integer>
> <key>NSExtensionActivationSupportsImageWithMaxCount</key>
> <integer>1</integer>
> <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
> <integer>1</integer>
> <key>NSExtensionActivationSupportsText</key>
> <false/>
> <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
> <integer>1</integer>
> </dict>
> </dict>
> <key>NSExtensionMainStoryboard</key>
> <string>MainInterface</string>
> <key>NSExtensionPointIdentifier</key>
> <string>com.apple.share-services</string>
> </dict>
6)在清理了整个解决方案并重建之后,我将引用共享扩展项目的dll添加到了xamarin ios项目中.之后,我运行该项目. (在iPhone 7 ios 12.0模拟器上)
6) After I cleaned whole solution and rebuilded, 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. Somebody help me please.
推荐答案
您的问题在这里:
在我清理了整个解决方案并重建之后,我添加了参考 与我的xamarin ios项目共享扩展项目的dll.
After I cleaned whole solution and rebuilded, I added to reference shared extension project's dll to my xamarin ios project.
在文档中,当它说到 它必须维护对扩展项目的引用.
您应该右键单击xamarin ios project
-> Add a reference
-> Choose the shared 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.
更新:
这篇关于如何实现Xamarin.Forms-iOS项目的共享扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!