Samstag, 17. Januar 2015

What is NC2-app ?

Some of you may have noticed that i've been working on a secret project for a while. If you didn't, don't worry. I published only very very few information and told only a handful people about it.
This project is called NC2-app. That was kinda meant to be a codename for development, but at this point i'm no sure if i'll keep the name or change it later. So what is this NC2-app? NC2-app is basically a package manager or "store" how i like to call it. You can say it's a Cydia alternative.
So why is there a need for an alternative? I thinks most people see Cydia as a tool to install and remove packages. They open it up, install some stuff and close it. That's it. But Cydia is more, than just a package installer. It is responsible for a lot of background stuff, for example stashing applications, running daemons which do stuff and more. Usually jailbreaks just do their work at patching the kernel and disabling codesigning and some other stuff. From that point on Cydia does everything else. Of course Cydia depends on a lot of stuff like dpkg and bash and other packages, but when you open up Cydia and it runs, your system has everything setup so you can make use of the hacks.
Cydia is probably the only app, which runs on every single iOS release and idevice available!
(At the time of writing Cydia runs on iOS 2.0 - 8.1.2)
I think that's also the reason why it's kept quite simple. If you break it down at it's basics, it's a uiwrapper for libapt and a webbrowser.
The reason why i'm making an alternative is, because i see way more potential in such a store. There are many features i want to add and some things i simply want to change.  Cydia is open source, so in fact i could just take the code and directly work on it, but saurik is a special type of guy. I don't know him well, but from what i've heard and seen he likes to do things in his own ways. Which is not a bad thing, but it's quite hard (at least for me) to get into the code, understand it and change things the way i want them. I mean just cloning and compiling Cydia is quite challenging already. And i can see why many people who have ideas have problems to get into that or don't even have the time to figure that out.
If you take a look at Cydia's binary you'll see that it only contains an armv6 build. This is required, to keep the old phone supported.
I want to go a different way. Because there is so much i want to change i decided to write a package manager from scratch. Most of that is just ui anyway, because libapt does a pretty good job at maintaining the packages at system level. NC2-app will be compiled with the most recent Xcode version and contain an armv7, armv7s and an arm64 build so it's optimized for every device out there.
To get a better feeling and usage, i won't support anything under iOS 7.0 and iPhone 4. I think most people are on iPhone 4 or higher anyway so that's not really a downside. Also this allows me to use features, which Cydia can't use because of compatibility reasons. NC2-app (or short "NC2") is using things like Storyboard and autolayout and many other cool things.

What means NC and why is there a 2 ?
I started this project with a friend of mine and he came up with the codename. It basically means "NewCydia". This does not mean i'm planning to kick off Cydia from the scene (at least not now :P), in fact i'm planning to make it 100% compatible with existing repos and purchases. At some point in development repos will have the possibility to update and support the NC2 features, but at the same time they will be still compatible with good old Cydia.
The reason there is a 2 in the name is because that's my second attempt. NC-app (version 1), which is discontinued, has never been released, because i hit some barriers during development. For NC1 i didn't use libapt and tried to create everything myself. I wrote parsers and fetchers and grabbers and used dirty NSThread things to invoke shell commands, but at the end it ended up in a mess. It's a very organised mess, but still a mess. Everything was coded "wrong" and slow and when it came to actually installing the packages, i realized, that too many dirty workarounds would be needed to get that somehow working. Even though it was planned from the beginning to use libapt, i thought i could use a temporary way, which turned out as a big mistake. The reason i couldn't use libapt at that time is, that Cydia's libapt library is only compiled for armv6 and even though i got the headers, Xcode wouldn't link it, because armv6 build aren't supported (i think since Xcode 6) anymore.
In theory i could release a binary of that, since the source was 100% either coded by me or by people allowing me to use their code for whatever i need. But there isn't really that much to see. I also kinda don't want to release the code, because you'll probably would cut your eyes off after looking at the code xD
To be honest i never wanted to release the source for multiple reasons, but for NC2 i have no choice :/
Because i'm using libapt-pkg which is under GPLv2 i have to release the source, as soon as i start distributing the binary. In contrast to Cydia, which afaik was never distributed outside saurik's repo (i think mainly because it's not quite easy to compile), i'm afraid people might patch out things they don't like, but which are necessary (like ads). At the moment i have no idea how to prevent this, as i'm planning to keep the freedom jailbreaking gives us. I've heard about iMods, but i don't like the idea of insead of having freedom, changing apple's restrictions for iMods restrictions. I think my opinion on iMods could take up another whole blogpost, so i'll just skip this. For NC2 i'm planning to keep most of the environment as it is. Keep using mobilesubstrate from saurik's repo, keep using the default repos (including saurik's), keep Cydia/saurik doing the payment as long as i don't have my own. But even if i'll have my own payment server one day, which is not one of my priorities right now, i'm thinking of it as adding additional features instead of completely replacing and even if i get my payment server working good enough to be able to replace Cydia's, i'm planning to keep Cydia payments as alternative which you can always use.
So basically NC2 takes the ideas from the original NC-app and completely re-implements them. I also have a whole list of stuff i'm planning to add. NC2-app uses libapt for managing a lot of stuff and C++ and C for performance reasons.

Current progress
Right now i'm really really busy with school and other stuff. I really don't know why i started working on NC2 again. First i started to compile libapt-pkg and libapt-inst, because the versions Cydia uses are for armv6 so i can't link to them when i build for other archs. To compile these libraries took me several month, because i had no time, was lazy and had to fix a lot of stuff. Oh and i had no clue about C++ syntax, so i only fixed it in the end because of luck. I named the libraries libapt-pkg-nc and libapt-ins-nc so you can install both, mine and saurik's at the same time without conflicts, because i didn't make the effort to compile them for armv6 so they'd be compatible with Cydia. After having the libraries working it took me a while to find out, how to actually use them, because i had still no clue about C++ and there wasn't good documentation either, justs the code.
Right now i got working: get a package by knowing it's id and update lists.
At the moment i started working on the ui of the packagedetail viewcontroller (NCVCDetail) and today i implemented grabbing the price and purchase status for a package.
There is a lot of work and a lot of parser and fetcher need to be written, as well as some system stuff, but eventually with a lot of time i'll get it going :D

Since i have to opensource NC2, i hope people will help me working on this. There is a lot stuff, which needs to be done, not only code. I need a designer, who make the icons and the whole ui, i need the community to think about what button to place where and many more. The app itself is just kinda halfway planned, there are things i didn't even think about yet, but which need to be implemented. So please tell me what features you want, how you want it to look like. Send me a tweet to @tihmstar or write me a mail:
Tell me what features you want, give me some feedback or design some icons or views.
Bring in your ideas and help me to make a cool new store.
Please keep in mind, that at the time of writing this i have almost no time at all, so i'll put your suggestions on my todolist, but i won't provide you access to my repo right now or give you more information or sth.

If you have questions, feel free to ask (preferably on twitter)
It's 4am right now and i'm half asleep, so please excuse if there are grammar mistakes in the post or if i simply wrote some bullshit. I'm too lazy to recheck everything in detail