質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,107 @@
|
|
19
19
|
一通り設定を変更したものを実行したところ以下のエラーに直面しました。
|
20
20
|
|
21
21
|
clang: error: linker command failed with exit code 1 (use -vto see invocation)
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
--追記--
|
28
|
+
|
29
|
+
[Cruby cocopods](https://github.com/xord/cruby)
|
30
|
+
|
31
|
+
上記のgitからcocoadodsでCRubyを導入したのですがエラーで実行できず。
|
32
|
+
|
33
|
+
またcocoadodsで作成したlibCRuby_ios.aというios端末用のlibrubyをbuild Phases/Link binary with Librarysから追加したところbuildは成功。
|
34
|
+
|
35
|
+
しかし実行すると Thread 1: EXC_BAD_ACCESS (code=1, address=0xe0) で止まります。
|
36
|
+
|
37
|
+
以下に現在のコードを添付します。
|
38
|
+
|
39
|
+
```C
|
40
|
+
|
41
|
+
#include <stdio.h>
|
42
|
+
|
43
|
+
#include "ruby.h"
|
44
|
+
|
45
|
+
#include "ruby/encoding.h"
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
VALUE $kernel;
|
50
|
+
|
51
|
+
void init()
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
// Ruby初期化のおまじない
|
56
|
+
|
57
|
+
ruby_init();
|
58
|
+
|
59
|
+
ruby_init_loadpath();
|
60
|
+
|
61
|
+
rb_enc_find_index("encdb"); // encodingライブラリの初期化
|
62
|
+
|
63
|
+
int error;
|
64
|
+
|
65
|
+
rb_protect( RUBY_METHOD_FUNC(rb_require), (VALUE) "rubygems", &error);
|
66
|
+
|
67
|
+
rb_protect( RUBY_METHOD_FUNC(rb_require), (VALUE) "./calee", &error);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
void run()
|
74
|
+
|
75
|
+
{
|
76
|
+
|
77
|
+
VALUE module = rb_const_get(rb_cObject, rb_intern("Test"));//ここでエラー EXC_BAD_ACCESS
|
78
|
+
|
79
|
+
VALUE klass = rb_const_get(module, rb_intern("Callee"));
|
80
|
+
|
81
|
+
VALUE obj = rb_class_new_instance(0, NULL, klass); // Test::Callee.new
|
82
|
+
|
83
|
+
VALUE str = rb_str_new2("こんにちは");
|
84
|
+
|
85
|
+
rb_funcall(obj, rb_intern("foo"), 1, str); // obj.foo(str)
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
void main()
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
init();
|
96
|
+
|
97
|
+
run();
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
```Swift
|
104
|
+
|
105
|
+
import UIKit
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
class ViewController: UIViewController {
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
override func viewDidLoad() {
|
114
|
+
|
115
|
+
super.viewDidLoad()
|
116
|
+
|
117
|
+
// Do any additional setup after loading the view, typically from a nib.
|
118
|
+
|
119
|
+
main()
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
```
|