Skip to content

Commit

Permalink
fix xcode compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
achorein committed Oct 8, 2024
1 parent 546c581 commit 1f392b4
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
.DS_Store

# VSCode
.vscode/
.vscode/*
!.vscode/tasks.json
jsconfig.json

# Xcode
Expand Down
136 changes: 136 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Clean and Build dependencies",
"command": "rm -fr node_modules && yarn install && yarn clean && yarn prepare",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./"
}
},
{
"label": "Clean examples dependencies",
"dependsOn": [
"Clean basic example",
"Clean expo-router example",
"Clean react-navigation example"
],
"problemMatcher": []
},
{
"label": "Clean basic example",
"command": "rm -fr node_modules .expo ios android && yarn install",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/basic"
}
},
{
"label": "Clean expo-router example",
"command": "rm -fr node_modules .expo ios android && yarn install",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/expo-router"
}
},
{
"label": "Clean react-navigation example",
"command": "rm -fr node_modules .expo ios android && yarn install",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/react-navigation"
}
},
{
"label": "Fix examples dependencies",
"dependsOn": [
"Fix basic example",
"Fix expo-router example",
"Fix react-navigation example"
],
"problemMatcher": []
},
{
"label": "Fix basic example",
"command": "yarn test:fix && yarn doctor",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/basic"
}
},
{
"label": "Fix expo-router example",
"command": "yarn test:fix && yarn doctor",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/expo-router"
}
},
{
"label": "Fix react-navigation example",
"command": "yarn test:fix && yarn doctor",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/react-navigation"
}
},
{
"label": "Run basic example",
"command": "yarn clean && yarn ios",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/basic"
}
},
{
"label": "Run expo-router example",
"command": "yarn clean && yarn ios",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/expo-router"
}
},
{
"label": "Run react-navigation example",
"command": "yarn clean && yarn ios",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./example/react-navigation"
}
},
{
"label": "Build and watch expo-module",
"dependsOn": ["Build expo-module", "Build expo-module plugin"],
"problemMatcher": []
},
{
"label": "Build expo-module",
"command": "yarn prepare && yarn build",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./"
}
},
{
"label": "Build expo-module plugin",
"command": "yarn build:plugin",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./"
}
}
]
}
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ Simply choose content types you need :
],
```

| Option | Values |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| iosActivationRules | Allow **text** sharing with `"NSExtensionActivationSupportsText": true`<br/>**Url** sharing with `"NSExtensionActivationSupportsWebURLWithMaxCount": 1` and `"NSExtensionActivationSupportsWebPageWithMaxCount": 1`<br/>**Images** sharing with `"NSExtensionActivationSupportsImageWithMaxCount": 1`<br/>**Videos** sharing with `"NSExtensionActivationSupportsMovieWithMaxCount": 1`<br/>**Files and audio** sharing with `"NSExtensionActivationSupportsFileWithMaxCount": 1`<br/>_default value_: `{ "NSExtensionActivationSupportsWebURLWithMaxCount": 1, "NSExtensionActivationSupportsWebPageWithMaxCount": 1 }"`<br/>_More info in apple developper doc [here](https://developer.apple.com/documentation/bundleresources/information_property_list/nsextension/nsextensionattributes/nsextensionactivationrule)_ |
| androidIntentFilters | **one file sharing** array of MIME types :`"text/*"` / `"image/*"` / `"video/*"` / `"*/*"`<br/>_default value_: `["text/*"]` (text and url) |
| androidMultiIntentFilters | **multiple files sharing** array of MIME types : `"image/*"` / `"video/*"` / `"audio/*`/ `"*/*"`<br/>_default value_: `[]` |
| androidMainActivityAttributes | _default value_: `{ "android:launchMode": "singleTask" }` |
| disableAndroid | Disable the android share intent. Useful if you want to use a custom implementation. _default value_: `false` |
| disableIOS | Disable the ios share extension. Useful if you want to use a custom implementation (ex: iOS custom view). _default value_: `false` |
| Option | Values |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| iosActivationRules | Allow **text** sharing with `"NSExtensionActivationSupportsText": true`<br/>**Url** sharing with `"NSExtensionActivationSupportsWebURLWithMaxCount": 1` and `"NSExtensionActivationSupportsWebPageWithMaxCount": 1`<br/>**Images** sharing with `"NSExtensionActivationSupportsImageWithMaxCount": 1`<br/>**Videos** sharing with `"NSExtensionActivationSupportsMovieWithMaxCount": 1`<br/>**Files and audio** sharing with `"NSExtensionActivationSupportsFileWithMaxCount": 1`<br/>_default value_: `{ "NSExtensionActivationSupportsWebURLWithMaxCount": 1, "NSExtensionActivationSupportsWebPageWithMaxCount": 1 }"`<br/>_More info in apple developper doc [here](https://developer.apple.com/documentation/bundleresources/information_property_list/nsextension/nsextensionattributes/nsextensionactivationrule)_<br/>you can also provide a custom query (ex: `"iosActivationRules": "SUBQUERY (...)"`) |
| androidIntentFilters | **one file sharing** array of MIME types :`"text/*"` / `"image/*"` / `"video/*"` / `"*/*"`<br/>_default value_: `["text/*"]` (text and url) |
| androidMultiIntentFilters | **multiple files sharing** array of MIME types : `"image/*"` / `"video/*"` / `"audio/*`/ `"*/*"`<br/>_default value_: `[]` |
| androidMainActivityAttributes | _default value_: `{ "android:launchMode": "singleTask" }` |
| disableAndroid | Disable the android share intent. Useful if you want to use a custom implementation. _default value_: `false` |
| disableIOS | Disable the ios share extension. Useful if you want to use a custom implementation (ex: iOS custom view). _default value_: `false` |

### Expo Router

Expand Down
10 changes: 5 additions & 5 deletions plugin/src/ios/ShareExtensionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@ class ShareViewController: UIViewController {
}

private func handlePdf(content: NSExtensionItem, attachment: NSItemProvider, index: Int) async {
Task.detached { [weak self] in
if let url = try? await attachment.loadItem(forTypeIdentifier: self!.pdfContentType) as? URL {
Task.detached {
if let url = try? await attachment.loadItem(forTypeIdentifier: self.pdfContentType) as? URL {
Task { @MainActor in

await self?.handleFileURL(content: content, url: url, index: index)
await self.handleFileURL(content: content, url: url, index: index)

}
} else {
NSLog("[ERROR] Cannot load pdf content !\(String(describing: content))")
await self?.dismissWithError(
await self.dismissWithError(
message: "Cannot load pdf content \(String(describing: content))")
}
}
Expand All @@ -258,7 +258,7 @@ class ShareViewController: UIViewController {
if let url = try? await attachment.loadItem(forTypeIdentifier: self.fileURLType) as? URL {
Task { @MainActor in

await self?.handleFileURL(content: content, url: url, index: index)
await self.handleFileURL(content: content, url: url, index: index)

}
} else {
Expand Down

0 comments on commit 1f392b4

Please sign in to comment.