Getting started with iPhone and JSCocoa

125 views
Skip to first unread message

Charles Lowell

unread,
Aug 4, 2010, 4:26:49 PM8/4/10
to JSCocoa
Hi,

Both new to jscocoa and xcode, I'm having trouble getting the
iPhoneTest2 project to build. If I just open it up and try to build
and run, I get the following two errors:

1)

CpResource /Users/cowboyd/Library/Developer/Xcode/DerivedData/
iPhoneTest2-alwwtovvbnlyjqbjnitkbrrugbud/Build/Products/Debug/
iPhoneTest2.app/Contents/Resources/iPhoneMain.js Classes/../
iPhoneMain.js
cd /Users/cowboyd/Projects/jscocoa/iPhone
/Xcode4/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/
SharedSupport/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/
Contents/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn
-exclude .git -resolve-src-symlinks /Users/cowboyd/Projects/jscocoa/
iPhone/Classes/../iPhoneMain.js /Users/cowboyd/Library/Developer/Xcode/
DerivedData/iPhoneTest2-alwwtovvbnlyjqbjnitkbrrugbud/Build/Products/
Debug/iPhoneTest2.app/Contents/Resources

/Users/cowboyd/Projects/jscocoa/iPhone/Classes/..: No such file or
directory
Command /Xcode4/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/
Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
CoreBuildTasks.xcplugin/Contents/Resources/pbxcp failed with exit code
1

Command /Xcode4/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/
Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
CoreBuildTasks.xcplugin/Contents/Resources/pbxcp failed with exit code
1


2)
CompileXIB iPhoneTest2ViewController.xib
cd /Users/cowboyd/Projects/jscocoa/iPhone
setenv DYLD_FRAMEWORK_PATH "/Xcode4/usr/bin/../../Library/
PrivateFrameworks:/Xcode4/usr/bin/../../Library/Frameworks"
setenv XCODE_DEVELOPER_USR_PATH /Xcode4/usr/bin/..
/Xcode4/usr/bin/ibtool --errors --warnings --notices --output-
format human-readable-text --compile /Users/cowboyd/Library/Developer/
Xcode/DerivedData/iPhoneTest2-alwwtovvbnlyjqbjnitkbrrugbud/Build/
Products/Debug/iPhoneTest2.app/Contents/Resources/
iPhoneTest2ViewController.nib /Users/cowboyd/Projects/jscocoa/iPhone/
iPhoneTest2ViewController.xib

/* com.apple.ibtool.document.warnings */
/Users/cowboyd/Projects/jscocoa/iPhone/
iPhoneTest2ViewController.xib:-1: warning: The view outlet of File's
Owner is connected to View but view is no longer defined on view. [4]
/* com.apple.ibtool.document.errors */
/Users/cowboyd/Projects/jscocoa/iPhone/iPhoneTest2ViewController.xib:
51: error: Pattern colors are not supported by the iPhone SDK for
iPhone OS versions prior to 3.0. [12]


ideas?

cheers,
Charles

Patrick Geiller

unread,
Aug 5, 2010, 11:00:29 AM8/5/10
to jsc...@googlegroups.com
> /Users/cowboyd/Projects/jscocoa/iPhone/Classes/..: No such file or
> directory

Empty remnant folder removed. iPhoneMain.js referenced it, but it didn't appear in git. Please get the new version.

-Patrick

Charles Lowell

unread,
Aug 5, 2010, 2:01:16 PM8/5/10
to jsc...@googlegroups.com
Patrick,

Thanks for the response.... That seemed to clear up one error, but now I see a new one:

/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m: In function 'jsCocoaObject_callAsFunction_ffi':
/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m:4332: error: 'struct objc_super' has no member named 'class'

Is it possible that I'm missing some headers?

cheers,
Charles


Charles Lowell

unread,
Aug 5, 2010, 2:56:07 PM8/5/10
to JSCocoa
If I comment this out, the application does compile, and even
launches, but only to a blank screen. I suspect that it is due to the
error that the build is seeing on the .xib:

CompileXIB iPhoneTest2ViewController.xib
cd /Users/cowboyd/Projects/jscocoa/iPhone
setenv DYLD_FRAMEWORK_PATH "/Xcode4/usr/bin/../../Library/
PrivateFrameworks:/Xcode4/usr/bin/../../Library/Frameworks"
setenv PATH "/Xcode4/Platforms/iPhoneSimulator.platform/Developer/
usr/bin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv XCODE_DEVELOPER_USR_PATH /Xcode4/usr/bin/..
/Xcode4/usr/bin/ibtool --errors --warnings --notices --output-
format human-readable-text --compile /Users/cowboyd/Library/Developer/
Xcode/DerivedData/iPhoneTest2-alwwtovvbnlyjqbjnitkbrrugbud/Build/
Products/Debug-iphonesimulator/iPhoneTest2.app/
iPhoneTest2ViewController.nib /Users/cowboyd/Projects/jscocoa/iPhone/
iPhoneTest2ViewController.xib

/* com.apple.ibtool.document.warnings */
/Users/cowboyd/Projects/jscocoa/iPhone/
iPhoneTest2ViewController.xib:-1: warning: The view outlet of File's
Owner is connected to View but view is no longer defined on view. [4]
/* com.apple.ibtool.document.errors */
/Users/cowboyd/Projects/jscocoa/iPhone/iPhoneTest2ViewController.xib:
51: error: Pattern colors are not supported by the iPhone SDK for
iPhone OS versions prior to 3.0. [12]

Do I have something misconfigured?

cheers,
Charles

Patrick Geiller

unread,
Aug 5, 2010, 3:43:47 PM8/5/10
to jsc...@googlegroups.com
/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m: In function 'jsCocoaObject_callAsFunction_ffi':
/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m:4332: error: 'struct objc_super' has no member named 'class'

Is it possible that I'm missing some headers?

iPhoneTest2 is a proof of concept so it's expected to break :)
The last SDK I tested is 3.1.3.

51: error: Pattern colors are not supported by the iPhone SDK for
iPhone OS versions prior to 3.0. [12]

Which SDK are you using?

If I comment this out, the application does compile, and even
launches, but only to a blank screen. I suspect that it is due to the
error that the build is seeing on the .xib:

You're seeing a blank screen because of the objc_super error : the derived class can't call the parent class which does most of the work.

-> Go to JSCocoaController.m:4332 and hold command while double clicking objc_super, this will take you to its definition. What members does it define ?

-Patrick

Charles Lowell

unread,
Aug 5, 2010, 3:51:05 PM8/5/10
to jsc...@googlegroups.com
On Aug 5, 2010, at 2:43 PM, Patrick Geiller wrote:

/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m: In function 'jsCocoaObject_callAsFunction_ffi':
/Users/cowboyd/Projects/jscocoa/iPhone/../JSCocoa/JSCocoaController.m:4332: error: 'struct objc_super' has no member named 'class'

Is it possible that I'm missing some headers?

iPhoneTest2 is a proof of concept so it's expected to break :)
The last SDK I tested is 3.1.3.

No worries, you'll just have to put up with my silly questions while I muddle through it.


51: error: Pattern colors are not supported by the iPhone SDK for
iPhone OS versions prior to 3.0. [12]

Which SDK are you using?


Perhaps that is it. I (think) I'm using 3.2. I also tried on 4.0 with no luck. It seems like an odd error message, because its complaining about support prior to 3.0


If I comment this out, the application does compile, and even
launches, but only to a blank screen. I suspect that it is due to the
error that the build is seeing on the .xib:

You're seeing a blank screen because of the objc_super error : the derived class can't call the parent class which does most of the work.

So what is the relation of the iPhoneTest2 to JSCocoa, does it use the JSCocoa library, or does it only borrow some of the concepts?

cheers,
Charles



-> Go to JSCocoaController.m:4332 and hold command while double clicking objc_super, this will take you to its definition. What members does it define ?

-Patrick

Patrick Geiller

unread,
Aug 5, 2010, 4:16:23 PM8/5/10
to jsc...@googlegroups.com
>
> Perhaps that is it. I (think) I'm using 3.2. I also tried on 4.0 with no luck. It seems like an odd error message, because its complaining about support prior to 3.0

Have you tried both device and simulator ?

>>
>>> If I comment this out, the application does compile, and even
>>> launches, but only to a blank screen. I suspect that it is due to the
>>> error that the build is seeing on the .xib:
>>
>> You're seeing a blank screen because of the objc_super error : the derived class can't call the parent class which does most of the work.
>
> So what is the relation of the iPhoneTest2 to JSCocoa, does it use the JSCocoa library, or does it only borrow some of the concepts?

iPhoneTest2 uses JSCocoa (which itself has some code testing for TARGET_OS_IPHONE) and uses custom classes written in Javascript in iPhoneMain.js. These Javascript classes still need to call the parent SDK methods, which is done with objc_super. (this.Super(arguments) in Javascript)


Btw I still need you to do this :

-> Go to JSCocoaController.m:4332 and hold command while double clicking objc_super, this will take you to its definition. What members does it define ?

Alternatively, you could try switching the unknown 'class' member with 'super_class' and see if that works.

-Patrick

Charles Lowell

unread,
Aug 5, 2010, 5:09:05 PM8/5/10
to jsc...@googlegroups.com
Here is the definition of objc_super:

struct objc_super {
    id receiver;
#if !defined(__cplusplus)  &&  !__OBJC2__
    Class class/* For compatibility with old objc-runtime.h header */
#else
    Class super_class;
#endif
    /* super_class is the first class to search */
};
#endif

If I change class -> super_class, then it compiles and runs, but I still don't see the view

I'm still getting the error in the .xib 

and here is the output of the debug console on the simulator:

GNU gdb 6.3.50-20050815 (Apple version gdb-1502) (Thu Jul  8 12:27:19 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 15559.
2010-08-05 16:06:45.979 iPhoneTest2[15559:207] JSLint error (818, 11)=Variable tv was not declared correctly.
2010-08-05 16:06:45.980 iPhoneTest2[15559:207] var v = tv = token.rawValue
2010-08-05 16:06:45.981 iPhoneTest2[15559:207]           ^
2010-08-05 16:06:45.981 iPhoneTest2[15559:207] JSLint error (818, 11)=Stopping, unable to continue. (69% scanned).
2010-08-05 16:06:45.982 iPhoneTest2[15559:207] var v = tv = token.rawValue
2010-08-05 16:06:45.982 iPhoneTest2[15559:207]           ^
2010-08-05 16:06:45.998 iPhoneTest2[15559:207] JSException: SyntaxError: Parse error on line 819 of /Users/cowboyd/Library/Application Support/iPhone Simulator/3.2/Applications/78D59ADE-0C35-409A-8A17-B74C3E42A48E/iPhoneTest2.app/class.js
2010-08-05 16:06:46.058 iPhoneTest2[15559:207] TypeError: Result of expression 'UITableView.instance' [<UITableView: 0x507a000; frame = (0 0; 0 0); clipsToBounds = YES; layer = <CALayer: 0x493b830>>] is not a function. on line 66 of /Users/cowboyd/Library/Application Support/iPhone Simulator/3.2/Applications/78D59ADE-0C35-409A-8A17-B74C3E42A48E/iPhoneTest2.app/iPhoneMain.js
2010-08-05 16:06:46.059 iPhoneTest2[15559:207] TypeError: Result of expression 'this.viewController.view' [null] is not an object. on line 44 of /Users/cowboyd/Library/Application Support/iPhone Simulator/3.2/Applications/78D59ADE-0C35-409A-8A17-B74C3E42A48E/iPhoneTest2.app/iPhoneMain.js


and on a 3.2 device:

GNU gdb 6.3.50-20050815 (Apple version gdb-1470) (Thu May 27 05:54:06 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys004
target remote-mobile /tmp/.XcodeGDBRemote-15288-46
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to thread 12035]
[Switching to thread 12035]
sharedlibrary apply-load-rules all
2010-08-05 16:08:27.727 iPhoneTest2[2456:207] JSLint error (818, 11)=Variable tv was not declared correctly.
2010-08-05 16:08:27.739 iPhoneTest2[2456:207] var v = tv = token.rawValue
2010-08-05 16:08:27.742 iPhoneTest2[2456:207]           ^
2010-08-05 16:08:27.744 iPhoneTest2[2456:207] JSLint error (818, 11)=Stopping, unable to continue. (69% scanned).
2010-08-05 16:08:27.747 iPhoneTest2[2456:207] var v = tv = token.rawValue
2010-08-05 16:08:27.750 iPhoneTest2[2456:207]           ^
2010-08-05 16:08:27.879 iPhoneTest2[2456:207] JSException: SyntaxError: Parse error on line 819 of /var/mobile/Applications/2B427196-CC78-4A4E-9B4D-0736A2432AA8/iPhoneTest2.app/class.js
2010-08-05 16:08:28.322 iPhoneTest2[2456:207] TypeError: Result of expression 'UITableView.instance' [<UITableView: 0x81ae00; frame = (0 0; 0 0); clipsToBounds = YES; layer = <CALayer: 0x154840>>] is not a function. on line 66 of /var/mobile/Applications/2B427196-CC78-4A4E-9B4D-0736A2432AA8/iPhoneTest2.app/iPhoneMain.js
2010-08-05 16:08:28.331 iPhoneTest2[2456:207] TypeError: Result of expression 'this.viewController.view' [null] is not an object. on line 44 of /var/mobile/Applications/2B427196-CC78-4A4E-9B4D-0736A2432AA8/iPhoneTest2.app/iPhoneMain.js

does that shed any light?

cheers,
Charles

On Aug 5, 2010, at 3:16 PM, Patrick Geiller wrote:


Perhaps that is it. I (think) I'm using 3.2. I also tried on 4.0 with no luck. It seems like an odd error message, because its complaining about support prior to 3.0

Have you tried both device and simulator ?

Yes, with the same result.


If I comment this out, the application does compile, and even
launches, but only to a blank screen. I suspect that it is due to the
error that the build is seeing on the .xib:

You're seeing a blank screen because of the objc_super error : the derived class can't call the parent class which does most of the work.

So what is the relation of the iPhoneTest2 to JSCocoa, does it use the JSCocoa library, or does it only borrow some of the concepts?

iPhoneTest2 uses JSCocoa (which itself has some code testing for TARGET_OS_IPHONE) and uses custom classes written in Javascript in iPhoneMain.js. These Javascript classes still need to call the parent SDK methods, which is done with objc_super. (this.Super(arguments) in Javascript)


Btw I still need you to do this :

-> Go to JSCocoaController.m:4332 and hold command while double clicking objc_super, this will take you to its definition. What members does it define ?

Alternatively, you could try switching the unknown 'class' member with 'super_class' and see if that works.

-Patrick

Patrick Geiller

unread,
Aug 6, 2010, 11:28:39 AM8/6/10
to jsc...@googlegroups.com

Fixed. 

Charles Lowell

unread,
Aug 6, 2010, 12:29:33 PM8/6/10
to jsc...@googlegroups.com
Awesome! It works on both the 3.2 simulator and actual device.

There are still lots of warnings and the error in the .xib, but I guess that stuff is not critical.

cheers,
Charles

LucasTizma

unread,
Aug 26, 2010, 10:00:45 PM8/26/10
to JSCocoa
With Apple's declaration that interpreted languages are not allowed on
the iPhone, is it safe to assume that the use of JSCocoa would cause
an application to be rejected from the App Store?

Patrick Geiller

unread,
Aug 27, 2010, 2:43:29 AM8/27/10
to jsc...@googlegroups.com

> With Apple's declaration that interpreted languages are not allowed on
> the iPhone, is it safe to assume that the use of JSCocoa would cause
> an application to be rejected from the App Store?

Yes.

They did relax the rules recently : http://www.appleinsider.com/articles/10/06/11/apple_relaxes_ios_sdk_to_allow_lua_but_block_flash.html
... and JSCocoa uses the iPhone's JavascriptCore library. Maybe it could go through, or will someday. But just to be safe, don't depend on JSCocoa.

-Patrick

Charles Lowell

unread,
Aug 29, 2010, 5:33:51 PM8/29/10
to jsc...@googlegroups.com
Section 3.3.2 from the iOS SDK Developer Agreement:

Unless otherwise approved by Apple in writing, no
interpreted code may be downloaded or used in an Application except for code that is interpreted
and run by Apple's Documented APIs and built-in interpreter(s).


The key there is "except for code that is interpreted and run by Apple's Documented APIs and built-in interpreter(s)"

It seems like JavaScriptCore fits the bill as both "documented" and "built-in".

I think what Apple wants to prevent is you doing something like embedding a ruby or python or (Flash!?!) interpreter or something like that. 

cheers,
Charles

Patrick Geiller

unread,
Aug 29, 2010, 9:24:37 PM8/29/10
to jsc...@googlegroups.com

The key there is "except for code that is interpreted and run by Apple's Documented APIs and built-in interpreter(s)"

It seems like JavaScriptCore fits the bill as both "documented" and "built-in".

Unfortunately JavascriptCore is not documented on the iPhone, just built-in. JSCocoa works by importing the JavascriptCore headers from the Mac and, at launch, grabbing each JavascriptCore function with dlsym().

-Patrick

Steve Conover

unread,
Mar 1, 2011, 5:18:09 PM3/1/11
to jsc...@googlegroups.com
FWIW I just tried to build the project (10.6, 3.2 Simulator) and got a
similar error, I had to change this

#elif TARGET_IPHONE_SIMULATOR || !TARGET_OS_IPHONE
_super.class = superSelectorClass;


to this...

#elif TARGET_IPHONE_SIMULATOR || !TARGET_OS_IPHONE
_super.super_class = superSelectorClass;


then it worked.

> Unfortunately JavascriptCore is not documented on the iPhone, just built-in. JSCocoa works by importing the JavascriptCore headers from the Mac and, at launch, grabbing each JavascriptCore function with dlsym().

Has anyone tried to get a JSCocoa app w/ JSCore bundled (not making
use of a private api) through to approval? It would seem that the
revisions to 3.3.2 technically allow for JSCocoa-style apps as long as
there's no code downloaded.

-Steve

Reply all
Reply to author
Forward
0 new messages