You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift实现Vmess协议Xray服务器Packet Tunnel技术求助

Swift实现Vmess协议Xray服务器Packet Tunnel遇到的问题

我有一台采用Vmess协议的Xray服务器,想要在Swift中实现Packet Tunnel,但找不到相关资源或教程。如果有相关实现思路、资源或者能提供技术帮助,我愿意付费,非常感谢。

我尝试用Go的v2ray-core包制作xcframework,但生成的框架里部分方法缺失。以下是Swift中能调用的CoreInstance类函数:

open class CoreInstance : NSObject, goSeqRefInterface, CoreServerProtocol {
    open var _ref: Any { get }

    public init(ref: Any)
    public init()

    // skipped method Instance.AddFeature with unsupported parameter or return types
    /**
     * Close shutdown the V2Ray instance.
     */
    open func close() throws

    // skipped method Instance.GetFeature with unsupported parameter or return types
    // skipped method Instance.RequireFeatures with unsupported parameter or return types
    /**
     * Start starts the V2Ray instance, including all registered features. When Start returns error, the state of the instance is unknown.
    A V2Ray instance can be started only once. Upon closing, the instance is not guaranteed to start again.

    v2ray:api:stable
     */
    open func start() throws
}

运行应用时控制台抛出以下错误:

-[Swift.__SharedStringStorage incNum]: unrecognized selector sent to instance 0x2813baa60
This is the core instance: <CoreServer: 0x280d92c10>
2024-10-25 17:17:37.515121+0500 V2Ray VPN[9474:580376] -[Swift.__SharedStringStorage incNum]: unrecognized selector sent to instance 0x2801e8b40
2024-10-25 17:17:37.516905+0500 V2Ray VPN[9474:580376] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift.__SharedStringStorage incNum]: unrecognized selector sent to instance 0x2801e8b40'
*** First throw call stack:
(0x18179fc60 0x198fcfee4 0x1818706e8 0x18173954c 0x18173875c 0x10139e114 0x10139c3f8 0x100f805b4 0x100f7fc28 0x194faa3e8 0x1dbfd6b88 0x102044700 0x102045fc8 0x1020548ac 0x1020544fc 0x18175b014 0x1817184f8 0x18172b174 0x1a226e988 0x183f2da88 0x183cc6f78 0x100f82e9c 0x101e684d0)
libc++abi: terminating with uncaught exception of type NSException

我推测这个错误是因为xcframework中缺失必要方法导致的。

内容的提问来源于stack exchange,提问作者Zeeshan Waheed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 23:30:13