尝试编写一个快速的Unity插件来从剪贴板中取出数据,所讨论的功能如下:
extern "C"
{
const char * _importString()
{
UIPasteboard *result = [UIPasteboard generalPasteboard];
NSString * resultString = [result string];
return [resultString UTF8String];
}
}
但是,当我激活该功能时,它会给我以下错误:
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A9 GPU
Initialize engine version: 2017.1.0f3 (472613c02cf7)
2017-08-26 13:46:21.395230+0100 ProductName[8608:2930827] [Common] _BSMachError: port 5e03; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2017-08-26 13:46:21.400889+0100 ProductName[8608:2930827] [Common] _BSMachError: port 5e03; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
UnloadTime: 4.034333 ms
ProductName(8608,0x1b8100b40) malloc: *** error for object 0x1740a6191: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
主要用Unity C编写,所以对iOS插件知之甚少,也不知道从哪里开始,任何帮助都有所帮助。
编辑:
对于那些在家里玩的人来说,这里是相关的Unity片段:
[DllImport("__Internal")]
private static extern string _importString();
//retrieves the clipboard contents from xcode
public string iPhoneImportClipboard()
{
return _importString();
}
答案 0 :(得分:4)
sudo apt-get install gcc
的结果不能被视为malloc指针。
在返回之前,您需要-string
一个缓冲区和malloc
字符串。
strcpy