Sign in to follow this  
dechorus

Unity Port XNA to iOS step-by-step (using MonoGame)

Recommended Posts

Hey everyone,

 

So I have an XNA 4.0 windows game in VS2010 running on my Windows PC (windows 7).

 

The game itself isn't finished yet, but before I continue work on it I'd like to try to get it running on my iPad, so that I suss out the porting procedure and feel confident about continuing to use XNA. The primary platforms I'd like this game to go on would be on Windows (and possibly Mac) and iOS.

 

I know that monogame is the way to go with porting XNA to iOS, but I'm finding it difficult finding step by step walkthroughs as to how to actually do this.

 

This is what I currently have:

 

 

A windows 7 PC

Visual Studio 2010

My XNA 4.0 game project on windows 7

 

A Macbook

MonoDevelop (it was installed as part of the Unity 4.0 install)

An iOS developer account

Latest XCode

 

Can anyone point me to any tutorials or guides as to how I can, from here, get my game ported over to iOS? Any comprehensive help and tips along with them would be much appreciated.

 

Thanks so much.

Share this post


Link to post
Share on other sites

Well... now time for the bad news...

 

You also need a copy of Xamarin for iOS ( previously known as MonoTouch ).

 

Now for the worser bad news...

 

It has a 299$ price tag.  There is however a 30 day full functioning trial I believe.

Share this post


Link to post
Share on other sites

Well... now time for the bad news...

 

You also need a copy of Xamarin for iOS ( previously known as MonoTouch ).

 

Now for the worser bad news...

 

It has a 299$ price tag.  There is however a 30 day full functioning trial I believe.

 

Actually, no longer! If you use their brand-new Xamarin Studio package, you can release to Android, iOS, and Mac OS X for free. The free version is really only usable for smaller apps that don't require P/Invoke (its not supported) and the version that does support P/Invoke is $299 (for everything). Its not perfect, but its a good starting point.

 

As far as XNA to MonoGame is concern, it should be pretty straight forward if you are only of Windows. When you get into Mac and Linux it does become slightly more complicated. I've never really worked with XNA or MonoGame, but people who I know have (and made the switch) say it isn't had to move. Still, my first move would be to switch from XNA to MonoGame in Windows first and then switch from Windows to Mac OS X or Linux.

Share this post


Link to post
Share on other sites

Well... now time for the bad news...

 

You also need a copy of Xamarin for iOS ( previously known as MonoTouch ).

 

Now for the worser bad news...

 

It has a 299$ price tag.  There is however a 30 day full functioning trial I believe.

 

Actually, no longer! If you use their brand-new Xamarin Studio package, you can release to Android, iOS, and Mac OS X for free. The free version is really only usable for smaller apps that don't require P/Invoke (its not supported) and the version that does support P/Invoke is $299 (for everything). Its not perfect, but its a good starting point.

 

As far as XNA to MonoGame is concern, it should be pretty straight forward if you are only of Windows. When you get into Mac and Linux it does become slightly more complicated. I've never really worked with XNA or MonoGame, but people who I know have (and made the switch) say it isn't had to move. Still, my first move would be to switch from XNA to MonoGame in Windows first and then switch from Windows to Mac OS X or Linux.

 

The pInvoke limitation is worse than you think...  Your code may not require pInvoke, but MonoGame does ( that's how it calls to OpenGL ).  I may be wrong, but im 90% certain the "free" version doesn't work with MonoGame.

Share this post


Link to post
Share on other sites

The pInvoke limitation is worse than you think...  Your code may not require pInvoke, but MonoGame does ( that's how it calls to OpenGL ).  I may be wrong, but im 90% certain the "free" version doesn't work with MonoGame.

 

Well MonoGame uses OpenTK for the OpenGL/ES backends. I checked the source code and it uses System.Runtime.InteropServices not DllImport or any of the other P/Invoke methods (although I don't know what InteropServices does in the backend).

 

EDIT: Information in this post is completely wrong and invalid.

Edited by Josh Vega

Share this post


Link to post
Share on other sites

Well MonoGame uses OpenTK for the OpenGL/ES backends. I checked the source code and it uses System.Runtime.InteropServices not DllImport or any of the other P/Invoke methods (although I don't know what InteropServices does in the backend).

 

I think you misunderstand what p/invoke means.

 

p/invoke is a shorthand for saying it uses InteropServices to perform automatic marshalling to and from the platform's libraries rather than using the .net method.

 

The source code you linked to has about 600 lines of this:

[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glDrawArrays", ExactSpelling = true)]
internal extern static void DrawArrays(OpenTK.Graphics.ES20.BeginMode mode, Int32 first, Int32 count);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glDrawElements", ExactSpelling = true)]
internal extern static void DrawElements(OpenTK.Graphics.ES20.BeginMode mode, Int32 count, OpenTK.Graphics.ES20.DrawElementsType type, IntPtr indices);

 

 

That is a textbook example of p/invoke.  

 

You wrote it does not use DllImport, but every single one of those entries is marked as DllImport.  Every single function is marked with "System.Runtime.InteropServices.DllImport".

 

 

That is what Serapth was pointing out.  It uses p/invoke all over the place, which your source code link confirmed rather than denied.

 

 

This is one reason I personally dislike the "free" libraries that have requirements of paid libraries.  They are generally less free than they advertise.

Edited by frob

Share this post


Link to post
Share on other sites

Woah!

 

I don't even know how I missed that. I know that from prior experience that InteropServices is a P/Invoke method. I must have have gotten the question confused with another C# question I was emailed by a friend. Its been a busy day for me.

 

Sorry about that.

Share this post


Link to post
Share on other sites

@SeraPath and @Josh Vega: The MonoGame team is working with Xamarin, to have their assemblies white listed, so they can be used with the Free version.

No ETA yet, but it is coming.

 

@dechorus, I would suggest posting any questions you have in the monogame.codeplex.com discussion forums.

 

D.

Share this post


Link to post
Share on other sites

@SeraPath and @Josh Vega: The MonoGame team is working with Xamarin, to have their assemblies white listed, so they can be used with the Free version.

No ETA yet, but it is coming.

 

Now that is an excellent news ! Do I understand it correctly that when these assemblies are whitelisted, one will be able to use the free version of Xamarin, then ?
 

To be more specific, if I am not using any other assemblies (other than .NET and XNA), I read it that I actually am not doing any other PInvoke, correct ?

 

Or will only XNA replacements will be whitelisted, but not the .NET ones [for the free version] ? 

Share this post


Link to post
Share on other sites

Unfortunately the free version of Xamarin also has a limited app size. I forget the exact size (it's hard to find on their website), but it's very tiny (I think 32KB). The default XNA project already exceeds that size because of the icon. You can shrink the icon, but any not-completely-trival game will exceed that size with just compiled code.

Share this post


Link to post
Share on other sites

32 KBs, as in, half the RAM of an 8-bit Atari 800 XL, from an era almost half a century ago ?

 

 

"But -hey- it's free !"

 

 

You gotta admit though, that's one great way how to piss potential customers.

 

 

I bet that must have been an idea of some CTO. Those are usually the ones displaced / torn out from the reality the most...

 

 

I sure would like the stuff they're smoking. Must be of top-most Columbian quality biggrin.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Forum Statistics

    • Total Topics
      628285
    • Total Posts
      2981836
  • Similar Content

    • By Simplepg
      https://play.google.com/store/apps/details?id=simple.gplay.GamesInABox
    • By Simplepg
      https://play.google.com/store/apps/details?id=simple.gplay.GamesInABox
    • By ForgedInteractive


      Who We Are
      We are Forged Interactive, a small team of like-minded game developers with the sole purpose of making games we love! We're a team of artists, animators, programmers, level designers, writers, composers, producers, and other creative minds. We want to make games that you, the modern gamer want to play! We hope to build a community that enjoys our games as much as we love creating them. With your feedback and support we will be able to achieve that.

      About the Game
      GAME NAME is a fun, action-packed army builder with unique characters, challenges and engaging levels. Set forth on an adventure to protect friends, family and countrymen from new adversaries. Once defeated your enemies turn coat and join you in your adventures. Players can enjoy a range of troops and abilities based on their gameplay style which become more important as maps introduce more challenging terrain, enemies and bosses. Strong orc knights, dangerous shamans, and even a dragon are out on the prowl. Knowing when to fight and when to run, and how to manage your army is essential. Your actions alone decide the fate of this world.

      Previous Work by Team
      Although we are working towards our first game as a team, our team members themselves have past experience in the industry.
      This includes members who have worked on titles including:
      Final Fantasy Kingsglaive, FIFA, Xcom 2 and Civilization.

      Who are we looking for? 3D Modellers Concept Artists Marketing Specialists Level Designer

      What do we expect? Reference work or portfolio. Examples what have you already done and what projects you have worked on academic or otherwise. The ability to commit to the project on a regular basis. If you are going on a two-week trip, we don't mind, but it would be good if you could commit 10+ hours to the project each week. Willingness to work with a royalty based compensation model, you will be paid when the game launches. Openness to learning new tools and techniques
      What can we offer? Continuous support and availability from our side. You have the ability to give design input, and creative say in the development of the game. Shown in credits on websites, in-game and more. Insight and contacts from within the Industry.
      Contact
      If you are interested in knowing more or joining. Please email or PM us on Skype. Myself or Colin will reply to you within 48 hours.

      E-mail: Recruitment@ForgedInteractive.com
      Skype: ForgedInteractive

      Regards,
      David and Colin

      Follow us on:

      Facebook: https://www.facebook.com/ForgedInteractive/
      Twitter: @ForgedInteract
      Youtube: https://www.youtube.com/channel/UCpK..._as=subscriber
      Reddit: https://www.reddit.com/user/Forged_Interactive/
    • By Eck
      I just saw their courses were knocked down to $10 each and figured I'd share the info here. They have stuff for Unity, Unreal, drawing, business, etc. I haven't used their stuff before, but the previews I looked at seemed pretty good and there is a user review system as well.
      https://www.udemy.com/courses/search/?q=Unity&src=ukw
      - Eck
       
    • By zizulot
      first and only logo , for now
  • Popular Now