Domanda

I'm converting an existing iOS application from Objective-C to RubyMotion.

The first major pitfall I've hit is that the AppDelegate class refers to other classes defined in the app.

Since these are compiled after the AppDelegate class, it raises an exception:

2012-06-20 13:38:03.088 myApp[3349:f803] *** Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant AppDelegate::User (NameError)

I can resolve the issue by explicitly stating in my Rakefile that the User class should be compiled before that AppDelegate class but that's hardly and optimal solution when you're dealing with an app with 30+ classes, many of which refer to each other.

Is there a better way to approach this issue in RubyMotion?

È stato utile?

Soluzione

I agree that using the app.files_dependencies approach can be burdensome once you have many classes.

In my app, I altered the app.files parameter instead, reordering it to put my most important things first (in my case, the lib/ folder I added):

app.files = (app.files.select { |f| f =~ /app\/lib/ } + app.files).uniq
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top