【发布时间】:2018-12-18 21:30:46
【问题描述】:
目前我已经尝试过使用 NativeScript 和 Typescript 进行开发,但现在我遇到了一个困扰我很多的问题。
我正在借助“nativescript-plugin-seed”开发一个插件,该插件使用 pod (AudioKit) 进行音频转换。我的问题是我应该如何将“AudioKit”模块导入插件以利用其功能,然后在应用程序中使用它们
我在 Swift 中包含了我在 Xcode 项目中测试的音频转换代码,以验证其正确操作以及我认为应该导入模块以生成将与我的应用程序通信的方法的模板。
Swift 代码
import UIKit
import AudioKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let fileManager = FileManager.default
do {
let origin = Bundle.main.url(forResource: "IOS", withExtension: "mp4")
let documentDirectory = try fileManager.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil, create:false)
let destination = documentDirectory.appendingPathComponent("test.wav")
var options = AKConverter.Options();
options.format = "wav";
options.sampleRate = 48000;
options.bitDepth = 16;
let converter = AKConverter(inputURL: origin!, outputURL: destination, options: options)
converter.start(completionHandler: { error in
if(error != nil){
print("ERROR")
}else{
print("CORRECT")
}
})
}
catch {
print(error)
}
}
}
插件代码 (my-plugin.ios.ts)
import { Common } from './audio-converter.common';
//I suppose the module should be declared here
export class AudioConverter extends Common {
// and used here
}
**已编辑
我已经使用了命令HERE,但从未创建过输入文件。以同样的方式阅读如果 pod 是用 Swift 编写的,我必须配置 pod 文件和 build.xcconfig,但无论如何它都不起作用。我将评论我正在执行的步骤,以验证我没有做错什么。
- 使用 git clone 创建插件 https://github.com/NativeScript/nativescript-plugin-seed 并配置插件名称.....
-
添加 podfile
pod 'AudioKit', '~> 4.0' post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_SWIFT3_OBJC_INFERENCE'] = 'On' config.build_settings['SWIFT_VERSION'] = '4.0' end end end 在 build.xcconfig 中添加标志
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES-
执行这些命令在 /src 中创建输入文件(-EDITED 要创建输入文件,这些命令必须在 /demo 中使用)
TNS_DEBUG_METADATA_PATH="$(pwd)/metadata" tns build ios [--for-device] [--release] TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios [--for-device] [--release] 在这一点上,我假设我必须在打字地毯中获取文件,但我没有得到它们
【问题讨论】:
标签: javascript ios swift typescript nativescript