工作笔记(1)

目录

拷贝SSH Keys

pbcopy < ~/.ssh/id_rsa.pub

git修改当前分支为main

git branch -M main

Ruby获取当前文件路径

$current_dir = File.dirname(File.expand_path(__FILE__))

终端、git设置代理

alias proxy='export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890'

alias unproxy="unset all_proxy"

alias gitproxy='git config --global http.proxy http://127.0.0.1:7890 && git config --global https.proxy https://127.0.0.1:7890'

alias ungitproxy='git config --global --unset http.proxy && git config --global --unset https.proxy'

全局文件中字符串替换

sed -i '' "s/192.28.6.24/192.26.5.171/g" `find -L ~/ -type f | grep .git/config`

终端只显示路径

在偏好设置->描述文件->Shell->启动 shell命令添加

PS1="\W \$:"; clear;
PS1="\W 😊:"; clear;

允许安装任何来源

sudo spctl --master-disable

时间统计

CFAbsoluteTime startTime =CFAbsoluteTimeGetCurrent();
CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime);
NSLog(@">>>>>>>>>>>>>>>>>time %f ms<<<<<<<<<<<<<<<<<<<", linkTime *1000.0);

iOS 遍历子视图

po [0x7fcdce80f030 recursiveDescription]
[[[UIApplication sharedApplication] keyWindow] recursiveDescription]


归档命令

tar -cjf DSYM.tar.bz2 

pod资源

s.resources = 'TUser/**/*.xib','TUser/**/*.plist','TUser/Resources/*','TUser/**/*.lproj'

打印字典

[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding]

添加断点

watchpoint set variable str
watchpoint command add -o 'bt' 1
添加线程信息 1位id
breakpoint set -n "[UIViewController viewDidLoad]"

https://www.jianshu.com/p/67f08a4d8cf2

https://www.jianshu.com/p/fd10bb8b89d6

https://www.jianshu.com/p/63d1bd3fe36d

https://www.jianshu.com/p/34021d7479d0

SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

https://stackoverflow.com/questions/48987512/ssl-connect-ssl-error-syscall-in-connection-to-github-com443
https://osxdaily.com/2014/04/18/disable-ipv6-mac-os-x/

字符串匹配

NSMutableAttributedString *newString = [[NSMutableAttributedString alloc] initWithString:@"要匹配的字符"];
    
NSRegularExpression *regex = [[NSRegularExpression alloc]initWithPattern:@"匹配的字符" options:NSRegularExpressionCaseInsensitive error:nil];
    
[regex enumerateMatchesInString:self.model.showtitle options:NSMatchingReportProgress range:NSMakeRange(0, newString.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
    
    [newString addAttribute:(NSString*)NSForegroundColorAttributeName
                      value:[UIColor redColor]
                      range:result.range];
}];
self.aTitle.attributedText = newString;

git 切换到某个tag
git checkout -b branch_name tag_name

git config user.name
git config user.email

没有add 之前 回滚
Git discard
git checkout -- README.MD

Add 之后回滚
git reset HEAD README.MD

撤销提交 已经commit 未push
git reset --hard HEAD^


查看远程分支
git remote -v

git pull <远程主机名> <远程分支名>:<本地分支名>
比如,要取回origin主机的next分支,与本地的master分支合并,需要写成下面这样 -
git pull origin next:master
如果远程分支(next)要与当前分支合并,则冒号后面的部分可以省略。上面命令可以简写为:
git pull origin next

在某些场合,Git会自动在本地分支与远程分支之间,建立一种追踪关系(tracking)。比如,在git clone的时候,所有本地分支默认与远程主机的同名分支,建立追踪关系,也就是说,本地的master分支自动“追踪”origin/master分支。Git也允许手动建立追踪关系:
git branch --set-upstream-to=远程主机名/<远程分支名>  <本地分支名>
比如git branch --set-upstream-to=origin/next master,指定master分支追踪origin/next分支。

Git 报错 (non-fast-forward)
解决方法:git pull origin master --allow-unrelated-histories


git error: failed to push some refs to

git pull --rebase origin master
git push origin master

Git clone 指定tag版本

git clone https://github.com/SDWebImage/SDWebImage.git
     /var/folders/
     --template= --single-branch --depth 1 --branch 5.0.2


打印公钥
 cat ~/.ssh/id_rsa.pub




Git配置
git config --global user.name "Jone doe"
git config --global user.email 694292399@qq.com

git config --list

git config user.name

查看状态

git status -s
git status --short

比较
git diff

git diff --cached
git diff --staged

跳过暂存区
git -a -m 'msg'


移动文件

git mv file_from file_to

日志

git log 
git log -p 显示每次提交内容差异
git log -p -2 显示最近两次提交



取消暂存文件
git reset HEAD <file>

撤销对文件的修改

git checkout -- <file>

查看远程仓库

git remote

git remote -v 显示URL

git添加远程仓库
git remote add <shortname> <url>

从远程仓库中抓取与拉取
git fetch [remote-name]

推送到远程仓库
git push [remote-name] [origin-name]
git push origin master

查看远程仓库
git remote show [remote -name]



git 远程仓库重命名与移除

重命名
git remote rename origin bp

git remote rm origin

git 附注标签

git tag -a 3.0.0 -m '3.0.0版本'

查看标签信息
 git show 3.0.0

后期打标签

git tag -a 3.0.0 9fceb02

git push origin [tagname]

一次推送多个标签
git push origin --tags

检出标签
git checkout -b [branchname] [tagname]


git log --oneline --decorate --graph --all

git 创建分支

git branch [branchname]

git 切换分支
git checkout [branchname]

git checkout -b [branchname]  [origin]/[branchname]

git 新建分支
git checkout -b issu3
相当于
git branch issu3
git checkout issu3

从hotfix合并到master分支
git checkout master
git merge hotfix

git 删除分支
git branch -d [branchname]

git 推送分支
git push (remote) (branch)

git branch命令的-r选项,可以用来查看远程分支,-a选项查看所有分支

远程分支
origin/master

取回origin主机的master分支。
$ git fetch origin master
取回远程主机的更新以后,可以在它的基础上,使用git checkout命令创建一个新的分支。
git checkout -b newBrach origin/master

git checkout -b [branch]  [remotename]/[branch]
        ||
git checkout --track origin/develop
删除远程分支
git push origin --delete fix_1212

新分支推送
git push --set-upstream origin kunshan_develop

git还原部分文件到指定版本
git checkout 07ed0f4a1b9118124df26d62ffa8c253ec540207 E:/Workspaces/WebStormProject/mobile/resources/ios/splash/

Xcode快捷键

XCode快捷键
Comand+Shift+O 搜索
Comand+T 新建标签
Shift+Comand+T 新建项目
option + command + N : 新建Group


command + W : 关闭标签
option + command + W : 关闭项目


shift + command + C : 开启控制台?
shift + command + Y : 隐藏/显示 Debug
command+k 清除日志

Command+Shift+F 搜索

标签切换
control + t 

option + commamd + D 显示隐藏Dock

Cmd + Opt + J         跳转到文件过滤区
Cmd + Opt +Left/Right   收起展示代码


command + ~ 两个项目之间快速切换 

Pods

清楚pod缓存

pod cache clean --all

Pods 库 file not found

在 User header search path 
${SRCROOT}/..

Pod不升级库安装

pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

unknown: Encountered an unknown error (Unable to find a specification for Router depended upon by Homepage) during validation.

pod lib lint --sources='http://172.28.6.24/ios_phenix/toon_pod_spec.git'

Pod lib lint 验证常见参数

去除警告
pod lib lint --allow-warnings

打印详细日志

pod lib lint --verbose --no-clean

添加私有源

pod lib lint --sources='http://192.28.6.24/ios_phenix/toon_pod_spec.git'

error: include of non-modular header inside framework module

pod lib lint --use-libraries
#或者
pod spec lint --use-libraries
#当然,在提交的时候也要加上
pod repo push <repoName> <podspec> --use-libraries
#此方法好像能一并解决xxx.h找不到的问题

添加 Podspec 到你的 repo

pod repo push O2Specs O2View.podspec

git tag '0.0.1'
git push --tags
git push origin master


私有库有引用私有库的情况,在验证已经推送podspec的时候都需要加上所有的资源地址,不然,pod会默认从cocoapods官方查询的。
  如,私有库a要引用私有库b,在验证与推送私有库a的时候,要加上私有库b的远程仓库地址,如下
  注意:要在pod lib lint 或者 pod spec lint 以及 pod repo push ....时候加上被引用的私有库地址  
pod spec lint --sources='#私有库b的远程仓库地址(如:http://xxxxxx.git)#,https://github.com/CocoaPods/Specs'
 pod repo push #本地Repo名字# #.podspec名# --sources='[私有库b的远程仓库地址(如:http://xxxxxx.git)],https://github.com/CocoaPods/Specs'

#demo:
 pod spec lint --sources='http://xxxxxx/iOSRepos.git,https://github.com/CocoaPods/Specs'

 pod repo push iOSTest iOSTest.podspec --sources='http://git.yinqiyun.com/xfx/iOSRepos.git,https://github.com/CocoaPods/Specs'

 

pod私有库报错

http://www.cnblogs.com/tufeibo/p/5654268.html
https://www.jianshu.com/p/283584683b0b
pod lib lint --sources=http://toongitlab.syswin.com/ios_phenix/zhengtong_ios_phenix_pod_spec,https://github.com/CocoaPods/Specs.git --allow-warnings  

pod lib lint --sources='http://172.28.6.24/ios_phenix/toon_pod_spec.git' 

pod lib lint --sources=http://toongitlab.syswin.com/ios_phenix/zhengtong_ios_phenix_pod_spec,https://github.com/CocoaPods/Specs.git --allow-warnings --skip-import-validation

pod lib lint --verbose (加--verbose可以显示详细的检测过程,出错时会显示详细的错误信息)
pod lib lint --allow-warnings (允许警告,用来解决由于代码中存在警告导致不能通过校验的问题)
pod lib lint --help (查看所有可选参数,可选参数可以加多个)
--skip-import-validation 参数,lint 将跳过验证 pod 是否可以导入。

CocoaPods卸载

1、查看CocoaPods组件安装位置:

which pod
结果:
/usr/bin/pod

2、手动移除这个组件:

sudo rm -rf /usr/bin/pod

2、移除RubyGems中的CocoaPods程序包

2.1、查看gems中本地程序包

gem list

2.2、移除程序包

有了版本号,就可以根据当前版本号移除CocoaPods了:
sudo gem uninstall cocoapods -v 1.5.3
sudo gem uninstall cocoapods-core
sudo gem uninstall fourflusher

2.3安装指定版本

$sudo gem install -n /usr/local/bin cocoapods -v 1.5.3
https://gems.ruby-china.com/

podspec设置buildsetting

s.xcconfig = {
  'ENABLE_INCREMENTAL_DISTILL' => 'YES'
  }

验证pods

pod lib lint --sources=http://toongitlab.syswin.com/ios_phenix/zhengtong_ios_phenix_pod_spec,https://github.com/CocoaPods/Specs.git --allow-warnings  

解决pod lib lint/repo push不支持i386编译&只能真机运行的库

https://www.jianshu.com/p/88180b4d2ab7

Pod 打包

pod package Homepage.podspec --force --spec-sources=http://gitlab.sfyfwin.com/ios_pnix/zheng_ios_pod_spec,https://github.com/CocoaPods/Specs.git --no-mangle


pod package ToKit.podspec --force --embedded --no-mangle --spec-sources=http://192.28.6.24/iOSTon/swin_pod_spec,https://github.com/CocoaPods/Specs.git
https://yangjie2.github.io/2018/08/07/%E4%BD%BF%E7%94%A8cocoapods%E6%8F%92%E4%BB%B6%E6%89%93%E5%8C%85%E9%9D%99%E6%80%81%E5%BA%93%E2%80%94%E2%80%94%E9%80%82%E7%94%A8%E4%BA%8E%E9%A1%B9%E7%9B%AE%E4%BE%9D%E8%B5%96%E7%A7%81%E6%9C%89%E5%BA%93%E3%80%81%E5%BC%80%E6%BA%90%E5%BA%93%EF%BC%8C%E7%A7%81%E6%9C%89%E5%BA%93%E5%8F%88%E4%BE%9D%E8%B5%96%E9%9D%99%E6%80%81%E5%BA%93%E7%AD%89%E5%A4%8D%E6%9D%82%E5%9C%BA%E6%99%AF/

pod package 参数

--force
# 强制覆盖之前已经生成过的二进制库
--embedded
# 生成静态.framework
--library
# 生成静态.a
--dynamic
# 生成动态.framework
--bundle-identifier
# 动态.framework是需要签名的,所以只有生成动态库的时候需要这个BundleId
--exclude-deps
# 不包含依赖的pod库的符号表/依赖的pod库不打包进去。生成动态库的时候不能使用这个命令,动态库一定需要包含依赖的符号表。 
--configuration
# 表示生成的库是debug还是release,默认是release 。
例如:--configuration=Debug,ONLY_ACTIVE_ARCH=NO
--no-mangle
# 表示 Do not mangle symbols of depedendant Pods,当你的项目依赖包含静态库时,
不加上这句,就会打包失败:
[!] podspec has binary-only depedencies,mangling not possible.
--subspecs
# 如果你的pod库有subspec,那么加上这个命名表示只给某个或几个subspec生成二进制库,
# --subspecs=subspec1,subspec2。生成的库的名字就是你podspec的名字,
# 如果你想生成的库的名字跟subspec的名字一样,那么就需要修改podspec的名字。 
# 这个脚本就是批量生成subspec的二进制库,每一个subspec的库名就是podspecName+subspecName。
--spec-sources
# 一些依赖的source,如果你有依赖是来自于私有库的,
# 那就需要加上那个私有库的source,默认是cocoapods的Specs仓库。
# --spec-sources=private,https://github.com/CocoaPods/Specs.git。

cocoapods can’t find simulators, pod repo push fails

https://stackoverflow.com/questions/52742003/cocoapods-cant-find-simulators-pod-repo-push-fails

s.dependency 'PromiseKit','1.7.6'

#valid_archs = ['arm64']
  #s.xcconfig = { 'VALID_ARCHS'=> valid_archs.join(' '),}
  s.xcconfig = {
    'VALID_ARCHS' =>  'arm64',
  }

雷达

雷达

library not found for -libstdc++.6.0.9

将 libstdc++、libstdc++.6、libstdc++6.0.9拷贝到Xcode的如下目录:
1.真机环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
2.模拟器环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

Reveal 安装方法

1、选中项目target — 》Build Settings—-》搜索Framework Search Paths—》将$(inherited) $(SRCROOT)填进去 2、-Build Settings—->Other Linker Flags—>填入-ObjC -weak_framework RevealServer 3、-Build Phases –》点击+添加Run Script phase

export REVEAL_SERVER_FILENAME="RevealServer.framework"

 # Update this path to point to the location of RevealServer.framework in your project.
 export REVEAL_SERVER_PATH="${SRCROOT}/${REVEAL_SERVER_FILENAME}"

 # If configuration is not Debug, skip this script.
 [ "${CONFIGURATION}" != "Debug" ] && exit 0

 # If RevealServer.framework exists at the specified path, run code signing script.
 if [ -d "${REVEAL_SERVER_PATH}" ]; then
   "${REVEAL_SERVER_PATH}/Scripts/copy_and_codesign_revealserver.sh"
 else
   echo "Cannot find RevealServer.framework, so Reveal Server will not be started for your app."
 fi

https://www.cnblogs.com/somethingWithiOS/p/6594496.html

创建模板

系统模板地址

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates

用户自定义模板地址

~/Library/Developer/Xcode/Templates/
https://www.jianshu.com/p/25387283d469

修改APP版本build 版本号

build_version=$(date +%y%m%d%H%M)
echo "build_version${build_version}"
/usr/libexec/PlistBuddy -c "Set CFBundleVersion ${build_version}" ${INFOPLIST_FILE}

flutter

1、访问父类Widget
context.ancestorWidgetOfExactType(MyExposingWidget);
2、获取State
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

myWidgetStateKey.currentState

class MyInheritedWidget extends InheritedWidget {
   MyInheritedWidget({
      Key key,
      @required Widget child,
      this.data,
   }): super(key: key, child: child);
    
   final data;
    
   static MyInheritedWidget of(BuildContext context) {
      return context.inheritFromWidgetOfExactType(MyInheritedWidget);
   }

   @override
   bool updateShouldNotify(MyInheritedWidget oldWidget) => data != oldWidget.data;
}

flutter安装

flutter安装
设置环境变量
sudo vi ~/.bash_profile

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn


:wq

下载flutter 放到 ~/flutter
在~/.bash_profile设置环境变量
export PATH=~/flutter/bin:$PATH
运行 source $HOME/.bash_profile 刷新当前终端窗口。
验证“flutter/bin”是否已在PATH中:
echo $PATH

flutter doctor


flutter 日期比较
DateTime.now().difference(_lastPressedAt) > Duration(seconds: 1)

.bash_profile

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
# export PATH=~/flutter/bin:$PATH
export PATH="/Users/syswin/Library/Application Support/fvm/current/bin:$PATH"

export PATH=/usr/local/opt/openssl@1.1/bin:$PATH
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

export NVM_DIR="$HOME/.nvm"
export BASH_SILENCE_DEPRECATION_WARNING=1
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


export MonkeyDevPath=/opt/MonkeyDev
export MonkeyDevDeviceIP=
export PATH=/opt/MonkeyDev/bin:$PATH

export THEOS=/opt/theos
export PATH=$THEOS/bin/:$PATH

export  THEOS_DEVICE_IP=127.0.0.1
export  THEOS_DEVICE_PORT=10010


export HOMEBREW_NO_AUTO_UPDATE=true

alias grep='grep --color=auto'
alias ll='ls -l'
alias lla='ls -l -a'
alias god='cd ~/Desktop/ && echo "当前目录:桌面"'
alias opro='open /Users/syswin/Desktop/项目'
alias rbs='sleep 7 && open http://127.0.0.1:4000 & cd /Users/syswin/Desktop/MySite && bundle exec jekyll serve'



# alias pod1='podcmd() { echo $1; awk -v rst=$1 -v cmd="$*" "/^TN/{ gsub(/update/,\"\", \$0);print \$0 cmd}" ../README.MD;}; podcmd install'

alias pod1='podcmd() { pod repo update 6-ios_phenix-toon_pod_spec; awk -v rst=$1 -v cmd="$*" "/^TN/{ gsub(/update/,cmd, \$0);print \$0; system("\$0")}" ../README.MD;}; podcmd install'

alias pod2='podcmd() { pod repo update 6-ios_phenix-toon_pod_spec; awk -v rst=$1 -v cmd="$*" "/^TN/{ gsub(/install/,cmd, \$0);print \$0; system("\$0")}" ../README.MD;}; podcmd update'

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦