Updates from December, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 5:00 pm on December 30, 2012 Permalink | Reply
    Tags:   

    Categories: iOS ( 222 )   

    How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track) 

    Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

    This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

    • cd into the directory where your project resides
    • then initialize an empty repository (git init)
    • and add the entire directory to it (git add .)
    • commit your changes (git commit -m “initial commit)

    So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

    To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

    • cd into the directory where you project resides
    • create a file called .gitignore
    • add each file or directory on a new line
    • then create, add and commit your files to Git

    Let’s assume my project is called MyProject, then the steps are as follows:

    cd MyProject
    vi .gitignore
    
    (add the following lines to that file)
    # ignore these files
    .DS_Store
    MyProject.xcodeproj/project.xcworkspace/xcuserdata/myusername.xcuserdatad/UserInterfaceState.xcuserstate
    (save and exit vi by pressing SHIFT-Z-Z)
    
    git init
    git add .
    git commit -m "initial commit, omitting several files"
    

    If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

    git rm --cached .DS_Store
    git rm --cached # ignore these files
    .DS_Store
    MyProject.xcodeproj/project.xcworkspace/xcuserdata/myusername.xcuserdatad/UserInterfaceState.xcuserstate
    git commit -m "removing files I no longer want"
    

    Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.





     
    • Jay Versluis 1:58 pm on March 4, 2013 Permalink | Reply

      I’ve just forked a superb general .gitignore for all Xcode projects, courtesy of @adamgit.

      – Copy and paste into an empty .gitignore
      – then initialize, add all and commit

      get .gitignore here

    • Arik Segal 5:13 am on September 10, 2015 Permalink | Reply

      Well done! this is a very useful post.
      One question though:
      Isn’t the derived data folder stored separately in ~/Library/Developer/Xcode/ ?
      If so, it would not be included in GIT commits anyway, so why adding it to .gitignore?

      • Jay Versluis 8:44 am on September 10, 2015 Permalink | Reply

        Hi Arik, I must pass I’m afraid – perhaps this is a question for @adamgit whom I’ve forked the gist from. I was mainly concerned with the interface state since it’s system dependant: if were to I checkout my project on a different system, the interface state doesn’t necessarily look great with another screen resolution. The gist helped prevent confusing Xcode on another system.

        Mind you, that was 2 years ago – perhaps Apple have started fixing things by now (we live in hope) 🙂

  • Jay Versluis 11:00 am on December 30, 2012 Permalink | Reply
    Tags:   

    Categories: iOS ( 222 )   

    How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track) 

    Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

    This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

    • cd into the directory where your project resides
    • then initialize an empty repository (git init)
    • and add the entire directory to it (git add .)
    • commit your changes (git commit -m “initial commit)

    So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

    To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

    • cd into the directory where you project resides
    • create a file called .gitignore
    • add each file or directory on a new line
    • then create, add and commit your files to Git

    Let’s assume my project is called MyProject, then the steps are as follows:

    cd MyProject
    vi .gitignore
    
    (add the following lines to that file)
    # ignore these files
    .DS_Store
    MyProject.xcodeproj/project.xcworkspace/xcuserdata/myusername.xcuserdatad/UserInterfaceState.xcuserstate
    (save and exit vi by pressing SHIFT-Z-Z)
    
    git init
    git add .
    git commit -m "initial commit, omitting several files"
    

    If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

    git rm --cached .DS_Store
    git rm --cached # ignore these files
    .DS_Store
    MyProject.xcodeproj/project.xcworkspace/xcuserdata/myusername.xcuserdatad/UserInterfaceState.xcuserstate
    git commit -m "removing files I no longer want"
    

    Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.





     
  • Jay Versluis 11:48 pm on December 27, 2012 Permalink | Reply
    Tags: ,   

    Categories: iOS ( 222 )   

    How to disable cell interaciton in UITableView 

    If you don’t want your cell to be highlighted you can de-select the option “User Interaction Enabled” in the storyboard. This is ticked by default. Untick it and nobody can select your cell anymore.

    UserInteraction





     
  • Jay Versluis 5:48 pm on December 27, 2012 Permalink | Reply
    Tags: ,   

    Categories: iOS ( 222 )   

    How to disable cell interaciton in UITableView 

    If you don’t want your cell to be highlighted you can de-select the option “User Interaction Enabled” in the storyboard. This is ticked by default. Untick it and nobody can select your cell anymore.

    UserInteraction





     
  • Jay Versluis 4:44 pm on December 27, 2012 Permalink | Reply
    Tags: cell, ,   

    Categories: iOS ( 222 )   

    How to create a transparent cell in a UITableView 

    First we make the cell’s background transparent. Next we create a custom view which we can show behind the cell, like so:

    cell.backgroundColor = [UIColor clearColor];
    UIView *backView = [[UIView alloc]initWithFrame:CGRectZero];
    backView.backgroundColor = [UIColor clearColor];
    cell.backgroundView = backView;
    




     
  • Jay Versluis 7:20 pm on December 26, 2012 Permalink | Reply
    Tags: project   

    Categories: iOS ( 222 )   

    How to rename an app in Xcode 4.5 

    You can conveniently rename an app you’ve started. For this example, we have a project called Old Project, created from the Master/Detail Template.

    Three areas need to be changed here:

    1. the actual app name and targets
    2. the scheme
    3. the group in which most project files reside

    Renaming the app

    Rename1

    Click on the blue Project, wait a second, then click on it again. The field will change just like in Finder, so you can type in your new app title. Once you hit return it will open a new dialogue box which will tweak some other files, most notably any existing targets, the bundle identifier (if it was set to automatic) and the app’s displayed name.

    Screen Shot 2012-12-26 at 19.08.03

    A couple of things still have the old name, so let’s fix that next.

    Renaming the scheme

    Rename2

    The scheme is displayed at the top next to the run and compile button. Click the left part of the drop-down menu and a context menu will appear, showing Manage Schemes. Don’t click on the right part (where it says iOS Device or iOS Simulator) as this will only let you pick which device you’d like to run the app on, not which scheme you’d like to use.

    Screen Shot 2012-12-26 at 19.14.21

    And just like before, click on the old app name, wait a second, then click again to change it to your new app title. If you have multiple schemes you can rename them all before hitting OK.

    Screen Shot 2012-12-26 at 19.14.46

    Renaming the file group

    This is more of a cosmetic thing: on the left hand side you will still have a group which contains most of your project files. These are not really folders, they are just convenient groups to keep a large amount of files in places where you can find them within a project. Again click on that group, wait a moment, then click again and rename it like a folder or file in Finder.

    Rename3

    And that’s it ;-)





     
  • Jay Versluis 4:07 pm on December 23, 2012 Permalink | Reply
    Tags: , , ,   

    Categories: How To ( 33 )   

    How to use Xcode with a remote Git server 

    Xcode_iconImagine you’ve created a project in Xcode with a local Git repository. Now you’d like to put this online so that others can collaborate with you. How do you do that?

    This has been puzzling me for a while, and there doesn’t seem to be a clear documentation on this subject – so I’ve decided to take some notes as I figured it out. Here are step by step instructions on how to make it work.

    All we need is a server running Git and SSH credentials to that server to get started.

    (More …)





     
    • Jaro 12:56 pm on April 2, 2013 Permalink | Reply

      But what if I dont wish to make a new bare repository. Instead I wish to use the local .git file that is here: /%PROJECT FOLDER%/.git ?

      • Jay Versluis 2:16 pm on April 2, 2013 Permalink | Reply

        Hi Jaro,

        In that case, just head over to the Xcode Repository browser (in the Organizer) and click the little plus icon on the bottom left. You can add a local repository there.

  • Jay Versluis 2:27 pm on December 23, 2012 Permalink | Reply
    Tags: ,   

    Categories: How To ( 33 ), Linux ( 100 )   

    How to install Git on CentOS 

    Git-Logo-2ColorGit is a superb version control system that’s tightly integrated into Apple’s Xcode. To collaborate with some coding buddies of mine we wanted to setup a central remote storage on my Plesk server so we could all contribute to the code.

    Since we did not want to share our code with the public we wanted to make it secure. So secure in fact that we could contribute from coffee shops around the world, hence we decided to use Git with SSH. This is probably the easiest and most straightforward way for read/write access to Git remotes: no daemon to setup, to Firewall to tweak – all we needed was a set of SSH credentials and a server running Git with a bit of space.

    (More …)





     
  • Jay Versluis 2:06 pm on December 23, 2012 Permalink | Reply
    Tags:   

    Categories: Plesk ( 75 )   

    How to give your Plesk users SSH access 

    Plesk-LogoBy default SSH access is disabled for FTP and web users which is a very good thing. I’d recommend enabling this only if you know exactly who’s connecting to your server and why.

    In my case, I want to use my server to host Git repositories so I can collaborate with some trusted coding buddies of mine. Here’s how I did it – I’m using Plesk 11 for this demonstration:

    (More …)





     
    • Ramadhan sora 11:44 pm on January 17, 2013 Permalink | Reply

      Save to desktop

    • Steffen Hornung 8:34 am on December 2, 2013 Permalink | Reply

      And what if I want an additional user to enable sftp/ssh

      • Jay Versluis 8:44 am on December 2, 2013 Permalink | Reply

        Hi Steffen,

        Sadly that’s not possible, only the main subscription user is allowed SSH/SFTP access, additional web and FTP users on the same subscription are not. It would be a nice feature to have, not sure why Parallels have elected not to make it available.

  • Jay Versluis 12:32 pm on December 21, 2012 Permalink | Reply
    Tags: bar, button, hide, menu bar, ,   

    Categories: iOS ( 222 )   

    How to hide a UIBarButton item 

    You can set simply set your UIBarButtonItem to nil, like so:

    self.navigationItem.rightBarButtonItem = nil;
    




     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel