1. 升級gem報錯
MacBook-Pro:~ Roy$ gem update --system
Updating rubygems-update
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
處理方式:
sudo chown -R $USER /Library/Ruby/Gems/ 或者 sudo gem update --system
2. 安裝cocoapods報錯
MacBook-Pro:~ Roy$ sudo gem install cocoapods
Fetching: nanaimo-0.2.3.gem (100%)
Successfully installed nanaimo-0.2.3
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: claide-1.0.1.gem (100%)
Successfully installed claide-1.0.1
Fetching: CFPropertyList-2.3.5.gem (100%)
Successfully installed CFPropertyList-2.3.5
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: minitest-5.10.1.gem (100%)
Successfully installed minitest-5.10.1
Fetching: i18n-0.8.0.gem (100%)
Successfully installed i18n-0.8.0
Fetching: activesupport-4.2.7.1.gem (100%)
Successfully installed activesupport-4.2.7.1
Fetching: xcodeproj-1.4.2.gem (100%)
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
處理方式:
sudo gem install -n /usr/local/bin cocoapods
3. 卸載已安裝的cocoapods
1、如果之前裝過cocopods,最好先卸載掉,卸載命令:
$ sudo gem uninstall cocoapods
2、先查看本地安裝過的cocopods相關(guān)東西,命令如下:
$ gem list --local | grep cocoapods
會顯示如下:
cocoapods-core (0.39.0)
cocoapods-downloader (0.9.3)
cocoapods-plugins (0.4.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2)
cocoapods-trunk (0.6.4)
cocoapods-try (0.5.1)
然后逐個刪除吧:
$ sudo gem uninstall cocoapods-core
4.Mac文件夾隱藏和顯示的命令如下:
隱藏:defaults write com.apple.finder AppleShowAllFiles -bool true
顯示:defaults write com.apple.finder AppleShowAllFiles -bool false
5.安裝rvm報錯
MacBook-Pro:~ LuohanCC$ rvm 2.0.0 --default
ruby-2.0.0-p643 is not installed.
To install do: 'rvm install ruby-2.0.0-p643'
LuohandeMacBook-Pro:~ LuohanCC$ rvm install ruby-2.0.0-p643
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.0.0-p643.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system.......
Error running 'requirements_osx_brew_update_system ruby-2.0.0-p643',
showing last 15 lines of /Users/LuohanCC/.rvm/log/1436950973_ruby-2.0.0-p643/update_system.log
[https://github.com/Homebrew/homebrew/wiki/Common-Issues](https://github.com/Homebrew/homebrew/wiki/Common-Issues)
and make sure `brew update` works before continuing.'
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'Failed to update Homebrew, follow instructions here:
[https://github.com/Homebrew/homebrew/wiki/Common-Issues](https://github.com/Homebrew/homebrew/wiki/Common-Issues)
and make sure `brew update` works before continuing.\n'
Failed to update Homebrew, follow instructions here:
[https://github.com/Homebrew/homebrew/wiki/Common-Issues](https://github.com/Homebrew/homebrew/wiki/Common-Issues)
and make sure `brew update` works before continuing.
++ return 1
Requirements installation failed with status: 1.
原因:因Mac未安裝Homebrew造成的
解決方法:在命令行輸入以下指令安裝Homebrew或者進入官網(wǎng)找到最新的下載鏈接
Homebrew官網(wǎng):http://brew.sh/index_zh-cn.html
ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))"
然后再次執(zhí)行$ rvm install 2.0.0
注意事項:安裝CocoaPots的順序:
Xcode -> homebrew -> RVM -> Ruby -> CocoaPots;
Sublime Text3 for Mac注冊碼
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
B085E65E 2F5F5360 8489D422 FB8FC1AA
93F6323C FD7F7544 3F39C318 D95E6480
FCCC7561 8A4A1741 68FA4223 ADCEDE07
200C25BE DBBC4855 C4CFB774 C5EC138C
0FEC1CEF D9DCECEC D3A5DAD1 01316C36
—— END LICENSE ——
6.安裝 xcode Alcatraz 插件管理器
- 1.執(zhí)行命令
curl -fsSL https://raw.github.com/alcatraz/Alcatraz/master/Scripts/install.sh|sh
- 2.前往
github地址https://github.com/alcatraz/Alcatraz下載打開使用xcode運行在mac上即可.
7.xcode 導(dǎo)出自定義的代碼塊
Xcode中的代碼塊默認(rèn)存儲在~/Library/Developer/Xcode/UserData/CodeSnippets下,可以直接拷貝出來,放在新電腦的該目錄下即可~
8.Swift中Any和AnyObject區(qū)別
AnyObject是一個協(xié)議,Any是零個協(xié)議!AnyObject用于任何類實例,而Any用于任何變量。
9.靜態(tài)庫打包合并命令
lipo -create 文件1路徑.文件 文件2路徑.文件 -output 合成文件路徑.文件
例如:
lipo -create /Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/Release-iphonesimulator/libPrint.a /Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/Release-iphoneos/libPrint.a -output /Users/pjk1129/Desktop/libPrint.a
10.lipo命令使用
- 查看靜態(tài)庫所支持的架構(gòu)
lipo -info xxx - 合并模擬器Framework與真機Framework
lipo -create xx1 xx2 -output xx3
http://devonios.com/xcode-lipo-framework.html
11.指定頁面靜止旋轉(zhuǎn)
- 如果是UINavigationController/UIViewController/UITabbarController,需要在指定的控制器中實現(xiàn)下面三個方法即可,(如用的是UINavigationController, 在ViewController中實現(xiàn)無用,需要在自定義的UINavigtaionController中實現(xiàn)方法才會生效)
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationMaskPortrait);
}
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait; // 表示只支持一個方向
}
12. Xcode編譯報錯
ditto: /Users/ppdai-roy/Library/Developer/Xcode/DerivedData/TestDemo-dfhwbabnlppefudopphgpjdywiga/Build/Products/Debug-iphonesimulator/TestDemo.app/Frameworks/XCTest.framework/XCTest.tbd: Operation not supported
Command /usr/bin/ditto failed with exit code 1
解決方式:stackoverflow
13. Git遠(yuǎn)程回退
git reset --hard HEAD~1
git push --force