Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
KasemJaffer committed Jan 26, 2024
1 parent a9a232e commit f92195a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
95 changes: 53 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
<key>AppGroupId</key>
<string>$(CUSTOM_GROUP_ID)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>

<key>NSPhotoLibraryUsageDescription</key>
<string>To upload photos, please allow permission to access your photo library.</string>
...
```

#### 3. Add the following to your [ios/Share Extension/Info.plist](./example/ios/Share%20Extension/Info.plist):

```xml
....
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppGroupId</key>
<string>$(CUSTOM_GROUP_ID)</string>
<key>CFBundleVersion</key>
Expand Down Expand Up @@ -191,9 +171,31 @@ Make sure the deployment target for Runner.app and the share extension is the sa
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
....
</dict>
</plist>
```
#### 3. Add the following to your [ios/Runner/Info.plist](./example/ios/Runner/Info.plist):

```xml
...
<key>AppGroupId</key>
<string>$(CUSTOM_GROUP_ID)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>

<key>NSPhotoLibraryUsageDescription</key>
<string>To upload photos, please allow permission to access your photo library.</string>
...
```

#### 4. Add the following to your [ios/Runner/Runner.entitlements](./example/ios/Runner/Runner.entitlements):

Expand All @@ -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
Expand All @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/RSIShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open class RSIShareViewController: SLComposeServiceViewController {

// extract host app bundle id from ShareExtension id
// by default it's <hostAppBundleIdentifier>.<ShareExtension>
// 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[..<lastIndexOfPoint!])
let defaultAppGroupId = "group.\(hostAppBundleIdentifier)"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: receive_sharing_intent
description: A flutter plugin that enables flutter apps to receive sharing photos, text or url from other apps.
version: 1.6.2
version: 1.6.3
homepage: https://github.com/KasemJaffer/receive_sharing_intent

environment:
Expand Down

0 comments on commit f92195a

Please sign in to comment.