Next Steps After Getting Started: Difference between revisions

From iPhone Development Wiki
m (→‎Integrating Your Tweak With Activator: It's the other way around)
(Add info and an example of %ctor)
Line 17: Line 17:


===What's %ctor good for?===
===What's %ctor good for?===
* explains what %ctor is and how to use it
%ctor is a logos directive which resolves to __atribute_((constructor)), which is a block that runs immediately when your dylib gets loaded.
* show some example situations where it might be useful
 
* show situations where %ctor is NOT a good idea
The syntax is similar to that of a function. An example is shown below:
 
<code>
%ctor {
    //This runs when your tweak gets loaded into the target process
    NSlog(@"My tweak has loaded!");
}
</code>
 
%ctor can be useful for performing any setup, for example, instantiating variables or reading your tweak's preferences.
 
However, there are certain things which %ctor is '''not''' good for. For example, a naive mistake might be to attempt to display a UIAlertView from your %ctor, which would most likely be impossible (depending on the process you're loading in to) as it has not even bootstrapped yet, so attempting to display UI elements at this point is futile.
 
It will probably minimize headache if you keep your %ctor use to just the bare minimum, and rather perform any extraneous setup at a different (most likely later) point.


===Dissecting App Store Apps===
===Dissecting App Store Apps===

Revision as of 16:56, 27 January 2015

Let's say you've figured out how to set up Theos, you know enough Objective-C to fool around, you know a little about how to use Cydia Substrate, and basically you've read all the beginner tutorials - what do you read next to learn more about jailbroken development as you experiment with building your own project? We should have a set of "next steps" tutorials for you!

These ones haven't been written yet, but it would be pretty cool for somebody to write them...maybe you? Anyone can start a page and begin writing some explanations, or you can just start filling out the sections below with more information. (Also, if you have an idea for a tutorial that you would like to see, feel free to add it to this list - it might inspire somebody to write an explanation of that thing you want to learn about.)

Using Development Tools

Changing System Volume with AVSystemController and Cycript

  • assumes the reader has basic Cycript and Objective-C knowledge
  • takes the reader on a journey through AVSystemController's methods using cycript
  • documents the thought process (ex. "-getVolume:(float*)arg1 forCategory:(id)arg2 indicates that there are different categories of volumes and they each have their own values")
  • ends with using the information learned to make a really simple command line utility

Dynamic Method Hooking With Cycript

  • assumes the reader has basic Cycript and Objective-C knowledge
  • showcases Cycript's ability to hook methods
  • hook some example methods to display benefits of dynamic hooking

What's %ctor good for?

%ctor is a logos directive which resolves to __atribute_((constructor)), which is a block that runs immediately when your dylib gets loaded.

The syntax is similar to that of a function. An example is shown below:

%ctor {

   //This runs when your tweak gets loaded into the target process
   NSlog(@"My tweak has loaded!");

}

%ctor can be useful for performing any setup, for example, instantiating variables or reading your tweak's preferences.

However, there are certain things which %ctor is not good for. For example, a naive mistake might be to attempt to display a UIAlertView from your %ctor, which would most likely be impossible (depending on the process you're loading in to) as it has not even bootstrapped yet, so attempting to display UI elements at this point is futile.

It will probably minimize headache if you keep your %ctor use to just the bare minimum, and rather perform any extraneous setup at a different (most likely later) point.

Dissecting App Store Apps

Integrating with Third Party Frameworks and Libraries

Building Tweak Settings with PreferenceLoader

  • goes through the process of building simple tweak preferences that are shown in Settings
  • shows the correct way to read/write to those settings in your tweak code
  • also shows how to use popular third party additions such as AppList / libcolorpicker / Activator

Your First Flipswitch

  • explains the idea behind the Flipswitch framework
  • goes through the different methods / objects you'll probably be using
  • shows how to build a simple flipswitch (ex. a simple flashlight toggle)

Integrating Your Tweak With Activator

  • goes through the Activator library
  • dos / don't of the Activator API
  • demo a simple Activator event (ex. got a notification from a specific app)
  • demo a simple Activator listener (ex. show an alert)