dudu MVP:五端语音输入法初始提交
- server:Go 网关(WS 流式识别中继/计费配额/微信登录支付 mock/反馈/埋点),gummy provider 已真实联调 - desktop:Tauri 2(全局快捷键 push-to-talk/浮层/托盘/设置/登录购买/反馈/首启引导) - android:Compose 主 App + IME(键盘内录音直传) - ios:App + 键盘扩展(1A spike 实证键盘内不可录音,走 deep link 听写) - design/design-pipeline:设计系统 + token 导出 iOS/Android 主题 - doc:前后端设计文档(HTML);web:官网宣传页;todo:任务看板 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
// 容器 App:引导启用键盘 + 在 App 内先验证一次正常录音(对照组)
|
||||
import AVFoundation
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SpikeApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup { ContentView() }
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var appMicResult = "未测试"
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text("dudu 键盘录音 spike").font(.title2).bold()
|
||||
Text("""
|
||||
步骤:
|
||||
1. 点下方按钮,先验证 App 内录音(对照组)
|
||||
2. 设置 → 通用 → 键盘 → 添加 DuduKbMicSpike
|
||||
3. 打开"允许完全访问"
|
||||
4. 任意输入框切到该键盘,按"测试键盘内录音"
|
||||
5. 把键盘上显示的结果告诉 Claude
|
||||
""").font(.callout)
|
||||
Button("测试 App 内录音(对照组)") {
|
||||
testAppMic { appMicResult = $0 }
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
Text("App 内结果:\(appMicResult)").font(.callout).monospaced()
|
||||
Spacer()
|
||||
}
|
||||
.padding(24)
|
||||
}
|
||||
}
|
||||
|
||||
func testAppMic(done: @escaping (String) -> Void) {
|
||||
AVAudioApplication.requestRecordPermission { granted in
|
||||
DispatchQueue.main.async {
|
||||
guard granted else { return done("麦克风权限被拒") }
|
||||
do {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try session.setCategory(.record, mode: .measurement)
|
||||
try session.setActive(true)
|
||||
let engine = AVAudioEngine()
|
||||
var frames: UInt32 = 0
|
||||
engine.inputNode.installTap(onBus: 0, bufferSize: 1024, format: nil) { buf, _ in
|
||||
frames += buf.frameLength
|
||||
}
|
||||
try engine.start()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
engine.stop()
|
||||
done(frames > 0 ? "✅ 收到 \(frames) 帧" : "❌ 无音频回调")
|
||||
}
|
||||
} catch {
|
||||
done("❌ \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 77;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
5EFA4CA44808FF863ED92634 /* KeyboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1FE0B102D57EB278A4082A2 /* KeyboardViewController.swift */; };
|
||||
C1FF8BD1BC8F768241336592 /* KeyboardExt.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = EAA33751C91327A7AE634E51 /* KeyboardExt.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
CD60E8C0617C91B4DF3702B5 /* SpikeApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C8C18A4141166114A8C057 /* SpikeApp.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
321CB212E7664C13F19344EF /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A69F0DD8B57227DFFA74D6DC /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = CA51BBE9CE0929E95F148070;
|
||||
remoteInfo = KeyboardExt;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
C5A47F06868FFA1224F15FC1 /* Embed Foundation Extensions */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 13;
|
||||
files = (
|
||||
C1FF8BD1BC8F768241336592 /* KeyboardExt.appex in Embed Foundation Extensions */,
|
||||
);
|
||||
name = "Embed Foundation Extensions";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
642D04C053A4F9B82CA9200F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
96C8C18A4141166114A8C057 /* SpikeApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpikeApp.swift; sourceTree = "<group>"; };
|
||||
B5EE542ABFB96B6F5823F4CB /* App.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C1FE0B102D57EB278A4082A2 /* KeyboardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardViewController.swift; sourceTree = "<group>"; };
|
||||
EAA33751C91327A7AE634E51 /* KeyboardExt.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = KeyboardExt.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
2D5607189AC0BE713CD39446 /* KeyboardExt */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
642D04C053A4F9B82CA9200F /* Info.plist */,
|
||||
C1FE0B102D57EB278A4082A2 /* KeyboardViewController.swift */,
|
||||
);
|
||||
path = KeyboardExt;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7659DF33F4F19FD06928CDC4 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ED9770B6B6CC37623925B3C8 /* App */,
|
||||
2D5607189AC0BE713CD39446 /* KeyboardExt */,
|
||||
9372AAC1311344DC3AEED011 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9372AAC1311344DC3AEED011 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B5EE542ABFB96B6F5823F4CB /* App.app */,
|
||||
EAA33751C91327A7AE634E51 /* KeyboardExt.appex */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
ED9770B6B6CC37623925B3C8 /* App */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
96C8C18A4141166114A8C057 /* SpikeApp.swift */,
|
||||
);
|
||||
path = App;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
2007A063D8B0067C3D704326 /* App */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 54BD9396E49168A7EE5A2CFD /* Build configuration list for PBXNativeTarget "App" */;
|
||||
buildPhases = (
|
||||
317D8937589C426FA9A4BBBB /* Sources */,
|
||||
C5A47F06868FFA1224F15FC1 /* Embed Foundation Extensions */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
2C59DBCCD8144857610DE5DF /* PBXTargetDependency */,
|
||||
);
|
||||
name = App;
|
||||
packageProductDependencies = (
|
||||
);
|
||||
productName = App;
|
||||
productReference = B5EE542ABFB96B6F5823F4CB /* App.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
CA51BBE9CE0929E95F148070 /* KeyboardExt */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 7BB4AA808EBA7CDD8D3C50A3 /* Build configuration list for PBXNativeTarget "KeyboardExt" */;
|
||||
buildPhases = (
|
||||
FCE6E8B6326FC9D614E0A5C3 /* Sources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = KeyboardExt;
|
||||
packageProductDependencies = (
|
||||
);
|
||||
productName = KeyboardExt;
|
||||
productReference = EAA33751C91327A7AE634E51 /* KeyboardExt.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
A69F0DD8B57227DFFA74D6DC /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 1430;
|
||||
TargetAttributes = {
|
||||
2007A063D8B0067C3D704326 = {
|
||||
DevelopmentTeam = FVVBJ8M8PU;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
CA51BBE9CE0929E95F148070 = {
|
||||
DevelopmentTeam = FVVBJ8M8PU;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = A2BF69604C5A7B464A13E0B6 /* Build configuration list for PBXProject "DuduKbMicSpike" */;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
Base,
|
||||
en,
|
||||
);
|
||||
mainGroup = 7659DF33F4F19FD06928CDC4;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
preferredProjectObjectVersion = 77;
|
||||
productRefGroup = 9372AAC1311344DC3AEED011 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
2007A063D8B0067C3D704326 /* App */,
|
||||
CA51BBE9CE0929E95F148070 /* KeyboardExt */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
317D8937589C426FA9A4BBBB /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CD60E8C0617C91B4DF3702B5 /* SpikeApp.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
FCE6E8B6326FC9D614E0A5C3 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5EFA4CA44808FF863ED92634 /* KeyboardViewController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
2C59DBCCD8144857610DE5DF /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = CA51BBE9CE0929E95F148070 /* KeyboardExt */;
|
||||
targetProxy = 321CB212E7664C13F19344EF /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
3297BB96EEF3CF6EE8636BD9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = FVVBJ8M8PU;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
4933ECD448368C64D0BA0A6D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = KeyboardExt/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.dudu.spike.kbmic.keyboard;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
9F6E47030745AAF0E7207719 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = FVVBJ8M8PU;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
"DEBUG=1",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CC89E47264E48BED9C8E0883 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = KeyboardExt/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.dudu.spike.kbmic.keyboard;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE1BA7F6ECF54A020BB82507 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSMicrophoneUsageDescription = "spike:验证键盘扩展录音可行性";
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.dudu.spike.kbmic;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
E298F9BBB39D8C531417AAD9 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSMicrophoneUsageDescription = "spike:验证键盘扩展录音可行性";
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.dudu.spike.kbmic;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
54BD9396E49168A7EE5A2CFD /* Build configuration list for PBXNativeTarget "App" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
E298F9BBB39D8C531417AAD9 /* Debug */,
|
||||
CE1BA7F6ECF54A020BB82507 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Debug;
|
||||
};
|
||||
7BB4AA808EBA7CDD8D3C50A3 /* Build configuration list for PBXNativeTarget "KeyboardExt" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CC89E47264E48BED9C8E0883 /* Debug */,
|
||||
4933ECD448368C64D0BA0A6D /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Debug;
|
||||
};
|
||||
A2BF69604C5A7B464A13E0B6 /* Build configuration list for PBXProject "DuduKbMicSpike" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
9F6E47030745AAF0E7207719 /* Debug */,
|
||||
3297BB96EEF3CF6EE8636BD9 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Debug;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = A69F0DD8B57227DFFA74D6DC /* Project object */;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>DuduKbMicSpike</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>IsASCIICapable</key>
|
||||
<false/>
|
||||
<key>PrefersRightToLeft</key>
|
||||
<false/>
|
||||
<key>PrimaryLanguage</key>
|
||||
<string>zh-Hans</string>
|
||||
<key>RequestsOpenAccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.keyboard-service</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).KeyboardViewController</string>
|
||||
</dict>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>spike:验证键盘扩展录音可行性</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,77 @@
|
||||
// 1A spike 核心:键盘扩展内尝试 AVAudioEngine 录音,结果直接显示在键盘上。
|
||||
// 判定标准:
|
||||
// ✅ engine.start() 成功且 1 秒内收到音频帧 → 键盘内录音可行(主路径成立)
|
||||
// ❌ setActive/start 抛错或 0 帧 → 不可行,走 deep link 降级方案(14D)
|
||||
import AVFoundation
|
||||
import UIKit
|
||||
|
||||
class KeyboardViewController: UIInputViewController {
|
||||
private let resultLabel = UILabel()
|
||||
private let engine = AVAudioEngine()
|
||||
private var frames: UInt32 = 0
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = .systemGray5
|
||||
|
||||
let stack = UIStackView()
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 10
|
||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stack)
|
||||
NSLayoutConstraint.activate([
|
||||
stack.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
stack.topAnchor.constraint(equalTo: view.topAnchor, constant: 16),
|
||||
stack.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -32),
|
||||
view.heightAnchor.constraint(greaterThanOrEqualToConstant: 220),
|
||||
])
|
||||
|
||||
let info = UILabel()
|
||||
info.text = "完全访问:\(hasFullAccess ? "已开启" : "未开启(请先开启)")"
|
||||
info.font = .systemFont(ofSize: 14)
|
||||
stack.addArrangedSubview(info)
|
||||
|
||||
let btn = UIButton(type: .system)
|
||||
btn.setTitle("测试键盘内录音(1 秒)", for: .normal)
|
||||
btn.titleLabel?.font = .boldSystemFont(ofSize: 17)
|
||||
btn.addTarget(self, action: #selector(testMic), for: .touchUpInside)
|
||||
stack.addArrangedSubview(btn)
|
||||
|
||||
resultLabel.text = "结果:未测试"
|
||||
resultLabel.font = .monospacedSystemFont(ofSize: 14, weight: .regular)
|
||||
resultLabel.numberOfLines = 0
|
||||
stack.addArrangedSubview(resultLabel)
|
||||
|
||||
let next = UIButton(type: .system)
|
||||
next.setTitle("🌐 切回系统键盘", for: .normal)
|
||||
next.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
|
||||
stack.addArrangedSubview(next)
|
||||
}
|
||||
|
||||
@objc private func testMic() {
|
||||
frames = 0
|
||||
resultLabel.text = "结果:测试中…"
|
||||
// 键盘扩展无法弹权限框;权限继承容器 App / 系统设置中的麦克风授权
|
||||
do {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try session.setCategory(.playAndRecord, mode: .measurement, options: [.mixWithOthers])
|
||||
try session.setActive(true)
|
||||
engine.inputNode.removeTap(onBus: 0)
|
||||
engine.inputNode.installTap(onBus: 0, bufferSize: 1024, format: nil) { [weak self] buf, _ in
|
||||
self?.frames += buf.frameLength
|
||||
}
|
||||
try engine.start()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
|
||||
guard let self else { return }
|
||||
self.engine.stop()
|
||||
self.engine.inputNode.removeTap(onBus: 0)
|
||||
let permission = AVAudioApplication.shared.recordPermission
|
||||
self.resultLabel.text = self.frames > 0
|
||||
? "结果:✅ 收到 \(self.frames) 帧 — 键盘内录音可行"
|
||||
: "结果:❌ 0 帧(权限态:\(permission.rawValue))— 需走降级方案"
|
||||
}
|
||||
} catch {
|
||||
resultLabel.text = "结果:❌ \(error.localizedDescription) — 需走降级方案"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
# 1A spike:验证 iOS 键盘扩展内能否录音(完全访问开启时 AVAudioEngine 是否收到音频回调)
|
||||
# 生成工程:xcodegen generate;真机运行需在 Xcode 中选择你的开发者团队签名。
|
||||
name: DuduKbMicSpike
|
||||
options:
|
||||
bundleIdPrefix: app.dudu.spike
|
||||
deploymentTarget:
|
||||
iOS: "17.0"
|
||||
settings:
|
||||
base:
|
||||
# 生成式 Info.plist 的 CFBundleVersion/ShortVersion 来源;缺失会导致真机安装报 MissingBundleVersion
|
||||
CURRENT_PROJECT_VERSION: 1
|
||||
MARKETING_VERSION: "1.0"
|
||||
CODE_SIGN_STYLE: Automatic
|
||||
DEVELOPMENT_TEAM: FVVBJ8M8PU
|
||||
targets:
|
||||
App:
|
||||
type: application
|
||||
platform: iOS
|
||||
sources: [App]
|
||||
settings:
|
||||
base:
|
||||
PRODUCT_BUNDLE_IDENTIFIER: app.dudu.spike.kbmic
|
||||
INFOPLIST_KEY_NSMicrophoneUsageDescription: "spike:验证键盘扩展录音可行性"
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation: true
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation: true
|
||||
GENERATE_INFOPLIST_FILE: true
|
||||
dependencies:
|
||||
- target: KeyboardExt
|
||||
embed: true
|
||||
KeyboardExt:
|
||||
type: app-extension
|
||||
platform: iOS
|
||||
sources: [KeyboardExt]
|
||||
settings:
|
||||
base:
|
||||
PRODUCT_BUNDLE_IDENTIFIER: app.dudu.spike.kbmic.keyboard
|
||||
GENERATE_INFOPLIST_FILE: true
|
||||
INFOPLIST_FILE: KeyboardExt/Info.plist
|
||||
Reference in New Issue
Block a user