RelayClient 0.0.1-alpha1

RelayClient 0.0.1-alpha1

Igor Lira 维护。



RelayClient 0.0.1-alpha1

Relay

Relay是一种工具,通过USB隧道将iOS套接字隧道到您的本地计算机。

⚠️这是一个实验性项目,可能会导致您的应用崩溃。请勿在生产构建中使用。

💕欢迎并感谢您的贡献。

工作原理

客户端(iOS)

Relay将创建一个或多个监听任意、用户指定的端口的套接字。所有该端口的通信将通过USB连接转发到和从您的计算机。

服务端(macOS)

当您的计算机上运行时,Relay将监听USB上的连接,并将客户端的流量路由到请求的端口本地的localhost。

安装

客户端(iOS)

如果您想手动安装,请查看ExampleRelayClient示例。

继电器可在CocoaPods上使用。在你的Podfile中添加以下行

pod 'RelayClient'

运行 pod install 命令后,向AppDelegate.m文件中添加以下行

+#import <RelayClient/RelayConnectionManager.h>

 @interface AppDelegate ()

+@property (nonatomic, strong) RelayConnectionManager* relayManager;

 @end
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+    self.relayManager = [[RelayConnectionManager alloc] init];

+    // Use hangIfNotConnected to prevent incoming connections from being refused if we're not connected over USB
+    self.relayManager.hangIfNotConnected = YES;

+    // Will relay iOS(localhost:80) to macOS(localhost:8081)
+    [self.relayManager addLocalPort:@(80) relayPort:@(8081)];

+    [self.relayManager start];
 }

 - (void)applicationDidEnterBackground:(UIApplication *)application {
+    [self.relayManager stop];
 }


 - (void)applicationWillEnterForeground:(UIApplication *)application {
+    [self.relayManager start];
 }

完成!

服务器端(macOS)

您可以直接从源代码构建target RelayServer,或从此处下载已编译版本这里

Relay会在菜单栏中添加一个图标,指示是否连接到设备

Relay menu

贡献

所有贡献都受到欢迎和赞赏。谢谢!