踩坑记录(检索关键字:怎么分享备忘录,备忘录内容分享到app,iOS 备忘录开发)
参考资料:
入门参考资料:
基本资料(了解什么是Share Extension):
https://www.jianshu.com/p/863ce6729455
错误集锦:
1:如何让App Extension访问Cocoapods引入的第三方库:
https://blog.csdn.net/tounaobun/article/details/42218201
2:编译报错(Cycle details)
https://stackoverflow.com/questions/50709330/cycle-inside-building-could-produce-unreliable-results-xcode-10-error/51052891
参考答案
1:In Xcode, go to File->Project/Workspace settings.
2:Change the build system to Legacy Build system.
3:第三库报错
在TARGETS找到Extension,在对应的General找到Linked Frameworks and Libraries 导入对应的第三方库
4:备忘录没有出现自己的App
参考资料:
https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
https://stackoverflow.com/questions/29546283/ios-share-extension-how-to-support-wav-files
如果对于图片,音视频,网页等这种单独文件分享可以根据苹果给出的参考代码来支付分享到自己的App,可以参考
文章最开始的链接,里面有相应的Info.plist截图,这里只讨论备忘录的分享
在最开始的时候看了很多开发文档和资料,没找到如何让备忘录也出现自己的App.这时候就想备忘录是苹果的应用,那应该是data类的,经测试确实可以在备忘录分享出现自己的App.
NSExtensionActivationRule修改为String,复制下面的代码
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data"
).@count == $extensionItem.attachments.@count
).@count >= 1
说明:这段代码是参考苹果文档的代码,具体请参考下面苹果文档:
页面检索关键词:complex or more specific filtering,
5:延伸资料:
以下是苹果给出的TypeIdentifiers:
https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
如果想要在多个文件格式中分享出现自己的App,可以参考苹果给的TypeIdentifiers再按照苹果给的过滤语法拼写即可
6:一些错误解决办法
1:上传到App Store的时候要把Share Extension的Version,Build设置跟主App一致
2:上传App Store出错误:ERROR ITMS-90206:"Invalid Bundle. The bundle at 'XXX.appex' contains disallowed file 'Frameworks'."
解决办法:
TARGETS->主App->Build Settings->搜索Always Embed Swfit Standard Librarise 设置为YES
TARGETS->Share Extension->Build Settings->搜索Always Embed Swfit Standard Librarise 设置为NO
实在不行,可以去Stack Overflow搜索此问题