This commit is contained in:
denggaofeng 2026-01-26 14:13:15 +08:00
parent 4db0e14c02
commit b10b9110aa
12 changed files with 90 additions and 85 deletions

View File

@ -14,7 +14,7 @@ public partial class MainPage : ContentPage
#if IOS
private void SetNFCCallbacks()
{
NFCManager.SetLoopCbWithCb(new LoopCallback(this));
NFCManager.SetLoopCbWithCb();
NFCManager.SetFinishedCbWithCb(() =>
{
System.Diagnostics.Debug.WriteLine("finished");
@ -38,27 +38,6 @@ public partial class MainPage : ContentPage
_mainMainViewModel.UpdateMessage($"控制中({progress}%)");
});
}
private class LoopCallback : Foundation.NSObject
{
private readonly MainPage mainPage;
public LoopCallback(MainPage page)
{
this.mainPage = page;
}
[Export("callAsFunctionWithId:isNew:rssi:")]
public bool CallAsFunction(IntPtr id, bool isNew, int rssi)
{
string deviceId = NSString.FromHandle(id);
mainPage._mainMainViewModel.DeviceId = deviceId;
mainPage._mainMainViewModel.DeviceRssi = rssi.ToString();
return true; // 继续循环
}
}
#endif
public MainPage(MainViewModel mainViewModel)

View File

@ -26,7 +26,7 @@ namespace NfcLock.Ios.Binding
// +(void)setLoopCbWithCb:(id)cb;
[Static]
[Export ("setLoopCbWithCb:")]
void SetLoopCbWithCb (NSObject cb);
void SetLoopCbWithCb (Func<NSString, bool, nint, bool> callback);
// +(void)setFinishedCbWithCb:(void (^ _Nonnull)(void))cb;
[Static]

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target arm64-apple-ios16.6 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target arm64-apple-ios16.6 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target arm64-apple-ios16.6-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target arm64-apple-ios16.6-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target x86_64-apple-ios16.6-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -1,7 +1,7 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.2.3 effective-5.10 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
// swift-module-flags: -target x86_64-apple-ios16.6-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-upcoming-feature DisableOutwardActorInference -enable-upcoming-feature InferSendableFromCaptures -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature MemberImportVisibility -enable-upcoming-feature InferIsolatedConformances -enable-upcoming-feature NonisolatedNonsendingByDefault -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name NfcLockFramework
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2.3
import CoreNFC
import NFCSDK
import Swift

View File

@ -4,6 +4,10 @@
<dict>
<key>files</key>
<dict>
<key>Headers/NfcLockFramework-Swift.h</key>
<data>
YEquuy4noJ8B7eMgaLE+YDh0fgM=
</data>
<key>Info.plist</key>
<data>
GpDEJ+rATPOCmP3HUpE7ZB1LJzg=
@ -14,7 +18,7 @@
</data>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
<data>
AvzsO/AVfO+ywZPE6yD9W7vfuo0=
2Dap9sXkg+TyM2W04UdOnZnmPqc=
</data>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
<data>
@ -22,11 +26,11 @@
</data>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
<data>
AvzsO/AVfO+ywZPE6yD9W7vfuo0=
2Dap9sXkg+TyM2W04UdOnZnmPqc=
</data>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
<data>
7ZUSCPKox6eMxhpnn4hrjbL6BxA=
l8O6zkrcOaGEuqWHNGBMJ5Su3cw=
</data>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
<data>
@ -34,7 +38,7 @@
</data>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
<data>
ZnK7qlDDFzUdvbvDxYNV3zJfJNs=
8oe3Jnkvx2Rh9M9uWCCu7FvLOvk=
</data>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
<data>
@ -42,15 +46,26 @@
</data>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
<data>
ZnK7qlDDFzUdvbvDxYNV3zJfJNs=
8oe3Jnkvx2Rh9M9uWCCu7FvLOvk=
</data>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
<data>
xgwvAMrwCj7TS3fvZmO+XTxikJI=
TYIw+cr1EMn5gNkjNNLhxYTm0bU=
</data>
<key>Modules/module.modulemap</key>
<data>
0aItPXpeIP7d1JVyWzIWeQbdMew=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/NfcLockFramework-Swift.h</key>
<dict>
<key>hash2</key>
<data>
Zu+uQldm/Vo1qMe0LNWnnbgXpAW9hCKvQZnlfKYz0Zk=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
<dict>
<key>hash2</key>
@ -62,7 +77,7 @@
<dict>
<key>hash2</key>
<data>
wuf+eH3BsUKo9NTwH7Um4g2Eeg4IC2hJqGCKDCc6lLI=
b6YLeZp9MwfAQhhyWJxQLrMa1doJqbXhxTWjhh+e2Pw=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
@ -76,14 +91,14 @@
<dict>
<key>hash2</key>
<data>
wuf+eH3BsUKo9NTwH7Um4g2Eeg4IC2hJqGCKDCc6lLI=
b6YLeZp9MwfAQhhyWJxQLrMa1doJqbXhxTWjhh+e2Pw=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
<dict>
<key>hash2</key>
<data>
GeWMkaizI6HvrqlHDDnyAntNRSFdAEKwXj4V3wwoUf4=
i3r4WpOvDeIbKEnjJvkPTABfhvc4vda1Sh4EDiYL+wA=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
@ -97,7 +112,7 @@
<dict>
<key>hash2</key>
<data>
qurGBKdP1/SpkBpV1Yl/SOxoj9Jt+9vW9PUvFthKl6s=
j2EM8BNhC4jEvjsXRctMbsumNgX4O/TXoQItNav3wE4=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
@ -111,14 +126,21 @@
<dict>
<key>hash2</key>
<data>
qurGBKdP1/SpkBpV1Yl/SOxoj9Jt+9vW9PUvFthKl6s=
j2EM8BNhC4jEvjsXRctMbsumNgX4O/TXoQItNav3wE4=
</data>
</dict>
<key>Modules/NfcLockFramework.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
<dict>
<key>hash2</key>
<data>
V70YxRBHqcbUYJV956PCLEmTLVXfvzZ5eDuk2uBxhgQ=
aaGoZ9a/i2KY4Q5ViIEYfHYbCf7e4oLD7gdSnTOoaXY=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash2</key>
<data>
56klHhajfaGpdlfxFjnPH7Kq6HS4am/aUjuo2XJ3TSU=
</data>
</dict>
</dict>

View File

@ -264,9 +264,11 @@
185AC0612F22284600E22FA2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
@ -290,7 +292,7 @@
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INSTALL_MODULE = YES;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
@ -300,9 +302,11 @@
185AC0622F22284600E22FA2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
@ -326,7 +330,7 @@
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INSTALL_MODULE = YES;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";