Published on

Creating Cydia Applications Through Xcode

Authors

If you've decided to venture into tweak development for your jailbroken iDevice, you've probably noticed that you can create an actual iOS application through NIC.pl. This instance template is used to create native iOS applications, but the tools provided are subpar, leaving you with no interface builder, no Swift support, no autocompletion, and loosely bounded files.

All of these problems can be solved by simply going through Xcode to create your project rather than using the files generated by NIC.pl. In this guide, I'll walk through creating your application in Xcode to installing the .deb file via SSH.

To start off, open Xcode and create a project as usual. I'm going to create a Single View Application, but all templates are supported. Any of the settings you decide to use when creating your project (including Swift development) is unrestricted as long as the iOS version you're developing for supports it, so don't be hesitant to experiment!

Once you've created your project and saved it to the designated location, you'll see your standard Xcode starter project including Storyboard files and your Assets.xcassets container! The benefits are becoming quite clear as to why you should use Xcode rather than the NIC.pl template.

I'm not going to walk you through how to build your application, but as a proof of concept I'll just add a label to the screen in Main.storyboard.


Now we need to tell Xcode to give us an .ipa file. But before we do that, let's ensure that our Deployment Target is set to a version equal to or below the devices you want to deploy to– otherwise the device won't be able to run the app.

To change the Deployment Target, find your project in the file window, select your target application, and change it from the latest iOS version to the desired Deployment target; in my case I'll change it to 8.0 so it'll support my device on 9.0.2 as well as a number of devices on 8.4 and 8.4.1.

Exporting .ipa File:

  1. In Xcode, do Product > Archive
  2. Window > Organizer
  3. Find your application and press "Export..."
  4. Select iOS App Store Deployment
  5. Deselect "Include app symbols for your application to receive symbolicated crash logs from Apple" as this isn't deployed through the App Store
  6. Deselect "Include bitcode" as your application won't know what device it's targeting through Cydia
  7. Press "Export"
  8. Finder will open with the .ipa file selected, go ahead and decompress this .ipa file using Archive Utility (or any other archive manager that supports .zip decompression)
  9. Copy the application within the Payload folder to a new folder on your Desktop, give this folder the name of your application
  10. Within this folder create two new folders: "DEBIAN" and "Applications"
  11. Move the application into the Applications folder
  12. Create a file named "control" in the DEBIAN folder

After completing these steps your folder structure should look something like:

└── MyApp
    ├── Applications
    ├── DEBIAN
    ├── MyApp.app
    └── control

Inside the control file I told you to make, you're going to want to include the following:

Package: com.zanehelton.myapp
Name: My App
Depends: mobilesubstrate
Version: 1.0.0
Architecture: iphoneos-arm
Description: This is a demo for building applications in Xcode and deploying through Cydia
Maintainer: Zane Helton
Author: Zane Helton
Section: Apps

Customize each line for your own use, this is the bare minimum for control files. A complete list of values can be found at: http://www.saurik.com/id/7

Now we need to convert this folder into a .deb file by doing the following:

  1. Open a terminal
  2. Ensure you have dpkg-deb installed
  3. cd into your the enclosing folder containing the Applications folder and DEBIAN folder, in my case it's the Desktop
  4. Run dpkg-deb -Zgzip -b [folder name] replacing [folder name] with the folder containing your Applications and DEBIAN folder

We now have a .deb file in the directory we ran the command in, this .deb file can be installed on your device by transferring it through any means (SFTP, AFC 2, etc.) and installing it by SSHing into your device, finding the .deb file and running

dpkg -i [filename].deb .

Potential Issues

  • Q: My icon isn't showing up on the home screen
    • A: Run the uicache command through SSH
  • Q: My application crashes on launch
    • A: Look at your system logs, it's probably still running from when you debugged through Xcode so either kill the old process or reboot your device