本文主要是來學習Xcode的學習文檔,來瞭解並學習Xcode4主題樣式的操作的內容,詳細的獎金了整個過程類似實現xcode4的主題樣式,具體內容來看本文詳細內容。
一、下載安裝Xcode4
因為我需要讓Xcode4和老版本共存,在安裝Xcode4時選擇其他安裝路徑,安裝成功後在xcode4安裝目錄下改名Xcode.app為Xcode4.app以區分老版本,隨便找一個xcodeproj檔案,右鍵Get Info,在Open with裡面選擇Xcode4並點擊Change All以設定檔案類型關聯。
二、熟悉介面
開啟Xcode,大概瀏覽下介面的變化,到處亂點下看是啥東西,把Xcode菜單瀏覽一遍。有空的話可以看看協助文檔裡面關於原始程式碼控制的部分。試著建一個HelloWorld項目,並操作下IB連結。
三、配置代碼編輯器的字型和顏色(Fonts & Colors)
我比較喜歡用黑色背景寫代碼,眼睛比較舒服。以前老的ColorTheme檔案用不了,ColorTheme的存放路徑變了,舊的在~/Library/Application Support/Xcode/Color Themes,Xcode4的在~/Library/Developer/Xcode/UserData/FontAndColorThemes下,而且檔案格式也變了,但是大部分項目都是一樣的。可以重新設定顏色字型,也可以對照著手動改設定檔。
Google了一下,aktowns已經寫了一個轉換指令碼:https://gist.github.com/793006
使用方法非常簡單:
1、下載dvtcolorconvert.rb,假如你放在案頭,把舊的Theme檔案也複製到案頭
- //dvtcolorconvert.rb
-
- #!/usr/bin/env ruby
- # This script converts xccolorthemes to dtvcolorthemes for porting xcode 3.x themes to xcode 4.x
- # created by ashley towns <ashleyis@me.com>
- # Public domain.
- # ./dvtcolorconvert <inputfile>
- # spits out a .dtvcolortheme file
-
- require 'rubygems'
- require 'plist'
- raise "Error: need a source file #{__FILE__} [file.xccolortheme]" if ARGV.length == 0
-
- def alpha inc, alpha=1
- "#{inc} #{alpha}"
- end
- def convert infile
- hash = Plist::parse_xml infile
- out_hash = {}
- out_hash[:DVTSourceTextSyntaxFonts] = {}
- out_hash[:DVTSourceTextSyntaxColors] = {}
- hash.each do |name, node|
- node.each do |child_name, child|
- puts "[on] node:#{name} child:#{child_name}(#{child})"
- if name == "Colors"
- case child_name
- when /Background/
- out_hash[:DVTSourceTextBackground] = alpha child
- out_hash[:DVTConsoleTextBackgroundColor] = alpha child
- out_hash[:DVTSourceTextInvisiblesColor] = alpha child
- out_hash[:DVTSourceTextBlockDimBackgroundColor] = alpha child
- when /InsertionPoint/
- out_hash[:DVTSourceTextInsertionPointColor] = alpha child
- out_hash[:DVTConsoleTextInsertionPointColor] = alpha child
- out_hash[:DVTDebuggerInsutrctionPointerColor] = alpha child
- out_hash[:DVTConsoleDebuggerInputTextColor] = alpha child
- out_hash[:DVTConsoleDebuggerOutputTextColor] = alpha child
- out_hash[:DVTConsoleExectuableInputTextColor] = alpha child
- out_hash[:DVTConsoleExecutableOutputTextColor] = alpha child
- when /Selection/
- out_hash[:DVTSourceTextSelectionColor] = alpha child
- out_hash[:DVTConsoleTextSelectionColor] = alpha child
- out_hash[:DVTDebuggerPromptTextColor] = alpha child
- else
- out_hash[:DVTSourceTextSyntaxColors][child_name] = alpha child
- end
- elsif name == "Fonts"
- case child_name
- when /xcode.syntax.plain/
- child = "Inconsolata - 14pt"
- out_hash[:DVTConsoleDebuggerInputTextFont] = child
- out_hash[:DVTConsoleDebuggerOutputTextFont] = child
- out_hash[:DVTConsoleDebuggerPromptTextFont] = child
- out_hash[:DVTConsoleExecutableInputTextFont] = child
- out_hash[:DVTConsoleExecutableOutputTextFont] = child
- out_hash[:DVTSourceTextSyntaxFonts]['xcode.syntax.plain'] = child
- else
- out_hash[:DVTSourceTextSyntaxFonts][child_name] = "Inconsolata - 14pt" #child
- end
- else
- raise "I don't know what #{name} is."
- end
- end
- end
- puts "Saving #{infile.gsub(/xccolortheme/,'dvtcolortheme')}"
- fp = File.open(infile.gsub(/xccolortheme/,'dvtcolortheme'),'w')
- fp.write out_hash.to_plist
- fp.close
- end
-
- convert ARGV[0]
- #Dir['*.xccolortheme'].each do |file|
- # convert file
- #end
2、安裝"plist“ ruby gem: $sudo gem install plist
3、執行轉化: $ruby dvtcolorconvert.rb ElfDart.xccolortheme 就在案頭產生ElfDart.xccolortheme了,放到~/Library/Developer/Xcode/UserData/FontAndColorThemes下重啟Xcode4,在Preferences中的Fonts & Colors啟用主題。
我轉換後的主題檔案,
如果你喜歡的話可以在這裡下載到:http://code.google.com/p/elf-ios-resource/downloads/detail?name=ElfDark.dvtcolortheme
https://github.com/Sundae/Cocoa-Utilities
四、Preferences/Text Editing 圖示)
小結:Xcode學習文檔:Xcode4主題樣式的內容介紹完了,希望通過本文的學習能對你有所協助!