Giter VIP home page Giter VIP logo

Comments (11)

TooTallNate avatar TooTallNate commented on July 28, 2024

Oh I think I see. Yes, it's the char ** arg that's not right. It's expecting a "pointer" type, so try passing ffi.Pointer.NULL there, to pass in the null pointer.

from nodobjc.

radare avatar radare commented on July 28, 2024

Thanks! this code seems to work:

var ret = $.UIApplicationMain (0, ffi.Pointer.NULL, null, null); 

But I'm unable to pass a NSString on the 3rd/4th arguments. Is this code fine?

var str = $.NSString('stringWithUTF8String', "hello world")
$.UIApplicationMain(0, ffi.Pointer.NULL, str, null);

Output is:

2012-05-07 01:03:13.593 node[65824:707] *** Assertion failure in int UIApplicationMain(int, char **, NSString *, NSString *)(), /SourceCache/UIKit/UIKit-1912.3/UIApplication.m:1568

For this :

var ret = $.UIApplicationMain (0, ffi.Pointer.NULL, "FooClass", null);

i get

Assertion failed: (!handle.IsEmpty()), function Unwrap, file /var/root/.node-gyp/0.6.14/src/node_object_wrap.h, line 51.

How are strings suposed to be passed here?

from nodobjc.

TooTallNate avatar TooTallNate commented on July 28, 2024

Your first version should work:

var str = $.NSString('stringWithUTF8String', "hello world")
$.UIApplicationMain(0, ffi.Pointer.NULL, str, null);

Note that the assertion error is coming from within UIApplication.m, so I believe it's going through properly, just something else incorrect about the string itself (like the Class not existing maybe).

Try running gdb on node and your script and seeing what happens.

from nodobjc.

radare avatar radare commented on July 28, 2024

gdb didnt stops on the assert. i tried placing a breakpoing on the symbol, but steping takes forever.. would be better to have a simpler test case for this i think.

btw, ios-bridgesupport bricks springboard.. which is kinda annoying because you are forced to reflash the phone :) I have been investigating the issue, and I will like to know if there's any way to specify a different path to find those bridgesupport files.

Thanks

from nodobjc.

bored-engineer avatar bored-engineer commented on July 28, 2024

I agree. I've had similar issues in the past. The ability to pull bridgesupport files from an external location would be very appreciated.

from nodobjc.

radare avatar radare commented on July 28, 2024

I have modified the NodObjC library (lib/import.js) to load the bridgesupport from "/usr/local/System/Library/Frameworks".

That worked fine, so i will modify my ios-bridgesupport cydia package to install there. If there's any BS directory in the filesystem, the SpringBoard will crash and you'll get a bricked iDevice.

It would be good to have a standard path for this, or handle an environment variable to choose the user-defined path.

After this I created an standalone /Applications/NodeJS.app with icon, launcher script and nodejs hello world for iOS.
The problem i'm facing now is related to the subclassing.

@TooTallNate i dont need to debug anything. by googling a bit I found that the assert in UIApplicationMain means that the referenced class does not exist. So i registered.

var $ = require('NodObjC')
var ffi = require ('node-ffi')

$.import ('UIKit')
var pool = $.NSAutoreleasePool('alloc')('init')

/* load AppDelegate */
var AppDelegate = $.NSObject.extend ('AppDelegate')
AppDelegate('respondsToSelector','viewDidLoad');
AppDelegate.addMethod('viewDidLoad', 'v@:@',
    function (self, _cmd, notif) {
        console.log('GOT VIEW DID LOAD');
    })
AppDelegate.addMethod('didFinishLaunching', 'v@:@',
    function (self, _cmd, notif) {
        console.log('got applicationDidFinishLauching')
        console.log(notif)
    })
AppDelegate.register()

var str = $.NSString('stringWithUTF8String', "AppDelegate"
var ret = $.UIApplicationMain (0, ffi.Pointer.NULL, null, str);

The problem is that applicationDidFinishLaunching is never called, so I can't initialize the window and the OS kills the app. I need to define the AppDelegate class in code to match:

@interface AppDelegate : NSObject <UIApplicationDelegate> {
   ...

How can I do this? i can't find any way to specify that this object will understand the UIApplicatinDelegate protocol..

from nodobjc.

TooTallNate avatar TooTallNate commented on July 28, 2024

@radare So I think you're simply not registering the proper methods to invoke. It should be applicationDidFinishLaunching: (also note the : at the end). So change it to that and you should be good.

To answer your second question, you don't actually have to specify anywhere that the object implements the UIApplicationDelegate. This information in Obj-C code is only used by the compiler, so for NodObjC you just need to make sure that the anticipated methods do exist.

from nodobjc.

TooTallNate avatar TooTallNate commented on July 28, 2024

Also:

AppDelegate('respondsToSelector','viewDidLoad');

^ FYI, that line doesn't seem to do anything. respondsToSelector: returns a bool true or false (false in this case, since "viewDidLoad" isn't registered yet), and you're supposed to use the return value for something.

from nodobjc.

TooTallNate avatar TooTallNate commented on July 28, 2024

P.S. when you get something that actually boot up, please show me your code! It would be great to add an iOS app to the examples dir of the repo.

I'm gonna close this issue, but open another one about the more flexible BridgeSupport file locations and I'll try to get to that soon.

from nodobjc.

radare avatar radare commented on July 28, 2024

Sorry for those misstakes. I tried with:

AppDelegate.addMethod('applicationDidFinishLa
unching:', 'v@:@',

And the fuction was never called :/ maybe this is not the place to discuss this :)

I plan to make cydia package for the module and a sample app too.

Thanks!

from nodobjc.

TooTallNate avatar TooTallNate commented on July 28, 2024

@radare No prob! And if you're looking for more support come to the #NodObjC IRC room on the freenode network.

P.S. if you're looking for some inspiration, check out the OS X GUI app example: https://github.com/TooTallNate/NodObjC/blob/master/examples/NodeCocoaHelloWorld.app/Contents/MacOS/app.js

^ I assume only minor tweaks would be needed to get an iOS app going...

from nodobjc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.