使用Xcode在Linux上远程调试Swift

时间:2019-02-15 17:54:45

标签: swift linux xcode bluetooth

我想使用Mac主机上的Xcode远程开发/运行/调试Swift蓝牙程序,并将其安装到带有Debian OS的远程(SBC)华硕Tinkerboard S。

经过大量的搜索和拼凑而成的随机博客,以下部分正在工作:

  • 在Debian上安装了Swift(Swift版本4.2.1(swift-4.2.1-RELEASE))
  • 在Debian中,可以使用Swift进行构建,并可以使用简单的Swift代码通过终端运行。
  • 使用一个在线示例来设置Xcode项目,该项目具有通过Xcode远程构建,rsync(Swish)和通过代码进行远程调试的能力。 https://swiftreviewer.com/2018/12/25/compile-swift-for-raspberry-pi-by-xcode/

当我检查Swift的版本时:

$ swift -v
Swift version 4.2.1 (swift-4.2.1-RELEASE)
Target: armv7-unknown-linux-gnueabihf
/usr/bin/lldb "--repl=-disable-objc-interop -color-diagnostics"
error: failed to stop process at REPL breakpoint

什么不起作用:

  1. 我需要蓝牙支持,因此将以下内容添加到Package.swift中(来自https://github.com/PureSwift:BluetoothLinux,GATT,SwiftFoundation。
  2. 编辑Package.swift之后,我通过调用.xcodeproj来重新生成swift package generate-xcodeproj
  3. 警告显示:警告:PackageDescription API v3 is deprecated and will be removed in the future; used by package(s): SwiftFoundation, CJSONC, CStatfs
  4. 然后,由于重新生成过程清除了远程构建目标,因此将其重新添加。
  5. 尝试构建,但出现以下消息时出错。我检查了x86_64-linux-gnu文件夹及其缺失。我已经安装了我所知道的依赖项...,我认为应该使用armv7-unknown-linux-gnueabihf来代替。
-----------------------------
Configuration:
-----------------------------
Username: linaro
Hostname: tinkerboard.local
Destination: ~/Swish/swift_program
-----------------------------
  Start syncing project to linaro@tinkerboard.local:~/Swish/swift_program
sending incremental file list
./
Package.swift

            993 100%    0.00kB/s    0:00:00  
            993 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=12/16)
  Did sync project to remote machine
⚒  Start building project
bash: /home/linaro/.bash_profile: No such file or directory
warning: PackageDescription API v3 is deprecated and will be removed in the future; used by package(s): SwiftFoundation, CJSONC, CStatfs
Compile Swift Module 'SwiftFoundation' (39 sources)
Compile Swift Module 'Bluetooth' (430 sources)
/home/linaro/Swish/swift_program/.build/checkouts/CStatfs.git--2064549412/module.modulemap:2:12: error: header '/usr/include/x86_64-linux-gnu/sys/vfs.h' not found
    header "/usr/include/x86_64-linux-gnu/sys/vfs.h"
           ^
/home/linaro/Swish/swift_program/.build/checkouts/SwiftFoundation--958978667/Sources/SwiftFoundation/FileDescriptor.swift:13:12: error: could not build C module 'CStatfs'
    import CStatfs
           ^
/home/linaro/Swish/swift_program/.build/checkouts/CStatfs.git--2064549412/module.modulemap:2:12: error: header '/usr/include/x86_64-linux-gnu/sys/vfs.h' not found
    header "/usr/include/x86_64-linux-gnu/sys/vfs.h"
           ^
/home/linaro/Swish/swift_program/.build/checkouts/SwiftFoundation--958978667/Sources/SwiftFoundation/FileDescriptor.swift:13:12: error: could not build C module 'CStatfs'
    import CStatfs
           ^
/home/linaro/Swish/swift_program/.build/checkouts/CStatfs.git--2064549412/module.modulemap:2:12: error: header '/usr/include/x86_64-linux-gnu/sys/vfs.h' not found
    header "/usr/include/x86_64-linux-gnu/sys/vfs.h"
           ^
/home/linaro/Swish/swift_program/.build/checkouts/SwiftFoundation--958978667/Sources/SwiftFoundation/FileDescriptor.swift:13:12: error: could not build C module 'CStatfs'
    import CStatfs
           ^
/home/linaro/Swish/swift_program/.build/checkouts/CStatfs.git--2064549412/module.modulemap:2:12: error: header '/usr/include/x86_64-linux-gnu/sys/vfs.h' not found
    header "/usr/include/x86_64-linux-gnu/sys/vfs.h"
           ^
/home/linaro/Swish/swift_program/.build/checkouts/SwiftFoundation--958978667/Sources/SwiftFoundation/FileDescriptor.swift:13:12: error: could not build C module 'CStatfs'
    import CStatfs
           ^
error: terminated(1): /usr/bin/swift-build-tool -f /home/linaro/Swish/swift_program/.build/debug.yaml main output:

我的Package.swift文件:

// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "swift_program",
    dependencies: [
        .package(url: "https://github.com/PureSwift/BluetoothLinux.git", .branch("master")),
        .package(url: "https://github.com/PureSwift/GATT", .branch("master")),
        .package(url: "https://github.com/PureSwift/SwiftFoundation.git", .branch("master"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "swift_program",
            dependencies: ["BluetoothLinux", "GATT", "SwiftFoundation"])
    ]
)

感谢任何帮助/建议。

0 个答案:

没有答案