You are viewing our Forum Archives. To view or take place in current topics click here.
| Tutorial | Creating Your First Tweak | iOS Development |
Posted:

| Tutorial | Creating Your First Tweak | iOS Development |Posted:

LacertosusDeus
  • Christmas!
Status: Offline
Joined: Jan 19, 201311Year Member
Posts: 396
Reputation Power: 17
Status: Offline
Joined: Jan 19, 201311Year Member
Posts: 396
Reputation Power: 17



[ Register or Signin to view external links. ]
No Coding Experience Required!

This Tutorial Will Show You The Basics To Start Coding Your Own Tweaks!



[ Register or Signin to view external links. ]

A Good Text Editor
[I Recommend [ Register or Signin to view external links. ] ]

A Jailbroken Device
[duh]

Theos
[Tutorials in Links Section]

[ Register or Signin to view external links. ]
We Will Be Creating A Tweak That Simply Locks The Orientation Up. Useless I Know But A Good Simple Start.

In Case You Get Stuck, You Can Look At The Final Code Here: [ Register or Signin to view external links. ]

STEP ONE:
[Starting Your Tweak]
1. Create A New Tweak Instance:
Type the command "~/thoes/bin/nic.pl"

2. Select "New Tweak" by typing "5"
[ Register or Signin to view external links. ]

3. Next you will name and add other information, for this example follow the image:
IMAGE

4. You're done with theos for now



STEP TWO:
[Begin Coding]
1. Open the folder where you created your tweak
Default location for windows is "C:\cygwin64\home\%YOUR NAME%\norotate"

2. Now open the file "tweak.xm"
This is the file where ALMOST ALL of your code goes

3. Delete everything in the file, then type "%hook SBOrientationLockManager", type carefully
What Does This Do You Might Ask:
We are 'hooking' into a header, these headers are where all iOS code is kept. We have to hook into these headers so we can 'edit' their operations!

A little confusing i know.

4. Now go down a couple lines and type "-(BOOL)_effectivelyLocked"
We need to tell that operation to be yes, so here is what we are going to type:
-(BOOL)_effectivelyLocked {
   return YES;
}


What this does is tell the operation that the device's orientation is locked!


5. We have a couple more lines to type, so here are all rest of the 'methods we have to edit (it has been annotated so you know what the code does):
//Class I am hooking into
%hook SBOrientationLockManager
-(BOOL)_effectivelyLocked {
   return YES;
}

//Keeps the Orientation Lock flipswitch lit up
-(void)_updateLockStateWithOrientation:(long long)arg1 forceUpdateHID:(BOOL)arg2 changes:(/*^block*/id)arg3 {
   arg2 = NO;
}

//Overrides
-(BOOL)lockOverrideEnabled {
   return NO;
}

-(BOOL)isLocked {
   return YES;
}
%end

//Hooking Another Class
%hook SBUIActiveOrientationObserver

//Actually Locks Springboard Orientation
-(void)activeInterfaceOrientationWillChangeToOrientation:(long long)arg1 {
   arg1 = nil;
}


6. If you have any questions about what is happening, feel free to message me!

7. Check your code [ Register or Signin to view external links. ]



STEP THREE:
[The Makefile]
1. Open the file called 'Makefile' with Notepad++ (or your alternative)

2. Make some space at the top and add these lines:
a. This code will allow you to make your tweak for new and old devices
ARCHS = armv7 arm64


b. This code will make thoes use the iOS Files of choice, for us it will be iOS 8.1
(This does not restrict your tweak to iOS 8! Our tweak WILL work on iOS9 and possibly iOS7)
SDK = iPhoneOS8.1


c. This code is for installing our tweak over wifi
THEOS_DEVICE_IP = PUT YOUR iDEVICE'S IP HERE




STEP FOUR:
[Installing/Testing]
1. On your jailbroken iDevice, install "OpenSSH"

2. Back on your computer, in the command prompt type "cd ~/norotate"
[ Register or Signin to view external links. ]

3. Next Type "SDKVERSION=8.1 make", if you get errors, then look at the completed version

Heres what it looks like with no errors:
[ Register or Signin to view external links. ]


4. Finally, type "SDKVERSION=8.1 make package", if you want to install it to your device over wifi, continue to step, if not move that .deb file to your phone and install it!

[Installing Over Wifi]
This is quite faster than manually transferring

5. Download "WinSCP" if you're on windows or just open the terminal for mac, click the correct system to continue:

Windows:
1. Open WinSCP

2. In 'Host Name' type your iDevice's IP address

3. Leave 'Port Number' at "22", and change 'User name' to "root"

4. Change 'Password' to "alpine"

5. Click Login!

6. Open cygwin and type "SDKVERSION=8.1 make package install"

7. Type 'alpine' whenever it asks for your passcode

8. And now your brand new tweak is installed to your device, and you cannot rotate your springboard!


Mac:
1. Open the native terminal and type "ssh root@%YOUR DEVICE IP HERE"

2. When it asks for your password, type "alpine"

3. Now type "SDKVERSION=8.1 make package install"

4. And now your brand new tweak is installed to your device, and you cannot rotate your springboard!


[ Register or Signin to view external links. ]
*If you have any questions about this tutorial or about development at all, message me!

*Tutorials on how to prepair your computer for development are evrywhere, for the windows version, look into the Links section

*Want more examples? Go to [ Register or Signin to view external links. ] for more open source tweaks!

[ Register or Signin to view external links. ]
Notepad++ <> [ Register or Signin to view external links. ]

My Website <> [ Register or Signin to view external links. ]

Reddit <> [ Register or Signin to view external links. ]

Install Theos [Windows] <> Link

Iphone Dev Wiki <> [ Register or Signin to view external links. ]

iPhone Headers [For Making Tweaks] <> [ Register or Signin to view external links. ]
[ Register or Signin to view external links. ]

Just Me <> Link


Last edited by LacertosusDeus ; edited 5 times in total

The following 3 users thanked LacertosusDeus for this useful post:

DNT (11-27-2015), JoeyNap (11-24-2015), config (11-22-2015)
#2. Posted:
Mustardayonnaise
  • Christmas!
Status: Offline
Joined: May 04, 201212Year Member
Posts: 726
Reputation Power: 29
Status: Offline
Joined: May 04, 201212Year Member
Posts: 726
Reputation Power: 29
Thank you for this. I was actually talking to my friend at school and we planned on making a tweak. I'll check this out very soon
#3. Posted:
JoeyNap
  • Resident Elite
Status: Offline
Joined: Aug 13, 20158Year Member
Posts: 227
Reputation Power: 20
Status: Offline
Joined: Aug 13, 20158Year Member
Posts: 227
Reputation Power: 20
Great post, will be shocked if this does not get stickied, very well put together.

Thankyou
#4. Posted:
LacertosusDeus
  • Ladder Climber
Status: Offline
Joined: Jan 19, 201311Year Member
Posts: 396
Reputation Power: 17
Status: Offline
Joined: Jan 19, 201311Year Member
Posts: 396
Reputation Power: 17
Mustardayonnaise wrote Thank you for this. I was actually talking to my friend at school and we planned on making a tweak. I'll check this out very soon


No problem! If you go to my [ Register or Signin to view external links. ] I have several open source tweaks for you to look at if you need help!

Bompton wrote Great post, will be shocked if this does not get stickied, very well put together.

Thankyou


Thanks! I dont believe it will be stickied sadly.
#5. Posted:
Mustardayonnaise
  • 2 Million
Status: Offline
Joined: May 04, 201212Year Member
Posts: 726
Reputation Power: 29
Status: Offline
Joined: May 04, 201212Year Member
Posts: 726
Reputation Power: 29
Try posting this to [ Register or Signin to view external links. ]
Might get a sticky on there. People will also appreciate this more on that website as its more dedicated to iOS
#6. Posted:
IBM
  • Powerhouse
Status: Offline
Joined: May 27, 201212Year Member
Posts: 496
Reputation Power: 23
Status: Offline
Joined: May 27, 201212Year Member
Posts: 496
Reputation Power: 23
Mustardayonnaise wrote Try posting this to [ Register or Signin to view external links. ]
Might get a sticky on there. People will also appreciate this more on that website as its more dedicated to iOS
I like the people on iOSGods. It's fun to just sit around in their SB.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.