Here is some info that may help.  There have been prior posts about this on this forum as well.  It is not trivial but it is also not hard.  Once all of this is done your C# classes will be available to the xcode world. <div>
<br></div><div>Best of luck.</div><div>Duane<br><div><br></div><div>Here is my init mono code and the main.m (below).  This is invoked when the xcode application starts, see main.m.  This code fully embeds the mono runtime assuming Mono 2.6.  There is code here that attempts to setup the soft debugger as well (not completely working).  In prior mono releases I ran into issues using a DLL so I use an EXE.  Note my setup is initmono.m and host.c are compiled into a dynamic library.  That library is then linked into the main xcode application.</div>
<div><br></div><div>This code uses mobjc but I&#39;ve used monobjc before.  The code around mymonoconfig is required so the dylib can be referenced.</div><div><br></div><div>Here is a prebuild command that is required to generate a host.c that is compiled into your xcode application.  The resulting library is linked into your application.</div>
<div><br></div><div># shell script goes here</div><div>if [ $ACTION = &quot;build&quot; ]; then</div><div>export AS=&quot;as -arch i386&quot;</div><div>export DYLD_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/</div>
<div>mkbundle -o $SRCROOT/host.c --nomain -c -oo $SRCROOT/Mono/libhost.a $SRCROOT/Mono/MyMessage.dll $SRCROOT/Mono/MacMonoClient.exe $SRCROOT/Mono/mobjc.dll $SRCROOT/Mono/mcocoa.dll System.dll System.Core.dll System.Xml.Linq.dll System.Xml.dll System.Drawing.dll mscorlib.dll System.Configuration.dll Mono.Security.dll System.Security.dll --machine-config /Library/Frameworks/Mono.framework/Versions/Current/etc/mono/2.0/machine.config</div>
<div>fi </div><div><br></div><div>I do NOT reference the mono.framework in my xcode project.  Instead I modified the project settings:</div><div><div>LD_DYLIB_INSTALL_NAME = @loader_path/../Libraries/InitMono.dylib</div></div>
<div><div>OTHER_LDFLAGS = -pthread -L/Library/Frameworks/Mono.framework/Versions/Current/lib -lmono -lpthread -lm -lgthread-2.0 -lglib-2.0 -lintl -rpath@loader_path/../Libraries</div></div><div><div>LIBRARY_SEARCH_PATHS = Mono</div>
</div><div><div>OTHER_CFLAGS = -D_XOPEN_SOURCE -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP -DGC_MACOSX_THREADS -DGetCurrentProcess=MonoGetCurrentProcess -DCreateEvent=MonoCreateEvent -DGetCurrentThread=MonoGetCurrentThread -I/Library/Frameworks/Mono.framework/Versions/Current/lib/glib-2.0/include -I/Library/Frameworks/Mono.framework/Versions/Current/include/glib-2.0 -D_THREAD_SAFE -D_REENTRANT -I/Library/Frameworks/Mono.framework/Headers/mono-1.0</div>
</div><div><br></div><div>In my application bundle:</div><div>../My.app/Contents/Libraries</div><div>I have this structure:</div><div><div>InitMono.dylib<span class="Apple-tab-span" style="white-space:pre">                        </span>System.dll</div>
<div>System.Xml.dll<span class="Apple-tab-span" style="white-space:pre">        </span>                a.dylib</div><div>MacMonoClient.exe<span class="Apple-tab-span" style="white-space:pre">                </span>lib/</div><div>MacMonoClient.exe.mdb<span class="Apple-tab-span" style="white-space:pre">                </span>libglib-2.0.0.dylib</div>
<div>Mono.Security.dll<span class="Apple-tab-span" style="white-space:pre">                </span>libgthread-2.0.0.dylib</div><div>MyMessage.dll<span class="Apple-tab-span" style="white-space:pre">                        </span>libintl.8.0.2.dylib</div><div>
System.Configuration.dll<span class="Apple-tab-span" style="white-space:pre">        </span>libmono.0.dylib</div><div>System.Core.dll<span class="Apple-tab-span" style="white-space:pre">                        </span>mcocoa.dll</div><div>System.Drawing.dll<span class="Apple-tab-span" style="white-space:pre">                </span>mobjc.dll</div>
<div>System.Drawing.dll.config<span class="Apple-tab-span" style="white-space:pre">        </span>mymonoconfig2</div><div>System.Xml.Linq.dll<span class="Apple-tab-span" style="white-space:pre">                </span></div><div><br></div></div>
<div>Then under lib I have:</div><div>mono/2.0/mscorlib.dll</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">I then run these libraries (below) through <span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span>.  You only have to do these next 2 steps once.  The library names may have changed... I copied the text below from my post on this forum on 10/1/2008.<br>
<span style="font-family: &#39;courier new&#39;, monospace; ">libglib-2.0.0.1400.1.dylib    libgthread-2.0.0.1400.1.dylib    libmono.0.0.0.dylib</span><br style="font-family: &#39;courier new&#39;, monospace; "><span style="font-family: &#39;courier new&#39;, monospace; ">libgmodule-2.0.0.1400.1.dylib    libintl.8.0.1.dylib</span>        <br>
<br>Two things have to be performed on these libraries.  First the id of the file has to be changed from the /Library/Frameworks/Mono.framework reference to @loader_path/../Libraries/&lt;name&gt;.  Run otool -L &lt;the dylib file&gt;.<br>
<span style="font-family: &#39;courier new&#39;, monospace; "><span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span> -id @loader_path/../Libraries/libintl.8.0.1.dylib libintl.8.0.1.dylib</span><br>
<br>The second operation is to change the references to other dynamic libraries you are embedding.<br><span style="font-family: &#39;courier new&#39;, monospace; "><span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span> -change /Library/Frameworks/Mono.framework/Versions/1.9.1/lib/libintl.8.0.1.dylib @loader_path/../Libraries/libintl.8.0.1.dylib libglib-2.0.0.1400.1.dylib</span><br>
<br>Basically what you are doing is telling the runtime app where to find these dynmaic libraries.  Rather than in the Frameworks directory look relative to the application.  Place these modified libraires in &lt;yourapp&gt;.app/Contents/Libraries.<br>
<br>Compile the xcode application normally.  Then run <span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span> on it as well, &lt;yourapp&gt;.app/Contents/MacOS/&lt;yourapp&gt;<br>
<span style="font-family: &#39;courier new&#39;, monospace; "><span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span> -change /Library/Frameworks/Mono.framework/Versions/1.9.1/lib/libgthread-2.0.0.1400.1.dylib @loader_path/../Libraries/libgthread-2.0.0.1400.1.dylib &lt;yourapp&gt; </span><br style="font-family: &#39;courier new&#39;, monospace; ">
<br>Now remember you have to run this <span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 242, 230); background-position: initial initial; background-repeat: initial initial; ">install_name_tool</span> many times.  Once for each library referenced by your application.  And once for each reference in the dynamic libraries to another dynamic library that you are trying to embed.  Use otool -L &lt;file&gt; to find the references you need to modify.</span></div>
<div><br></div><div>##### initmono.m</div><div><br></div><div><div>#import &lt;Cocoa/Cocoa.h&gt;</div><div>#include &lt;mono/jit/jit.h&gt;</div><div>#include &lt;mono/metadata/assembly.h&gt;</div><div>#include &lt;mono/metadata/mono-config.h&gt;</div>
<div>#include &lt;mono/metadata/mono-debug.h&gt;</div><div>#include &lt;mono/utils/mono-logger.h&gt;</div><div><br></div><div>extern void mono_mkbundle_init();</div><div><br></div><div>void InitMono(int argc, char *argv[])</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSString *mPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@&quot;Contents/Libraries/lib&quot;];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//g_setenv(&quot;MONO_PATH&quot;, [mPath UTF8String], 1);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//mono_mkbundle_init();  //call this instead of loading the dll below</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>MonoDomain *domain;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// these next 2 lines are used to load a file from the bundle directory</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>// if we call mono_mkbundle_init then we do not need these 2 lines</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSString *libraryPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@&quot;Contents/Libraries/&quot;];</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>NSString *sampleAssemblyPath = [libraryPath stringByAppendingPathComponent:@&quot;MacMonoClient.exe&quot;];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//g_setenv(&quot;DYLD_LIBRARY_PATH&quot;, [libraryPath UTF8String], true);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//const gchar* val;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//val = g_getenv(&quot;DYLD_LIBRARY_PATH&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//NSLog(@&quot;Load Library %s&quot;, val);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//NSString* monoPath = [libraryPath stringByAppendingPathComponent:@&quot;lib&quot;];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//NSLog(@&quot;Mono %@&quot;, monoPath);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//NSLog(@&quot;initmono path %s&quot;, getenv(&quot;MONO_PATH&quot;));</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//setenv(&quot;MONO_PATH&quot;, [monoPath UTF8String], true);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//<span class="Apple-tab-span" style="white-space:pre">        </span>NSLog(@&quot;zero&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//<span class="Apple-tab-span" style="white-space:pre">        </span>else NSLog(&quot;one&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//NSString *sampleAssemblyPath = @&quot;MacMonoClient.exe&quot;;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSLog(@&quot;libraryPath: %@&quot;, sampleAssemblyPath);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSString* mymonoconfig = @&quot;&lt;configuration&gt;&lt;dllmap dll=\&quot;mobjc-glue.dylib\&quot; target=\&quot;&quot;;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mymonoconfig = [mymonoconfig stringByAppendingString:[libraryPath stringByAppendingPathComponent:@&quot;a.dylib&quot;]];</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>mymonoconfig = [mymonoconfig stringByAppendingString:@&quot;\&quot; /&gt;&lt;/configuration&gt;&quot;];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>[mymonoconfig writeToFile:[libraryPath stringByAppendingPathComponent:@&quot;mymonoconfig2&quot;] atomically:YES encoding:NSASCIIStringEncoding error:NULL];</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSString* configFile = [libraryPath stringByAppendingPathComponent:@&quot;mymonoconfig2&quot;];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mono_config_parse ([configFile UTF8String]);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>#if MONO26_MY</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSLog(@&quot;about to check for MOON_SOFT_DEBUG&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>const gchar *soft_debug;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>soft_debug = g_getenv (&quot;MOON_SOFT_DEBUG&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (soft_debug != NULL) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>NSLog(@&quot;we have MOON_SOFT_DEBUG %s&quot;, soft_debug);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>gchar *opt = g_strdup_printf (&quot;--debugger-agent=%s&quot;, soft_debug);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mono_jit_parse_options (1, &amp;opt);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>g_free (opt);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mono_debug_init (MONO_DEBUG_FORMAT_MONO);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>#endif</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>const gchar *my_debug;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>my_debug = g_getenv (&quot;MY_MONO_DEBUG&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (my_debug != NULL) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>NSLog(@&quot;MY DEBUG is %s&quot;, my_debug);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mono_debug_init (MONO_DEBUG_FORMAT_MONO);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>const gchar *mono_trace_level;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mono_trace_level = g_getenv (&quot;PMONO_TRACE_LEVEL&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (mono_trace_level != NULL)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>mono_trace_set_level_string(mono_trace_level);</div><div>
<br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mono_assembly_setrootdir([mPath UTF8String]);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>domain = mono_jit_init ([sampleAssemblyPath UTF8String]);//, &quot;3.0.04506&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>MonoAssembly *monoAssembly = mono_domain_assembly_open(domain, [sampleAssemblyPath UTF8String]);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSLog(@&quot;sample assembly: %p&quot;, monoAssembly);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>mono_jit_exec (domain, monoAssembly, 1, argv);</div><div><br></div><div>}</div><div><br></div>My main.m:</div><div><div>#import &lt;Cocoa/Cocoa.h&gt;</div>
<div><br></div><div>int main(int argc, char *argv[])</div><div>{<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NSAutoreleasePool *pool;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>pool = [[NSAutoreleasePool alloc] init];<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>InitMono(argc, (char**)argv);<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>[pool release];</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return NSApplicationMain(argc, (const char **) argv);</div>
<div>}</div><div><br></div><div class="gmail_quote">On Mon, Apr 5, 2010 at 9:33 AM, Alexander Chilcott <span dir="ltr">&lt;<a href="mailto:alexchilcott@gmail.com">alexchilcott@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hey guys,<div><br></div><div>I am an experienced C# developer and reasonably new to objective c and xcode. I am having issues embedding the Mono framework into an objective-C project I am working on. I have added the Mono.Framework to my linked frameworks in my xcode project, but there are no header files being displayed when I expand the Mono.Framework tree node in the xcode project. I have installed the latest mono framework and CSDK.</div>

<div><br></div><div>Does anyone have any experience with this? It seems to be a common theme among forum posts for embedding mono in objective-c. Apologies if there is a simple solution that I have missed, but I assure you I have googled my heart out :)</div>

<div><br></div><div>Thanks,</div><div>Alex</div>
<br>_______________________________________________<br>
Mono-osx mailing list<br>
<a href="mailto:Mono-osx@lists.ximian.com">Mono-osx@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-osx</a><br>
<br></blockquote></div><br></div></div>