Author Topic: iNinjas Python Objc  (Read 823 times)

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
iNinjas Python Objc
« on: September 03, 2012, 04:03:07 pm »
Ok here Is my version of Python-ObjC.  For all you noobs, it is a bridge/wrapper written in python to access ObjectivE-C classes and objects.  I used python-ctypes instead of writing it in C like PyObjC.   I've been working on this the past couple weeks and It is perfected I believe.   It comes with some example scripts that I modified,  using another project called cocoapy.  I copied absolutley no code from that project except for the example scripts because I did not know any ObjC at the time and am still learning.  Even still they had to be modified to work with my module. 

You can checkout with this command:

svn co https://ios-python-objc.googlecode.com/svn/trunk objc

Ok,  one of the most important functions you will use are

load_library()

I did not load UIKit or Foundation within the module itself, this will be something done within the user script.  So to load say UIKit,  its as easy as

load_library("UIKit")


No path definition neccesarry as long as the frameworks are in the right path.  Actually the libraryloader is very smart and shouldn't have trouble finding any dylibs or frameworks you throw in there.   

Take for example list_classes.py

# List the names of all loaded Objective-C classes.

import objc
import ctypes
import sys


framework = sys.argv[1]
objc.load_library(framework)

count = objc.objc_getClassList(None, 0)
print '%d classes found:' % count

classes = (ctypes.c_void_p * count)()
count = objc.objc_getClassList(classes, count)

class_names = []
for cls in classes:
    class_names.append(objc.class_getName(cls))
   
class_names.sort()

for name in  class_names:
    print name


This script will list all classes available from a given framework or library.  It is used with

python list_classes.py UIKit

for example,  "UIKit" being the example.   

So far this module is pretty dependent on /usr/lib/libobjc.dylib and will not be functional without it.  I hope to soon create a functional GUI app with this but who knows,  thats why I released it so others could play with it.

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: iNinjas Python Objc
« Reply #1 on: September 03, 2012, 04:08:29 pm »
Very cool! I'm going to have to take a look at this!

8BitAce

  • Hero Member
  • *****
  • Posts: 703
  • Reputation: 57
  • If at first you don't succeed; call it version 1.0
  • Computers: Toshiba L505D-GS6000
  • iDevices: iPad 2 16GB WiFi, iPod 2g, iPod 4g
Re: iNinjas Python Objc
« Reply #2 on: September 03, 2012, 04:11:03 pm »
Awesome work Boo! Even if you know ObjC this can come in real handy for making little test scripts!

[null]

  • Hero Member
  • *****
  • Posts: 646
  • Reputation: 42
  • the halloween jack is a real cool cat
  • Computers: I have a PC running Windows 7 that was built by my uncle. I also have a Newsmy T3 Android Tablet.
  • iDevices: iPod Touch 4G
Re: iNinjas Python Objc
« Reply #3 on: September 03, 2012, 04:48:46 pm »
Awesome work! +1
__  __           ___    ___          
/\ \/\ \         /\_ \  /\_ \          
\ \ `\\ \  __  __\//\ \ \//\ \     
 \ \ , ` \/\ \/\ \ \ \ \  \ \ \          
  \ \ \`\ \ \ \_\ \ \_\ \_ \_\ \_
   \ \_\ \_\ \____/ /\____\/\____\
    \/_/\/_/\/___/  \/____/\/____/

A12danrulz

  • Leader
  • Hero Member
  • *****
  • Posts: 4017
  • Reputation: 216
  • Badges:
Re: iNinjas Python Objc
« Reply #4 on: September 03, 2012, 06:16:44 pm »
I love you. ;) Finally an easy way for me to get started on objc

Don't like seeing ads? Click here to register!

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: iNinjas Python Objc
« Reply #5 on: September 04, 2012, 05:19:32 am »
No prob!  Thanks for the thanks :)

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: iNinjas Python Objc
« Reply #6 on: September 04, 2012, 11:05:16 pm »
this is awesome. but i keep getting a Killed: 9 when checking out

Apetrick

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3512
  • Reputation: 90
  • <Apetrick> lank is 1337
  • Badges:
  • iDevices: Ipod Touch 4g
Re: iNinjas Python Objc
« Reply #7 on: September 04, 2012, 11:06:55 pm »
this is awesome. but i keep getting a Killed: 9 when checking out
Use ldone from cydia to sign the binary.
ldone /path/to/binary -s
<%a12danrulz> Idk, but doing a DoS from an apple device is like fighting a bear with a plastic spork

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: iNinjas Python Objc
« Reply #8 on: September 04, 2012, 11:26:07 pm »
Thanks i figured that was the problem, but if i cant checkout than how can i download the binary that needs to be signed

Apetrick

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3512
  • Reputation: 90
  • <Apetrick> lank is 1337
  • Badges:
  • iDevices: Ipod Touch 4g
Re: iNinjas Python Objc
« Reply #9 on: September 04, 2012, 11:45:16 pm »
Thanks i figured that was the problem, but if i cant checkout than how can i download the binary that needs to be signed
I'm sorry I forgot, this isn't a binary. So I don't know how to fix it unless I'm getting things wrong.
<%a12danrulz> Idk, but doing a DoS from an apple device is like fighting a bear with a plastic spork

Don't like seeing ads? Click here to register!

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: iNinjas Python Objc
« Reply #10 on: September 05, 2012, 02:17:34 am »
Thanks i figured that was the problem, but if i cant checkout than how can i download the binary that needs to be signed
Code: [Select]
svn co https://ios-python-objc.googlecode.com/svn/trunk objc

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: iNinjas Python Objc
« Reply #11 on: September 08, 2012, 02:39:33 pm »
Your getting killed 9 because svn needs to be signed.

ldid -s /usr/bin/svn


Or wherever svn binary is installed.  I think its in /usr/bin.....too lazy too check right now lol.

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: iNinjas Python Objc
« Reply #12 on: September 08, 2012, 03:05:05 pm »
Yeah i figured it out thanks man.. Working nicely

equity7

  • Jr. Members
  • **
  • Posts: 50
  • Reputation: 3
Re: iNinjas Python Objc
« Reply #13 on: April 12, 2013, 01:18:53 pm »
+1 this will come in handy for sure. I will look into making some kind of interface system depending on where my project work takes me. This could be very handy to interface Python and Obj-C components together, like doing a bunch of core stuff in pure obj-c then doing config and other dynamic stuff in Python

LeoTh3o

  • Full Member
  • ***
  • Posts: 230
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: iNinjas Python Objc
« Reply #14 on: April 14, 2013, 06:01:44 am »
Your getting killed 9 because svn needs to be signed.

ldid -s /usr/bin/svn


Or wherever svn binary is installed.  I think its in /usr/bin.....too lazy too check right now lol.
ldid -S /usr/bin/svn    Use uppercase S or it doesn't work.
0xEB        0xFE
jmp short -2