chore(ios): merge with old code

This commit is contained in:
砍砍 2024-12-17 12:09:14 +08:00
parent a2a3e6ede1
commit d285599556
5 changed files with 84 additions and 5 deletions

View File

@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
5075136A2D1924C600AD60C0 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507513692D1924C600AD60C0 /* RootViewController.swift */; };
5075136E2D1925BC00AD60C0 /* IntelligentsPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5075136D2D1925BC00AD60C0 /* IntelligentsPlugin.swift */; };
50802D612D112F8700694021 /* Intelligents in Frameworks */ = {isa = PBXBuildFile; productRef = 50802D602D112F8700694021 /* Intelligents */; }; 50802D612D112F8700694021 /* Intelligents in Frameworks */ = {isa = PBXBuildFile; productRef = 50802D602D112F8700694021 /* Intelligents */; };
50A285D72D112A5E000D5A6D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 50A285D62D112A5E000D5A6D /* Localizable.xcstrings */; }; 50A285D72D112A5E000D5A6D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 50A285D62D112A5E000D5A6D /* Localizable.xcstrings */; };
50A285D82D112A5E000D5A6D /* InfoPlist.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 50A285D52D112A5E000D5A6D /* InfoPlist.xcstrings */; }; 50A285D82D112A5E000D5A6D /* InfoPlist.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 50A285D52D112A5E000D5A6D /* InfoPlist.xcstrings */; };
@ -31,6 +33,8 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
507513692D1924C600AD60C0 /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
5075136D2D1925BC00AD60C0 /* IntelligentsPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntelligentsPlugin.swift; sourceTree = "<group>"; };
50802D5E2D112F7D00694021 /* Intelligents */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Intelligents; sourceTree = "<group>"; }; 50802D5E2D112F7D00694021 /* Intelligents */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Intelligents; sourceTree = "<group>"; };
50A285D52D112A5E000D5A6D /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; }; 50A285D52D112A5E000D5A6D /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; };
50A285D62D112A5E000D5A6D /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; }; 50A285D62D112A5E000D5A6D /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
@ -126,6 +130,7 @@
9D90BE172CCB9876006677DB /* CookieManager.swift */, 9D90BE172CCB9876006677DB /* CookieManager.swift */,
9D90BE182CCB9876006677DB /* CookiePlugin.swift */, 9D90BE182CCB9876006677DB /* CookiePlugin.swift */,
9D6A85322CCF6DA700DAB35F /* HashcashPlugin.swift */, 9D6A85322CCF6DA700DAB35F /* HashcashPlugin.swift */,
5075136D2D1925BC00AD60C0 /* IntelligentsPlugin.swift */,
); );
path = Cookie; path = Cookie;
sourceTree = "<group>"; sourceTree = "<group>";
@ -143,8 +148,9 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9D90BE1A2CCB9876006677DB /* Plugins */, 9D90BE1A2CCB9876006677DB /* Plugins */,
9D90BE1B2CCB9876006677DB /* AffineViewController.swift */,
9D90BE1C2CCB9876006677DB /* AppDelegate.swift */, 9D90BE1C2CCB9876006677DB /* AppDelegate.swift */,
507513692D1924C600AD60C0 /* RootViewController.swift */,
9D90BE1B2CCB9876006677DB /* AffineViewController.swift */,
9D90BE1D2CCB9876006677DB /* Assets.xcassets */, 9D90BE1D2CCB9876006677DB /* Assets.xcassets */,
9D90BE1E2CCB9876006677DB /* capacitor.config.json */, 9D90BE1E2CCB9876006677DB /* capacitor.config.json */,
9D90BE1F2CCB9876006677DB /* config.xml */, 9D90BE1F2CCB9876006677DB /* config.xml */,
@ -309,6 +315,8 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
5075136E2D1925BC00AD60C0 /* IntelligentsPlugin.swift in Sources */,
5075136A2D1924C600AD60C0 /* RootViewController.swift in Sources */,
C4C97C7C2D030BE000BC2AD1 /* affine_mobile_native.swift in Sources */, C4C97C7C2D030BE000BC2AD1 /* affine_mobile_native.swift in Sources */,
C4C97C7D2D030BE000BC2AD1 /* affine_mobile_nativeFFI.h in Sources */, C4C97C7D2D030BE000BC2AD1 /* affine_mobile_nativeFFI.h in Sources */,
C4C97C7E2D030BE000BC2AD1 /* affine_mobile_nativeFFI.modulemap in Sources */, C4C97C7E2D030BE000BC2AD1 /* affine_mobile_nativeFFI.modulemap in Sources */,

View File

@ -5,7 +5,8 @@ import UIKit
class AFFiNEViewController: CAPBridgeViewController { class AFFiNEViewController: CAPBridgeViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
webView?.allowsBackForwardNavigationGestures = true // disable by default, enable manually when there is a "back" button in page-header
webView?.allowsBackForwardNavigationGestures = false
navigationController?.navigationBar.isHidden = true navigationController?.navigationBar.isHidden = true
extendedLayoutIncludesOpaqueBars = false extendedLayoutIncludesOpaqueBars = false
edgesForExtendedLayout = [] edgesForExtendedLayout = []
@ -18,7 +19,8 @@ class AFFiNEViewController: CAPBridgeViewController {
let plugins: [CAPPlugin] = [ let plugins: [CAPPlugin] = [
CookiePlugin(), CookiePlugin(),
HashcashPlugin(), HashcashPlugin(),
// IntelligentsPlugin(representController: self), NavigationGesturePlugin(),
IntelligentsPlugin(representController: self),
] ]
plugins.forEach { bridge?.registerPluginInstance($0) } plugins.forEach { bridge?.registerPluginInstance($0) }
} }

View File

@ -0,0 +1,36 @@
import Capacitor
import Foundation
@objc(IntelligentsPlugin)
public class IntelligentsPlugin: CAPPlugin, CAPBridgedPlugin {
public let identifier = "IntelligentsPlugin"
public let jsName = "Intelligents"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "presentIntelligentsButton", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "dismissIntelligentsButton", returnType: CAPPluginReturnPromise),
]
public private(set) weak var representController: UIViewController?
init(representController: UIViewController) {
self.representController = representController
super.init()
}
deinit {
representController = nil
}
@objc public func presentIntelligentsButton(_ call: CAPPluginCall) {
DispatchQueue.main.async {
self.representController?.presentIntelligentsButton()
call.resolve()
}
}
@objc public func dismissIntelligentsButton(_ call: CAPPluginCall) {
DispatchQueue.main.async {
self.representController?.dismissIntelligentsButton()
call.resolve()
}
}
}

View File

@ -12,12 +12,16 @@ let package = Package(
], ],
products: [ products: [
.library(name: "Intelligents", targets: ["Intelligents"]), .library(name: "Intelligents", targets: ["Intelligents"]),
], ]
dependencies: [ ,dependencies: [
.package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.4.1"), .package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.4.1"),
.package(url: "https://github.com/Lakr233/SpringInterpolation", from: "1.1.0"),
.package(url: "https://github.com/Lakr233/MSDisplayLink", from: "1.1.0"),
], ],
targets: [ targets: [
.target(name: "Intelligents", dependencies: [ .target(name: "Intelligents", dependencies: [
"SpringInterpolation",
"MSDisplayLink",
.product(name: "MarkdownUI", package: "swift-markdown-ui"), .product(name: "MarkdownUI", package: "swift-markdown-ui"),
]), ]),
] ]

View File

@ -0,0 +1,29 @@
#!/bin/zsh
set -e
set -o pipefail
# packages/frontend/apps/ios/
cd "$(dirname "$0")"
cd ../../../../
if [ ! -d .git ]; then
echo "[-] .git directory not found at project root"
exit 1
fi
echo "[+] setting up the project"
yarn install
BUILD_TYPE=canary PUBLIC_PATH="/" yarn workspace @affine/ios build
yarn workspace @affine/ios cap sync
rustup target add aarch64-apple-ios
rustup target add aarch64-apple-ios-sim
rustup target add aarch64-apple-darwin
echo "[+] setup complete"
yarn workspace @affine/ios cap open ios