简体   繁体   English

在远程设备上执行Objective-C代码

[英]Executing objective-c code on remote device

I wonder if I have remote iOS device, with any custom solution I can preload on it (written myself), is there a way to make it execute any custom code, like a block? 我想知道我是否有远程iOS设备以及可以在其上预加载的任何自定义解决方案(自己编写),是否有办法使它执行任何自定义代码(例如块)?

Here is what I mean: 这是我的意思:

// establish connection with remote device
[self connectToDevice:remoteDevice];

// send arbitary block of code and data to execute on remote device

[myDevice executeBlock:^(void)(BOOL result, NSData *data) {

// here I can write any code that uses the data
// I want this code to run on remote machine

}];

// I might get results via network, or any other way, not related

I do not mean run any malicious code, or my program, or something like that. 我并不是说运行任何恶意代码,我的程序或类似的东西。 I mean that I have my program already running and waiting for task to execute. 我的意思是我已经在运行程序并等待任务执行。

The problems I might see - Objective-c is compiled language, so having code sent does not help. 我可能会看到的问题-Objective-c是编译语言,因此发送代码无济于事。 Is it possible to use some scripting language or solution to overcome this? 是否可以使用某些脚本语言或解决方案来克服这一问题?

In a word, no. 一言以蔽之。 Apple's terms of service forbid you from executing code you receive over the network. Apple的服务条款禁止您执行通过网络收到的代码。

Plus, Objective C is compiled and needs to be linked into your project. 另外,Objective C已编译,需要链接到您的项目中。 There is no facility for installing dynamically linked libraries at runtime in iOS. 没有在iOS的运行时安装动态链接库的功能。

You might be able to figure out a way to deliver dynamically linked libraries on a jailbroken device, but that's out of the scope of this board. 您也许能够找到一种在越狱设备上交付动态链接库的方法,但这超出了本板的范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM