Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ios: folder picker and readdir * update README.md Co-authored-by: Weihua Lu <luwh364@gmail.com> Co-authored-by: leizhe <leizhe@leizhedeMacBook-Air.local>
- Loading branch information
1 parent
c7fa6ca
commit 425f688
Showing
10 changed files
with
215 additions
and
10,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// FolderPicker.m | ||
// App | ||
// | ||
// Created by weihua on 9/29/21. | ||
// | ||
|
||
#import <Capacitor/Capacitor.h> | ||
|
||
CAP_PLUGIN(FolderPicker, "FolderPicker", | ||
CAP_PLUGIN_METHOD(pickFolder, CAPPluginReturnPromise); | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// FolderPicker.swift | ||
// App | ||
// | ||
// Created by weihua on 9/29/21. | ||
// | ||
|
||
import Capacitor | ||
import Foundation | ||
import MobileCoreServices | ||
|
||
@objc(FolderPicker) | ||
public class FolderPicker: CAPPlugin, UIDocumentPickerDelegate { | ||
|
||
public var _call: CAPPluginCall? = nil | ||
|
||
@objc func pickFolder(_ call: CAPPluginCall) { | ||
|
||
self._call = call | ||
|
||
DispatchQueue.main.async { [weak self] in | ||
let documentPicker = UIDocumentPickerViewController( | ||
documentTypes: [String(kUTTypeFolder)], | ||
in: UIDocumentPickerMode.open | ||
) | ||
|
||
documentPicker.allowsMultipleSelection = false | ||
documentPicker.delegate = self | ||
documentPicker.modalPresentationStyle = UIModalPresentationStyle.fullScreen | ||
|
||
self?.bridge?.viewController?.present( | ||
documentPicker, | ||
animated: true, | ||
completion: nil | ||
) | ||
} | ||
} | ||
|
||
public func documentPicker( | ||
_ controller: UIDocumentPickerViewController, | ||
didPickDocumentsAt urls: [URL] | ||
){ | ||
var items: [String] = [] | ||
|
||
for url in urls { | ||
items.append(url.absoluteString) | ||
} | ||
|
||
self._call?.resolve([ | ||
"path": items.first | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
{ | ||
"appId": "com.logseq.app", | ||
"appName": "Logseq", | ||
"webDir": "public", | ||
"bundledWebRuntime": false, | ||
"server": { | ||
"url": "http://192.168.50.122:3001", | ||
"cleartext": true | ||
"webDir": "public", | ||
"plugins": { | ||
"SplashScreen": { | ||
"launchShowDuration": 3000, | ||
"launchAutoHide": false, | ||
"androidScaleType": "CENTER_CROP", | ||
"splashImmersive": true, | ||
"backgroundColor": "#002b36" | ||
} | ||
} | ||
"server": { | ||
"url": "http://192.168.0.104:3001", | ||
"cleartext": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Installation: | ||
|
||
* Install Xcode 13 from App Store. | ||
* Install [CocoaPods](https://cocoapods.org/) | ||
```shell | ||
sudo gem install cocoapods | ||
``` | ||
Note: use the following commands from *ios/App* directory to fix **ffi_c.bundle** related issue for M1 MacBook [^1]. | ||
```shell | ||
sudo arch -x86_64 gem install ffi | ||
arch -x86_64 pod install | ||
``` | ||
* Run `yarn && yarn app-watch` from the logseq project root directory in terminal. | ||
* Open Logseq project in Xcode by running the following command in termimal. | ||
```shell | ||
npx cap open ios | ||
``` | ||
Note: for the first time after a fresh clone. | ||
- Run `npx cap copy ios` to copy web assets from public to *ios/App/App/public*, and create *capacitor.config.json* in *ios/App/App*. | ||
- Run `npx cap update ios` to update iOS plugins. | ||
- Add the following code to *ios/App/App/capacitor.config.json*, and replace `server url` with your local-ip-address:3001 (run ifconfig to check) | ||
```json | ||
"server": { | ||
"url": "http://your-own-id-address:3001", | ||
"cleartext": true} | ||
``` | ||
* Run logseq | ||
```shell | ||
npx cap run ios | ||
``` | ||
|
||
[^1] https://github.com/CocoaPods/CocoaPods/issues/10220#issuecomment-730963835 | ||
|
Oops, something went wrong.