Comments (11)
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.
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.
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.
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.
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.
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.
@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.
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.
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.
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.
@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)
- Doing an in-app purchase in Electron app for the Mac App Store HOT 1
- [Question] Are there any simple ways to get a binary data of NSData or NSInlineData? HOT 4
- Do I need some release procedure?
- Unable install nodobjc in electron project
- Please update with fixed ffi "callback has been garbage collected" (ffi-napi maybe?) HOT 1
- Activating an application - may be a bug
- can't install nodobjc HOT 2
- Dynamic Linking Error HOT 3
- Question: Any help regarding usage of the NSSharingService (composeEmail)
- Error in electron 3.0.0 HOT 5
- TypeError: error setting argument 2 - writeInt64: Number/String 64-bit value required HOT 2
- Unable to call CoreTextFunctions
- $.import() is not importing nested frameworks
- .EKEventStore
- node event loop blocked whilst menus are active HOT 3
- crashed in electron 4.2.5 HOT 1
- is support Node V12 and electron 5+ HOT 3
- install error
- Question: how to create a NSWindow? HOT 1
- No native build was found for platform=darwin
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodobjc.