「问题」笔记本

字数 485阅读 30

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相关东西,命令如下:
$ 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或者进入官网找到最新的下载链接
Homebrew官网: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))"

然后再次执行$ 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.执行命令
curl -fsSL https://raw.github.com/alcatraz/Alcatraz/master/Scripts/install.sh|sh
  • 2.前往github地址https://github.com/alcatraz/Alcatraz下载打开使用xcode运行在mac上即可.

7.xcode 导出自定义的代码块

Xcode中的代码块默认存储在~/Library/Developer/Xcode/UserData/CodeSnippets下,可以直接拷贝出来,放在新电脑的该目录下即可~

8.SwiftAnyAnyObject区别

AnyObject是一个协议,Any是零个协议!AnyObject用于任何类实例,而Any用于任何变量。

9.静态库打包合并命令

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命令使用

  • 查看静态库所支持的架构lipo -info xxx
  • 合并模拟器Framework与真机Frameworklipo -create xx1 xx2 -output xx3
http://devonios.com/xcode-lipo-framework.html

11.指定页面静止旋转

  • 如果是UINavigationController/UIViewController/UITabbarController,需要在指定的控制器中实现下面三个方法即可,(如用的是UINavigationController, 在ViewController中实现无用,需要在自定义的UINavigtaionController中实现方法才会生效)
- (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远程回退

git reset --hard HEAD~1
git push --force

14. Git远程回退

推荐阅读更多精彩内容