diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dfcfd1b..3f77b633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.6.3 + +* Updated readme iOS section, rearranged the steps to properly setup the plugin and added a new step #7 + ## 1.6.2 * Requires Swift 5.0 diff --git a/README.md b/README.md index 70416873..c9727f9a 100644 --- a/README.md +++ b/README.md @@ -124,33 +124,13 @@ Add the following filters to your [android/app/src/main/AndroidManifest.xml](./e Make sure the deployment target for Runner.app and the share extension is the same. -#### 2. Add the following to your [ios/Runner/Info.plist](./example/ios/Runner/Info.plist): +#### 2. Replace your [ios/Share Extension/Info.plist](./example/ios/Share%20Extension/Info.plist) with the following: ```xml -... -AppGroupId -$(CUSTOM_GROUP_ID) -CFBundleURLTypes - - - CFBundleTypeRole - Editor - CFBundleURLSchemes - - ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER) - - - - -NSPhotoLibraryUsageDescription -To upload photos, please allow permission to access your photo library. -... -``` - -#### 3. Add the following to your [ios/Share Extension/Info.plist](./example/ios/Share%20Extension/Info.plist): - -```xml -.... + + + + AppGroupId $(CUSTOM_GROUP_ID) CFBundleVersion @@ -191,9 +171,31 @@ Make sure the deployment target for Runner.app and the share extension is the sa NSExtensionPointIdentifier com.apple.share-services -.... + + ``` +#### 3. Add the following to your [ios/Runner/Info.plist](./example/ios/Runner/Info.plist): + +```xml +... +AppGroupId +$(CUSTOM_GROUP_ID) +CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER) + + + +NSPhotoLibraryUsageDescription +To upload photos, please allow permission to access your photo library. +... +``` #### 4. Add the following to your [ios/Runner/Runner.entitlements](./example/ios/Runner/Runner.entitlements): @@ -209,18 +211,7 @@ Make sure the deployment target for Runner.app and the share extension is the sa ``` -#### 5. Make your `ShareViewController` [ios/Share Extension/ShareViewController.swift](./example/ios/Share%20Extension/ShareViewController.swift) inherit from `RSIShareViewController`: - - -```swift -import receive_sharing_intent - -class ShareViewController: RSIShareViewController { - // That's it. You don't need to add any code here :) -} -``` - -#### 6. Add the following to your [ios/Podfile](./example/ios/Podfile): +#### 5. Add the following to your [ios/Podfile](./example/ios/Podfile): ```ruby ... target 'Runner' do @@ -237,14 +228,34 @@ end ... ``` -#### 7. Add Runner and Share Extension in the same group +#### 6. Add Runner and Share Extension in the same group + +* Go to `Signing & Capabilities` tab and add App Groups capability in **BOTH** Targets: `Runner` and `Share Extension` +* Add a new container with the name of your choice. For example `group.MyContainer` in the example project its `group.com.kasem.ShareExtention` +* Add User-defined(`Build Settings -> +`) string `CUSTOM_GROUP_ID` in **BOTH** Targets: `Runner` and `Share Extension` and set value to group id created above. You can use different group ids depends on your flavor schemes + +#### 7. Go to Build Phases of your Runner target and move `Embed Foundation Extension` to the top of `Thin Binary`. + + +#### 8. Make your `ShareViewController` [ios/Share Extension/ShareViewController.swift](./example/ios/Share%20Extension/ShareViewController.swift) inherit from `RSIShareViewController`: -* Go to the Capabilities tab and switch on the App Groups switch for both targets. -* Add a new group and name it as you want. For example `group.YOUR_HOST_APP_BUNDLE_IDENTIFIER` in my case `group.com.kasem.sharing` -* Add User-defined(`Build Settings -> +`) string `CUSTOM_GROUP_ID` in *BOTH* Targets: `Runner` and `Share Extension` and set value to group id created above. You can use different group ids depends on flavor schemes + +```swift +// If you get no such module 'receive_sharing_intent' error. +// Go to Build Phases of your Runner target and +// move `Embed Foundation Extension` to the top of `Thin Binary`. +import receive_sharing_intent + +class ShareViewController: RSIShareViewController { + // That's it. You don't need to add any code here :) +} +``` #### Compiling issues and their fixes +* Error: No such module 'receive_sharing_intent' + * Fix: Go to Build Phases of your Runner target and move `Embed Foundation Extension` to the top of `Thin Binary`. + * Error: App does not build after adding Share Extension? * Fix: Check Build Settings of your share extension and remove everything that tries to import Cocoapods from your main project. i.e. remove everything under `Linking/Other Linker Flags` diff --git a/ios/Classes/RSIShareViewController.swift b/ios/Classes/RSIShareViewController.swift index c4adf109..f796c9f7 100644 --- a/ios/Classes/RSIShareViewController.swift +++ b/ios/Classes/RSIShareViewController.swift @@ -78,7 +78,7 @@ open class RSIShareViewController: SLComposeServiceViewController { // extract host app bundle id from ShareExtension id // by default it's . - // for example: com.test.ShareExtension -> com.test + // for example: "com.kasem.sharing.Share-Extension" -> com.kasem.sharing let lastIndexOfPoint = shareExtensionAppBundleIdentifier.lastIndex(of: ".") hostAppBundleIdentifier = String(shareExtensionAppBundleIdentifier[..