iOS 備忘錄如何分享到App(Share Extension)

踩坑記錄(檢索關(guān)鍵字:怎么分享備忘錄,備忘錄內(nèi)容分享到app,iOS 備忘錄開發(fā))
參考資料:

入門參考資料:

基本資料(了解什么是Share Extension):
http://www.itdecent.cn/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,在對應(yīng)的General找到Linked Frameworks and Libraries 導(dǎo)入對應(yīng)的第三方庫

4:備忘錄沒有出現(xiàn)自己的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

如果對于圖片,音視頻,網(wǎng)頁等這種單獨文件分享可以根據(jù)蘋果給出的參考代碼來支付分享到自己的App,可以參考
文章最開始的鏈接,里面有相應(yīng)的Info.plist截圖,這里只討論備忘錄的分享
在最開始的時候看了很多開發(fā)文檔和資料,沒找到如何讓備忘錄也出現(xiàn)自己的App.這時候就想備忘錄是蘋果的應(yīng)用,那應(yīng)該是data類的,經(jīng)測試確實可以在備忘錄分享出現(xiàn)自己的App.
NSExtensionActivationRule修改為String,復(fù)制下面的代碼

SUBQUERY (
    extensionItems,
    $extensionItem,
    SUBQUERY (
        $extensionItem.attachments,
        $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data"
    ).@count == $extensionItem.attachments.@count
).@count >= 1

說明:這段代碼是參考蘋果文檔的代碼,具體請參考下面蘋果文檔:

頁面檢索關(guān)鍵詞:complex or more specific filtering,

https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1

5:延伸資料:
以下是蘋果給出的TypeIdentifiers:
https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
如果想要在多個文件格式中分享出現(xiàn)自己的App,可以參考蘋果給的TypeIdentifiers再按照蘋果給的過濾語法拼寫即可

6:一些錯誤解決辦法

1:上傳到App Store的時候要把Share Extension的Version,Build設(shè)置跟主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 設(shè)置為YES
TARGETS->Share Extension->Build Settings->搜索Always Embed Swfit Standard Librarise 設(shè)置為NO
實在不行,可以去Stack Overflow搜索此問題

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容