My new sounds:
Monterey Bay Aquarium

Love Begins

⁂
tumblr dot com
ojovivo
hello vonnie
Peter Solarz
h
Today's Document
Cosmic Funnies
almost home

tannertan36

No title available
Keni
taylor price

Discoholic 🪩
NASA

No title available
dirt enthusiast
Alisa U Zemlji Chuda

seen from Maldives

seen from United States
seen from United States
seen from United Kingdom
seen from United States

seen from Switzerland
seen from Türkiye

seen from United States
seen from United States
seen from United States
seen from United States

seen from Türkiye

seen from Türkiye

seen from United States
seen from United States
seen from Kuwait
seen from United States

seen from United States

seen from United States
seen from United States
@leonnears
My new sounds:
Learn how to create aggregate projects with Theos, while writing a configurable mobile substrate tweak.
ting Aggregate Projects with Theos. My newest tutorial.
Hello, I read your blog about writing cydia tweaks. I learned in college C and JAVA and I already read the "Beginning iOS 5 Development - Exploring the iOS SDK" book to learn Objective-C, I wanted to know if you think it's enough so I can start trying to use the knowledge I have to write apps/tweaks (and use open source apps and tweaks to learn more practical things) or is there anything else I should learn? Thanks!
As I have said in a few posts, tweak development is something you must be willing to do right since the beginning. As such, even if you have learned all these languages and have an idea of how the official SDK works, it's nothing if you have no practical experience with any of them.
While you know the "essentials" for iPhone development, you should really apply them before you use them on tweaks. Try to build an app using the official SDK first. It doesn't have to be an app you'll make available to people for them to download, but it has to be something you built from scratch and maybe something you will use. This is important if you want to do tweak development, because some mistakes are better done with the official SDK rather than on a jailbreak app due to the nature of tweaks. You have to be absolutely certain you can build iPhone apps before you try to extend iOS itself.
Finally to answer your question from a more practical point of view, actual things to learn... there is a few (optional) things you should read about. You can know all those languages but what about iOS itself?? iOS is built on top of FreeBSD and as such it has FreeBSD features. How does FreeBSD work behind the scenes? What is FreeBSD anyway? Answer those questions to yourself. My recommendation would be to be able to answer those questions before you try to write tweaks. It's not completely necessary, but it will come in handy. Bash also comes in really handy.
Writing SBSettings Toggles.
Heya guys.
I have written a new tutorial. This time for writing SBSettings Toggles for iOS.
It's located here:
http://www.andyibanez.com/2012/11/24/writing-sbsettings-toggles-a-tutorial/
Check it out!
Multithreading on iOS And Mac OS X Using NSOperations: A Friendly Tutorial.
I have published a new tutorial.
http://www.andyibanez.com/2012/10/12/multithreading-on-ios-and-mac-os-x-using-nsoperations-a-friendly-tutorial/
Feel free to check it out! This is an important topic that I don't know why it isn't covered my more people.
FREE PROMO CODE. Get A Promo Code For Combox Today!
I'm giving away 4 promo codes for Combox first. Combox is a Dropbox Client for iOS. Why another Dropbox client for iOS, when there's already an official one? Combox was thought for Dropbox lovers and power users, and it offers many features you will not find in other Dropbox clients. Combox is a wonderful little app for those Dropbox lovers out there.
To participate, simply Like my Facebook Page and share the post with the Combox promo poster. The promo poster is here, so simply share the Facebook post with this poster in your timeline and you will be participating to win a free promo code.
Key Value Coding, Key Value Observing, and Cocoa Bindings: A Basic Tutorial.
I just finished writing this new tutorial. KVC and KVO are really important so if you haven't grasped that yet now is your chance.
http://www.andyibanez.com/2012/09/13/key-value-coding-key-value-observing-and-cocoa-bindings-a-basic-tutorial/
Additionally, I have enabled a new E-Mail address that you can use to request tutorials. Naturally I won't be able to write about everything, but here you have a guy willing to write something for you to learn! Just send a mail to [email protected] specifying what kind of tutorial you would like to read.
Dear Tumblr Followers: I Can Write A Tutorial RIGHT Now.
I woke up really early and literally have nothing to do. If you want any iOS tutorials you can ask for a tutorial right now. If I get requests I will pick one and write it ASAP - by ASAP I mean I will start writing it right away and very likely publish it today as well, or at most tomorrow.
So if you want any iOS tutorials, right now is a perfect chance to ask.
I probably won't write a jailbreak tutorial because of iOS 6, but still, feel free to request anything you may like.
New Domain Name: andyibanez.com
Heya all.
Like you (may) know my domain name is http://www.leonnears.com. Most of my official stuff will be posted in http://www.andyibanez.com/ from now on.
Does this mean anything for you? Probably not. I will still use Tumblr to share my tutorials and the like. I love Tumblr. My Twitter is also staying the same.
You will still be able to access this Tumblr via http://blog.leonnears.com (I was going to change it to http://blog.andyibanez.com, but I fear I may break many links to my blog, so I'm keeping it). Only little change is that http://www.leonnears.com will redirect to http://www.andyibanez.com. Before, it was a dead link since I didn't have hosting, so at least it will work now.
I'm just posting this so you guys know that Leonnears is the same person as Andy Ibanez haha. Feel free to check the website out. It's neat!
So, I Released My First App To The App Store.
And I'm very, very excited about it.
Yes, it is a very, very simple tool, but it is perfect for programmers and computer science students. It's just a base converter BUT it can convert any base number, from base 2 to base 64. You can convert back and forth numbers from base 2 up to base 16 (sorry guys, you can't convert higher bases to lower bases because I have no idea of how I would cram so many little symbol buttons while keeping the app usable).
It's called SBConverter, and it's in the App Store:
SBConverter
It costs 0.99$. Like you may know, I am a college student. Currently, I want to save enough money to pay for my website hosting, and I want to pay for at least 2 years straight so I don't worry about it anymore (like you can tell, I currently only pay for the domain name), so if you guys could give me a hand collecting enough funds to do that, I will highly appreciate it! If I manage to get my website up and running, I will be able to put more cool information, and my portfolio (because I hate sitting around in college without making enough money on my own), I will be able to write even more nice tutorials for you (for those who appreciate everything I have written so far, of course).
So yeah, if you guys wanna help a fellow iOS Developer get more exposure, I will really appreciate it if you gave me a hand with this. Thanks! (:
hello. how can i replace a plist with mobilesubstrate?
MobileSubstrate itself cannot do that.
Also, I don't know what you are trying to do but superficially, it sounds really, really dangerous. You may want to look for another solution.
So you want to write Cydia tweaks for iOS? Read This.
Everybody wants to write something for iOS. Some will opt to write apps, others prefer to do open development writing tweaks, Siri enhancements, notification center widgets, and the like. Some of us can actually write both. It is undoubtedly that many people want to develop something for iOS, and they cannot be blamed. iOS is a wonderful mobile OS, it has many powerful features, and in the end, developers, whether they write "official apps" or tweaks, help make the platform better. So many tweaks have been so great, that Apple actually hired some people that wrote certain tweaks so they could officially extend the platform with them. Writing for iOS is something a lot of developers want to do, and many of them help make it better one of the best mobile OSes ever created.
All kinds of people have been attracted to the platform. Middle schoolers, high schoolers, college students, professionals who are not necessarily linked to the IT industry… Everyone seems to have a breathtaking idea of what to do for the platform. But here's the thing; many of them have no idea of what to do. Out of all the people who have great ideas, many of them just hire a development company to bring their ideas to life. Others are willing to take the whole thing in their own hands. In this article, I want to focus in the latter people, particularly in those who have decided to go the jailbreak way.
I don't want to discourage anyone from trying to bring their own ideas to life (although, it may look that way): In fact, it is the other way around. But the truth is that many people who attempt to write something for Cydia, have no idea of what to do. They don't know where to begin, they don't know how long it will take them or how long it should take them. In this article, I hope to clarify some doubts of that type that interested people may have.
The truth is that, ever since I started writing jailbreak tutorials, a lot of people have wanted to jump into the Tweaks bandwagon and have asked me questions. I don't mind if people ask me questions; I love helping people and I love teaching, that's why I write tutorials after all, but I always expect people who contact me to have a little bit of experience writing code for iOS (or at least a good amount of experience in any programming language). When I'm starting to help someone who sends me a tweet or comments on my blog, I always assume they will be able to understand my answer because they have enough technical knowledge to absorb it all and use it. But many times people who have never written any line of code in their lives ask me about Tweak development. This astonishes me, it really does, because you can't have no experience with programming and expect to have a working tweak from night to morning. Jumping to tweak development as your first project is NOT a good idea. There's many steps you have to go through before you try to do something like that. Of course, I don't mind if people ask me, "hey, I'm completely new to programming but I want to write tweaks for Cydia. Can you tell me where should I begin", I will happily give them pointers to start out, but just that, tips to start out. With the pointers I give to complete beginners they will not be able to, nor should they attempt to, write a full working piece of code in a very short time.
If you are a new programmer with limited experience, or if you are someone who has never written code in their life (note: CSS and HTML do not count as programming languages because there is no actual programming logic involved), then you need time. This is really, really important. You need a lot of time and dedication. I know, it sucks, you saw this guy writing a MobileSubstrate tutorial that is easy to follow and he creates a working example and you expected to make it work as the first code you write, but later you realise that you need to know many more things if you actually want to write tweaks; or, you are trying to run the examples, but you get errors you do not understand, so then you are disappointed you need to invest a lot of time learning many more things. I reiterate, even if your biggest dream is to get your tweak up and running on Cydia, you just cannot jump into it if you don't know programming - many things can and will go wrong.
Programming is not for everyone. It really is not. I see people who love programming, and I see people who hate it, but I never see people in the middle of these two extremes. How can you tell if you like programming or not? You may be asking yourself that important question right now. The answer is really simple: You try to learn it and do it. If you are not enjoying it, then stop right now and find the right vocation for yourself that will make you live happily for the rest of your time. If you like it, then congratulations! You may be in the right path to code your dreams into reality. But how do you learn, you say? This is actually a complicated question. There are many ways you can learn programming. You can go to classes, either in college or otherwise, you can buy books and go the self-taught path, or you can try something more dynamic like http://www.codecademy.com. Personally, I am self taught (and this tutorial will go around my experience), and I can definitely tell you that you can teach yourself programming by buying books and practicing on your own. Actually, I am a slow learner; to the day I have problems memorising my times tables, but I love programming so much, I was able to learn it on my own without having a teacher on my back saying what I should do or what I shouldn't! And trust me, if I could do it, then you certainly can do it too.
But nothing will come out good unless you are willing to do some sacrifices. Once on Quora.com, I saw someone asking how can a slow learner learn to program? and I wrote a lengthy answer, but that answer can be shortened into very few words: Get time, get interest, and get resources. First, you really need to invest a lot of time if you want to write code. You may have to sacrifice many things and hobbies if you really like it a lot; You will need to spend less time with your friends and more time with yourself. You will need to kill some time of your hobbies (in my case, anime and video games) to make more time room for your programming. If you think "5 minutes for programming a day" is enough to become "good" at it, then you don't have the right mentality. You must be willing to spend hours learning programming a day, and actually programming when you get the hang of it. You must also have enough self-discipline to read books without getting distracted (if you are going the self taught way, of course), and you must be prepared to read technical books and resources, lots of them (it was hard for me, because I am a fantasy lover, but now I can read all kinds of books with no problems so learning to program paid off for more things than just programming). You will not reach your final goal of writing tweaks or apps people will use if you don't make time for a decent of programming in your schedule a day. How you get your books is not a concern of mine, but most of the time you will need money to buy them, too (I will tell you about the books I used to learn later, first come the words of encouragement!)… If you are focused on your goal, some sacrifices are due.
Second, you need to love it. Like I said earlier, if you can't sit still writing and reading then programming is not for you. If you don't have enough interest in programming, then find something else you love doing. Programming, like many other vocations and even hobbies, is something you have to love in order to do it right. Even if you are "good" at programming "naturally", if you are not enjoying it you will be as bad as someone who doesn't know what HTML is. You have to find programming interesting. The good news is, even if you think it's boring, you can find an use for it! Maybe you are a musician right now who wants to write a guitar app or a SpringBoard Tuner tweak, but you don't think you find programming interesting enough. Programming can solve many needs. Programmers are usually multi-talented people (I'm not saying we are the wisest of men, but rather we do have knowledge in lots of things because we solve all sorts of problems via code). When we write code, we enhance our knowledge for things. A programmer can be asked to write a running algorithm and in the way he will learn about music; the musician wanting to learn programming will be able to learn programming not only for app or tweak, but to solve other problems that will arise in the future for him or her as well. If you think programming is not for you, think on the kind of problems you could solve when doing your other hobbies or works: It will certainly pay off very well!
Finally, get resources. You may be a Computer Science student who goes to programming classes. But why limit yourself to that when you can learn a lot more beyond the scope of your classes? Try to get your hands in books of programming topics that interest you, or at least browse the web for articles and tutorials. The internet actually has many nice tutorials and articles for any programming-related topic you may think of. If you are self taught, you should definitely go to your local library and browse the sections where programming books can be found. Maybe a nifty title will grab your attention and you may want to buy it. Libraries are beautiful places to look for resources. Where I live, we don't have many libraries, but when I go the USA, I can spend hours and hours browsing the books in Barnes & Noble until I find something I like or reading the first chapter of a book that calls my attention. You should definitely do this too. It sounds boring, specially if you are a school teacher. But if you are really into programming and you find it fascinating, it should be as easy as pie as to browse books just like that. You learn a lot that way, even by just looking at book titles.
Are you still with me? If you are still reading this, I assume you recognise that you won't write the next breathtaking tweak in one night, and that you are willing to spend a lot of time learning your way to success. If you are discouraged, I'm sorry, you may want to stop reading this now. But if you are with me, willing to invest time and do the needed sacrifices, then keep reading, this is where things get a little better.
Alright, so now you may actually want me to give you some resources, and tell you about how I got here. You see, like I said before, I am entirely self taught. I have taken programming classes in college because they were a requirement, but honestly I learned very little stuff that can be applied to my daily routine. The first code I was exposed to in my life was HTML. I learned HTML, CSS, and JavaScript. Then I wanted something more challenging, and wanted to learn PHP and C++. PHP is completely unrelated right now so I will tell you about my experience with C++. First I went to a website called http://www.cplusplus.net (great site, by the way) to look for my first C++ tutorials. Honestly, at first I tried to follow the tutorial, but I had no idea of what I was doing, nor did I understand what was going on, despite the fact that I read the same tutorials many, many times. My head could not absorb those concepts at all, so I was discouraged and I just said "meh, I will wait till college teaches me all this". This was when I was 14. We went to the USA for vacation that year, and we walked into a Barnes & Noble store and I was fascinated by all the books I could see. I saw a C++ book that called my attention, in January like 3 days after new years. The book was called "C++ Without Fear". The monster in the cover made me think that programming maybe is easier to understand than what I think, and I thought the monster in the cover made the book look like it was easy to understand. So I brushed off some 50$ and bought that book. It was the first programming book I had ever purchased. When we returned home with my family from the US, I started reading the book.
And boy was I impressed! Things started to make sense, with the way that book explained things. I ate this book in a few books and I was much better at C++ (nowhere near an expert, and I still didn't know half of the language, but it gave me the first foundations to study C++ a bit more). "C++ Without Fear" is a book I recommend to anyone who wants to learn programming. It may look ridiculous, it may look easy, but it does a very great job teaching the noob programmer how to do things right. The book is of course, incomplete; C++ is a huge language that is really hard to cover completely from top to bottom. I was also using a Windows Machine back then. The CD that comes with the book has Windows software and it can't be used in a Mac. Regardless, I recommend this book to anyone who wants to learn programming because of its way of explaining things. C++ is a language, so the language itself, you can learn it on any machine running any OS. If you want to get this book, you can follow the examples by using Xcode on your Mac, without tinkering with the examples to make them work in OS X.
As a complementary book for C++, you can buy, and I recommend "Professional C++" by Solter and Kepler. This book, like its name may imply, focus on C++ at a much complex level, because it doesn't teach you the basics anymore. It teaches you other languages features like templates and the such.
Why C++ when there are only Objetive-C and C frameworks in Cocoa/Cocoa Touch, you say? C++ is really powerful. C++ is not a hard language, but it certainly is one of the most complex languages out there. If you can pick C++ up with most of its features, learning other languages may be a bit easier. Also, a big advantage of C++ over C is that C++ offers the Object-Oriented programming paradigm; Objective-C is entirely an Object-Oriented language, so if you pick C++'s object oriented features, with a solid grasp of Object Oriented Programming (OOP), then you will have an easier time picking up Objective-C.
A book I have checked out that looks great is called "Learning C On The Mac". This may, or may not be, a better book to learn programming on your Mac, It teaches you C and it explains things nicely, so if you want to pick C over C++ before going to Objective-C this book is not bad all. Only bad thing is that C itself has no OO capabilities so depending on the person, picking up Objective-C may be a tiny little bit harder to pick than someone who already picked it up with C++.
Once you learn C or C++, you have to learn Objective-C. Objective-C is (like you may have been able to deduce) the main language used to create Mac and iOS applications. The de-facto book to learn Objective-C is Stephen Kochan's "Programming In Objective-C 2.0". This is the only Objective-C book I have ever read. It's so complete I don't think you need to learn anything else.
Then you have to learn Cocoa Touch, the framework for iOS apps. There's many books for this topic that I have read and all of them contributed to what I know about iOS development. The Big Nerd Ranch's book iPhone Programming is a great book for iOS programming, praised by many people, and one of the most complete and well explained iOS books out there. Apress has published many iOS books. The ones I have read that I think are good are "Beginning iPhone Development: Exploring the iPhone SDK", which teaches a little bit of Objective-C at first but later is fully iPhone-Oriented. I have read this book for iOS 4 and iOS 5 and it's really neat. As additional books, Erica Sadun's "The iOS Developers Cookbook" is a must have. Erica is a recognised developer and her books are neat, not to mention she hosts her examples on her Github so you can tinker with them.
Now, why all the official development books even though this article is focused on tweaks, you say? Because it will be really hard to write your tweaks without knowing any of these material! If you want to write a tweak that shows an alert view, you will need to know how to create the alert view. The Cocoa frameworks, which you will learn about them with those "learning iOS dev" books I showed you above is essential for you to do anything. Yes, you can mix C and C++ code, even manipulate C++ and C strings if you prefer to over Objective-C, but the Foundation's framework NSString can make your life easier. Also all the UI elements for iPhone are written using Objective-C frameworks, so you must understand all the material in those earlier books.
An additional book, but a book I have skimmed over a few times and looks really good, is "Hacking and Securing iOS Applications" by Jonathan Zdziarski. This book is important for both tweak developers and official developers, because this book shows exploits, how to find security holes, and how to abuse them. It looks like a wonderful every iOS developer should read, and it can benefit everyone equally.
A final resource will always be Apple's Developers website (developer.apple.com). You must learn to use this reference for the official frameworks.
Now to talk a bit more about Cydia tweaks and jailbreak apps, this is really a vast topic. Private frameworks change a lot in each iOS release. All the knowledge you will get up to this point will help you more doing tweaks. For iOS tweaks, you will browse private headers a lot. You will need to learn to get your hands in these private framework headers (some people share them, others dump their own). Dumping them on your own is not hard, but it takes a while to fix the headers yourself (because they are not always compile-ready). Then you will learn to "hook code" and a basic knowledge on the Objective-C's runtime (which is something every developer should learn, not only jailbreak people) so you have a basic understanding of code hooking and how C really works with your C++ code. There are not many books dedicated to iPhone development (Jonathan Zdziarski has written one, but it hasn't been updated since 2008 and it still focuses on iOS 2.0; iOS 6 is just around the corner now). Your patience will be tested, trust me. You will experiment a lot with code to learn what is it that you should hook and what you should leave alone. You may need to restore your device more than once in some cases. Open development can be really tough if you don't know what you are doing; you can damage your device if you are not careful. This is why Tweaking shouldn't be the first thing you try to do if you are new programming altogether. You will learn a lot of iPhone headers, and you will get used to research because like I said, the private frameworks change a lot in each iOS release, so your iOS 5 tweak that works wonderfully, that took you months to develop, may break on iOS 6 and you will need to find the alternative way to hook your code.
Okay, okay, woah, woah! You probably want me to stop for a little while here. I think I can hear you asking "How long is all this going to take?". This is a very, very complicated question. Despite the fact that I have been programming for 6 years, the first thing I ever released to the public was just a few months ago. Prior to that, I spent the previous years getting programming skills for other languages and technologies. When I learned to program, the iPhone wasn't out yet, and I actually didn't like Apple. My knowledge was limited to web technologies, C++, and C# along with Microsoft's technologies. I must have studied C# and Windows Development for at least a year. But I never did anything with that knowledge.
So while in my case it may have taken me 6 years to get something out, in your case it may take you more or less. It really depends on how much time and effort you put into it. But even then, then expect to have a tweak out and working in just a few months. To really understand C, you will have to do it for a pretty long time. You will end up writing lots of console/terminal programs just to learn more. If you eat absolutely all the books I mentioned (recommended), then you may be attempting to write tweak in like 9 months or so. Just learning C, you will be a few months. An extra month or so for Objective-C, and yet more time with Cocoa Touch. When you get to actual tweak development you will be exploring and researching a lot on your own or asking question in Saurik's IRC because there isn't much content written about iOS development.
A very important word of advice is due here: DON'T THINK ON THE TIME. Just learn programming and ENJOY YOURSELF. If you don't, like I said, it will be evident that programming is not for you. If you focus on learning and on enjoying it, you will see that, while your tweak will still be your main goal, you will develop more programming related-goals, hopes, and dreams. You will think on other projects you want to work on, and you will get a great satisfaction of learning things.
If you have read all this and are willing to go through everything, remember to ASK QUESTIONS. On StackOverflow, on IRC channels, anywhere. Like I said, I love helping people answering their questions as long as they are interested, so send me a tweet or something if you want my help with something. I'm not an expert, there's many things I don't know, but part of the reason I love teaching is because I end up learning a lot. Some questions people have asked me, drove me to do some research and learn more, getting more benefit. Don't have doubts, ever.
After all, the glory you get of releasing something to the public that people like and talk about can never be replaced by anything else. You think your tweak is not worth it? Submit it anyway: When I submitted my first tweak to ModMyi's repo on Cydia (called SiLight, which is just a simple Siri extension that allows you to turn on your flashlight with your voice), I firstly thought no one was going to be interested on it, and that only 10 people or so would download it. You have no idea of how wrong I was: In it's first hour, it received 70 downloads, and by the end of the day, it had 700 downloads. A tweak I thought no one was going to care was getting downloaded. The next day, I decided to Google "SiLight Siri", and I was received by a beautiful surprise: Many blogs in many different languages were talking about that crazy flashlight you could toggle with Siri. It received a lot of praise for being "An extension that goes beyond the software and toggles the hardware", and it received a lot of exposure. On it's first week it received around 5000 downloads, and at the time of this writing, it has over 13000. So yes, like you can see, the effort you will put into will pay off. Even if you think your tweak is going to be ignored by everyone, you may get a very pleasant surprise when you see people downloading it, thanking you for it, using it, and talking about it. So go on! If you have spent 20 minutes of your life reading all this, I'm sure you want to have some little glory for yourself. We all do. Just remember to work hard, and don't expect things to work out the easy way.
--
The Blogger entry where you can comment and ask questions is here.
SiLight 1.1.0 To Be Released Soon.
Hi guys.
To those who downloaded my SiLight tweak off Cydia, version 1.1.0 should be on ModMyi's repo soon.
A few people and blogs have reported that it's hard to turn off the lights, some even said that the functionality wasn't there haha. Yes, the functionality is there, but I did a mistake and didn't make the "Turn off" commands intuitive enough. This is now fixed. Not to mention, some commands are affected by an apparent bug in MobileSubstrate that causes Siri to think for a long time without toggling the light. Unfortunately, I can't tackle that right now and we will have to wait until an AE update goes live.
As a workaround for this, I have added more commands.
Another mistake I made was to not list the commands that could be used. That's because I want to make this tweak as intuitive and "human" as possible. But for those still having problems turning the lights on and off, here is a list of commands you can use:
To turn on the lights:
"There's a blackout"
"Turn on the light"
"It's dark in here"
"I need a flashlight"
"Switch on the light"
Any variation similar to the commands above should be able to turn the torch on.
To turn off the lights:
"Thanks for the light"
"Thank you for the light"
"Shut off the light"
"Shut down the light"
"Lights off"
"Light off"
"Flashlight off"
Just like the commands to turn the lights on, variations are possible and anything that comes naturally out of the user's work with the intention of toggling the lights should work: If not, please send me an e-mail like you have been doing all along and I will tackle the problems ASAP!
Changelog:
% Fixed a small logic error. If the user said any command to turn on the lights in a device without a torch, Siri would say "Will this help?" and immediately say that she can't help. + Added more commands to turn the lights on and off and to make the tweak more natural to human talk.
Changelog Legend:
% = Bug fix. + = New feature. - = Removed feature.
As a final note, I want to apologize who everyone who had to restart, restore, or use other toggles to turn the lights off. I didn't see the toggle thinking for forever with most shutdown commands. Fortunately, this is an issue I addressed by adding more commands you can use to turn the lights off.
How To Create A MobileSubstrate Tweaks for iOS.
Welcome to my second tutorial on iOS Open Development! In this tutorial, I will give you the first hand to get started with MobileSubstrate tweaks. If you are here, you should already know what MobileSubstrate is and why you would want to write tweaks for it, so I'm not going to get into too many details about MobileSubstrate and how it works.
Before we get started, there's a couple of things I want to say first. First, if you don't know what you are doing (new programmer, first time writing for iOS, whatever), then this is NOT a tutorial for you. MobileSubstrate protects the system from tweak errors and lousy programmers, but one can never be too careful. If you don't know what you are doing, you could mess up your device, perhaps not bad enough to brick it, but bad enough to require a full restore. So if you follow this tutorial, I trust you know programming, have been doing it for a while, and that you take full responsibility of whatever happens to your device for writing "bad" tweaks.
Second, writing MobileSubstrate tweaks... There's a lot you can do. It's all about code hooking thanks to Objective-C's dynamic nature and there's a lot you can do with it. I cannot possibly teach you, not even in a thousand posts, everything you can modify with MobileSubstrate tweaks. This small tutorial is just meant to give you a hand getting started with tweaks. It's not a comprehensive guide. It would really be impossible to write a full book about everything you could hook because there's too much. Once you are finished with this guide, you will know enough about widgets and you will be able to research on your own: That is, once you are done with this tutorial, you will have to explore the private headers to find what you are looking for and hook it. Writing MobileSubstrate tweaks requires patience and familiarization with the private frameworks, so once you build your first project, start studying the private frameworks: I will tell you how to dump your own headers or where you can find headers that have already been dumped and modified for you to use.
Now, putting that aside...
In this tutorial you are going to write your first MobileSubstrate tweak. We will build a simple tweak that will show the user a message whenever he/she tries to open an app. Once the user taps an icon, we will display a message that says "Launching App..." and then we will launch the app once the user taps an "OK" button. Yes, it is a useless tweak, but you will learn a lot in your way.
In this tutorial, I will do the following:
I will explain you how to get the required headers to create tweaks.
I will explain what "hooking" code is in a nutshell
I will teach you how to hook code using Logos instead of the Objective-C runtime, so you will learn the basic Logos syntax along the way and you will be ready to hook your own things any time.
You will learn three very basic things but they should be powerful enough for you to write any tweak you can think of.
Okay, let's get started!
First Things First: You Need The Private Headers To Work With.
You need to get the private iOS headers you want to "hook". Otherwise, well, there's nothing you can play with. So I will show you ways to do that.
The first and hardest method is to dump your own headers yourself using a command line tool called class-dump-z (or class-dump: refer to this post for more details on the tools). How to use this tools is beyond the scope of this tutorial but a word on them is due. Dumping your own headers is a tedious option. There's a bunch of private frameworks and it can take a while to dump them all. Save each header to a respective framework directory when done.
Another (and easier) option is to download the headers from someone else. A lot of people have dumped their own headers and are hosting them free of charge on GitHub, so go on there and grab a copy. Personally, I recommend you use rpetrich's headers, simply because he is a great developer with great reputation in the iOS open development community. But there's lots of options out there shall you want/need them.
Once you have your headers downloaded, each header nicely inside a folder with the name of the framework, move or copy each framework to the directory called "include" inside the Theos directory. By default, you would save all the headers in the following location (Mac):
/opt/theos/include
Every private framework you download has to be saved there (so you can simple #import them when you want to use them, as you would include any other iOS framework in "official", non-jailbreak projects).
That is all there is to downloading your headers: Once you are done, you can move on.
But Wait, What Exactly Is "Hooking"?
Objective-C is just a superset of C. Everyone who knows iOS or Mac programming knows that, and it's the first thing a good book or tutorial on Objective-C tells you. But what exactly does this mean? It simply means that Objective-C has a lot of C code running under the hood. As so, you can freely mix any C code with Objective-C code.
Objective-C is mainly driven by what is called the Objective-C Runtime. The Objective-C Runtime is a C framework that, as you may imagine, controls everything that happens on Ojective-C under the hood. This runtime is responsible of creating classes, creating methods, ivars... Everything Objective-C does, is controlled by this run time. This runtime is in its most superficial level a bunch of C functions, and this framework is the reason Objective-C is such a dynamic language. This runtime can create classes, methods, ivars, and modify any of them along way on runtime rather than on compile time. Here are some functions provided by this framework:
class_addIvar
class_addMethod
objc_msgSend
This are just some functions found in the runtime. Their purpose is really clear: The first one adds an ivar to an existing class. The second one adds a method to an existing class, and the third one sends a message to a class.
Programmers can have full access to the Objective-C Runtime functions by just importing the framework as they would import anything else, granting them access to very powerful tools to modify running code as they wish on runtime and have a lot of control of whatever happens in their machine. In a running application, a developer can "hook" to a current method and make it behave like something completely to what was intended. In other words, to "hook" means to modify or extends the Objective-C code to do what you want. For example, someone could "hook" the NSString's stringByAppendingString to append the passed parameter and to append a personal string at the end. Suppose I wanted that method to append "Leo" at the end of very string that receives that message. I could hook that method to append the wanted string and my own personal string at the end.
The Objective-C Runtime takes care of hooking. Writing tweaks require hooking, but the iOS Open development community has developed methods to abstract the Objective-C Runtime functions from the programmer. "Hooking" mechanisms have been created precisely to abstract the runtime and perhaps make it less intimidating. CaptainHook is one of them, and Logos is another one. Logos is a very nice hooking mechanism and it abstracts the runtime nicely with simple commands like "%hook" and "%orig". No idea what I am talking about? In this tutorial I will show you how to create a tweak with Logos, so you will understand more once you see the actual tweak.
Without further ado, time to build the actual tweak and get your hands dirty. This is actually the shorter part of this tutorial but I hope everything I taught you so far will be useful for you in the future.
Getting Our Hands Dirty: Creating The Tweak
Alright, launch up the terminal and create a MobileSubstrate project (If this is your first time using Theos, or you don't even have Theos installed yet, refer to this post. I mainly give links to instructions for installing Theos but the small content I dedicate to installation and configuring should help you getting started with it). I will call mine LaunchNotifier:
Once you have your project created, you will see a file called "Tweak.xm". This is the file that has all the Logos hooking code and where you write your tweak. So open it up and be surprised for a short while at all that "%" syntax...
You also need to modify the makefile to add the UIKit framework. If you are in this tutorial you should know how to do that, but if you don't, it's very simply, just add this line:
LaunchNotifier_FRAMEWORKS = UIKit
And save it. That's everything we need to do so close it now.
You will see a bunch of commented-out content. Please look at it for a while and try to understand it. It shows you the very basics of code hooking like:
%hook ClassName and %end. This is what I call a "Hook Block". Everything you write in between is the block where you will be hooking things of the className (note that %hook and %end have no finishing semi-colon in their lines).
%orig calls the original version of the code you are hooking. You will find yourself calling %orig in all your methods most of the time, as they have most of the code needed for the code to be finished. Not calling %orig; can have disastrous consequences in your tweak, depending on what you are doing, although sometimes it's desirable to avoid calling the original version of the method. Make sure you know when you want to call orig and when you don't. Usually, it's just common sense.
%orig(...) is %orig; but with arguments. In the parenthesis you pass in all the parameters to hand them over to the original method.
The rest of the commented code are examples for Logos. They can work, but in this tutorial I want to build something that works, because it's easier to learn things with "real-world" examples.
Feel free to delete everything on that file for now. We will build everything from scratch (and it's nothing too big, since it's just a UIAlertView basically).
First things first, a quick review of what we are doing to do: When the user taps an icon in the SpringBoard, he will see a message telling him he's about to launch an app.
Okay, so how do we do that? I need to say again, Tweak development requires lots of header browsing. You can never be certain of where things are. You know you want to a show message when an icon is tapped. You know icons are part of SpringBoard, so that's a good start. You would head over to the SpringBoard framework folder and browse all the headers there. What are you looking for? Common sense is to be used here: You know, it's an icon, so just look for anything that may have "Icon" on it's name. What should you hook? You browse your headers for a while and find a class called SBIcon. Is this the one? Could be. Under normal circumstances, you would try to hook different classes and methods, writing code for them to do something (show an UIAlertView is a good idea), to see if you are hooking the right class and method. Okay, nothing interesting here. This can't be the method. Oh, oh, what do I See? Is that a class called SBApplicationIcon? That sounds less generic and it may be exactly what you are looking for! In our case, yes, we want to hook that class.
You inspect that class and you see it has a method called -launch. Instinctively, we know this method will launch the respective app, so it makes sense to hook it.
The initial hooking will simply look like this:
%hook SBApplicationIcon //Methods to hook here. %end
Here we are just saying "I will hook some methods from the SBApplicationIcon class".
-launch is the method that holds the magic for us, so to hook it, just write it's implementation inside the hook block like you would anywhere else:
%hook SBApplicationIcon -(void)launch { //Hooked launch. What will it do now? } %end
And there you can just write any Objective-C code you want. We want to show a message, so just write a UIAlertView like this:
%hook SBApplicationIcon -(void)launch { NSString *appName = [self displayName]; NSString *message = [NSString stringWithFormat:@"The app %@ has been launched", appName, nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:appName message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; %orig; } %end
And that's really it! make package install your project (you should now that by now). Once the user taps an icon, the app will launch while showing a message:
A couple of things you have to note about the code we wrote above:
We are calling %orig;. If you don't call %orig; here, your app won't launch because you will override all the launch logic. Instead, you will just see your message but nothing will be launched. If a normal user installed this app (without the method calling %orig;), he/she would be screwed. Why? Because he/she wouldn't be able to launch Cydia and uninstall it. The developer, on the other hand, can reverse the problem by simply fixing the problem and make package installing it again. This is why tweak programming is not for everyone and you should only do it if you plan on doing it well.
Note that we can call [self displayName]. Like I said, you can write any code like you normally code as you usually would, except you can "call hooks" whenever you want or need them.
Congratulations! You have now written your first MobileSubstrate tweak. As usual, the full code can be found on my pastebin here, and if you have any questions, head over this post and ask all the questions you may have.
Have Questions or Problems With My Tutorials But Can't Ask Me? You Can Now.
A while ago when I wrote my first tutorial on Blogger, I wrote at the end of it that if anyone had problems or questions, they could just ask in the "Comments Section" of the post.
Well, a few weeks ago I got a Question (As in, a Question you can ask on tumblr, not a question on a comment) from the user Slapwall who pointed out that the comments don't work. I went ahead and fixed that ASAP as soon as he pointed it out, but I just don't understand how Tumblr's comments system works exactly and it looks like the comments are not enabled yet.
As a consequence of this, I have revived my very old Blogger account. From now on, I will use that Blog to post the links to my new tutorials on Tumblr. You can ask questions in my Blogger account in the comment section of each blog post since Blogger's comments work perfectly fine. Now you may be asking, why not just use Blogger instead of this "cross-use" of Tumblr and Blogger? The answer is that I love Tumblr because of it's features, it's more social, and I get more exposure with it. Only downside with Tumblr is it's comments system (is there even one, now that I think about it?), but a great fix, at least temporarily, will be to let people ask questions in the Blogger posts.
In other words: That Blogger account will simply have links to my tutorials here and you can ask questions there. The actual content will still be hosted on my Tumblr and I will continue using Tumblr as I normally would.
The Blogger blog is located here:
http://blogger.leonnears.com
The comments doesn't work
Thank you for pointing that out... I will fix it ASAP.
What Tutorials Do YOU Want?
I haven't been able to use Tumblr so much lately because I have been busy with college (And Tales of Graces F, but hey). I want to write new tutorials for iOS but, I can't think of anything right now.
So if you guys want a tutorial for iOS, doesn't matter if it is a jailbreak tutorial or an official tutorial, let me know! If I get ideas for tutorials I may write them on a request basis when I can't think of anything at any given time.
So shoot your ideas away! Either comment on this post (comments should be enabled now), send a Tumblr question with your tutorial request, or mention me on a Tweet (@Leonnears) with your idea. I know my way around iOS, and even if there's something I don't know, I will learn it because well, I love learning. So fire 'em ideas!