clang-format 参考配置

贴一份在用的参考配置,欢迎大家讨论

BasedOnStyle: LLVM
BreakBeforeBraces: Linux
Language: Cpp
ColumnLimit: 200
ReflowComments: false
SortIncludes: false

#括号风格
BreakBeforeBraces: Custom
BraceWrapping:
  AfterEnum: false
  AfterStruct: false
  SplitEmptyFunction: false

# 连续声明时,对齐所有声明的变量名
AlignConsecutiveDeclarations:   true
# 针和引用的对齐: Left, Right, Middle
PointerAlignment:   Left
# 在C风格类型转换后添加空格
SpaceAfterCStyleCast:   false
# 在赋值运算符之前添加空格
SpaceBeforeAssignmentOperators: true
# 开圆括号之前添加一个空格: Never, ControlStatements, Always
SpaceBeforeParens:  ControlStatements
# 在空的圆括号中添加空格
SpaceInEmptyParentheses:    false
# 在尾随的评论前添加的空格数(只适用于//)
SpacesBeforeTrailingComments:   2
# 在尖括号的<后和>前添加空格
SpacesInAngles: true
# 宏赋值对齐
AlignConsecutiveMacros: true

xcode安装clang-format

clang-format是很好用的插件,所以我们也想在xcode中继续使用。

install

brew install clang-format

check version:

clang-format --version
clang-format version 9.0.0 (tags/google/stable/2019-05-14)

add automator service

创建automator action
automator
在左侧搜索“运行shell脚本”,并拖入右侧,在脚本本输入:

export PATH=/usr/local/bin:$PATH
clang-format

automator
将服务保存为clang-format(或者任意你喜欢的),后面还有用到这个名字。

setting clang-format

在当前用户的根目录 ~ 放置一个 .clang-format 文件。参考内容如下:

BasedOnStyle: LLVM
BreakBeforeBraces: Linux
Language: Cpp
ColumnLimit: 120
ReflowComments: false
SortIncludes: false

#括号风格
BreakBeforeBraces: Custom
BraceWrapping:
  AfterEnum: false
  AfterStruct: false
  SplitEmptyFunction: false

注意,这个只是参考,你需要按照你实际的风格进行设置。

add keyboard shortcuts

在系统设置页面找到“键盘”,选择“快捷键”的tab,在左侧选择 “app快捷键”,然后选择+号,创建用于xcode的快捷键,选择clang-format服务,然后选择一个你准备用户代码格式化的快捷键组合,比如 ctrl+i。
automator
在xcode中,选择我们的目标代码,然后ctrl+i,就触发clang-format格式化了。

done!

nehelper sent invalid result code [1] for Wi-Fi information request

ios运行时出现大量:
nehelper sent invalid result code [1] for Wi-Fi information request

经过搜索,增加”Access WiFi Information” 权限后问题解决。

ref:https://stackoverflow.com/questions/58791035/ios-13-2-message-nehelper-sent-invalid-result-code-1-for-wi-fi-information-re

OCSP check failed for /xxx/cert1.pem (are we offline?)

现象

certbot renew时出现类似的错误:
OCSP check failed for /xxx/cert1.pem (are we offline?)

原因

经搜索原因:原因是 ocsp.int-x3.letsencrypt.org 的 cname 域名 a771.dscq.akamai.net 受到了干扰。
可以采用本地修改hosts的方案进行临时处理,在/etc/hosts中添加

23.32.3.72     ocsp.int-x3.letsencrypt.org

验证

# openssl ocsp -no_nonce -issuer /etc/letsencrypt/archive/xxx/chain1.pem -cert /etc/letsencrypt/archive/xxx/cert1.pem -url http://ocsp.int-x3.letsencrypt.org -CAfile /etc/letsencrypt/archive/xxx/chain1.pem -verify_other /etc/letsencrypt/archive/xxx/chain1.pem -trust_other -header Host ocsp.int-x3.letsencrypt.org
Response verify OK
/etc/letsencrypt/archive/www.itranscloud.com/cert1.pem: good
    This Update: May 14 10:00:00 2020 GMT
    Next Update: May 21 10:00:00 2020 GMT

添加后,在重试 certbot renew,ok,正常

ref:https://holmesian.org/letsencrypt-ocsp-fix

This branch has conflicts that must be resolved 解决示例

使用git日常免不了遇到conflicts,那么如何消除conflicts呢,以下的内容以一个具体的过程来讲解整个过程和原理。

以下我们手动创造一个conflicts:
git conflicts

Step 1: From your project repository, check out a new branch and test the changes.

git checkout -b apache-master master
git pull https://github.com/apache/incubator-apisix.git master

Step 2: Merge the changes and update on GitHub.

git checkout master
git merge --no-ff apache-master
git push origin master

以上的的例子, 我们从A合入到B:B <== A。
A: https://github.com/apache/incubator-apisix.git
B: xxxx/incubator-apisix.git

例子中有一个README.md的冲突,并且给出了解决的命令行参考。
我们将逐条命令来解释如何按照提示解决冲突。

  1. 假设我们已经在B的git 根目录下。
  2. git checkout -b apache-master master #建立B的 apache-master分支,并切换到apache-master
  3. git pull https://github.com/apache/incubator-apisix.git master # 将A最新的内容合入apache-master
  4. 因为有冲突,所以上条执行时,会提示冲突:
From https://github.com/apache/incubator-apisix
 * branch            master     -> FETCH_HEAD
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
  1. 解决冲突[ … resolve any conflicts … ]:
    手动打开冲突文件,根据提示修改,删除冲突的内容,留下想要的结果内容。
  2. git add [files that were conflicted]
  3. git commit,将冲突修改提交敖本地仓库:
$ git commit -m "resolve the conflict"
[apache-master 6ad2d5e] resolve the conflict
  1. git checkout master # 将B切换为master
  2. git merge –no-ff apache-master #将B仓库的apache-master 合入 master
  3. git push origin master #将B仓库的最终的本地库推到云端master

最终解决了冲突,完成了对B master的更新。

希望以上就解释清楚,谢谢!

how to upgrade certbot from acmev1 to acmev2

original

certbot version:0.9.3
centos version:CentOS Linux release 7.0.1406 (Core)

upgrade the certbot version

#sudo yum update certbot

# certbot --version
certbot 1.3.0

upgrade the acme account

#certbot update_account
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Starting new HTTPS connection (1): supporters.eff.org

IMPORTANT NOTES:
 - Your e-mail address was updated to [email protected]

check upagrade result

ls /etc/letsencrypt/accounts
acme-staging.api.letsencrypt.org  acme-v01.api.letsencrypt.org  acme-v02.api.letsencrypt.org

you can see the acme-v02 information, it indicate that the upgrade is successful.

done, have fun!

iphone 屏幕尺寸相关

屏幕物理尺寸

4.0寸的iPhone5/5s
4.7寸的iPhone678
5.5寸的iPhone6P7P8P
5.8寸的iPhoneX/XS iPhone11Pro
6.1寸的iPhoneXr iPhone11
6.5寸的iPhone XS Max/iPhone 11 Pro Max

屏幕像素分辨率

ref:https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/#device-screen-sizes-and-orientations

Device Portrait dimensions Landscape dimensions
12.9″ iPad Pro 2048px × 2732px 2732px × 2048px
11″ iPad Pro 1668px × 2388px 2388px × 1668px
10.5″ iPad Pro 1668px × 2224px 2224px × 1668px
9.7″ iPad 1536px × 2048px 2048px × 1536px
7.9″ iPad mini 4 1536px × 2048px 2048px × 1536px
iPhone XS Max 1242px × 2688px 2688px × 1242px
iPhone XS 1125px × 2436px 2436px × 1125px
iPhone XR 828px × 1792px 1792px × 828px
iPhone X 1125px × 2436px 2436px × 1125px
iPhone 8 Plus 1242px × 2208px 2208px × 1242px
iPhone 8 750px × 1334px 1334px × 750px
iPhone 7 Plus 1242px × 2208px 2208px × 1242px
iPhone 7 750px × 1334px 1334px × 750px
iPhone 6s Plus 1242px × 2208px 2208px × 1242px
iPhone 6s 750px × 1334px 1334px × 750px
iPhone SE 640px × 1136px 1136px × 640px

图片分辨率

ref:https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/

Device Scale Factor
12.9″ iPad Pro @2x
11″ iPad Pro @2x
10.5″ iPad Pro @2x
9.7″ iPad @2x
7.9″ iPad mini 4 @2x
iPhone XS Max @3x
iPhone XS @3x
iPhone XR @2x
iPhone X @3x
iPhone 8 Plus @3x
iPhone 8 @2x
iPhone 7 Plus @3x
iPhone 7 @2x
iPhone 6s Plus @3x
iPhone 6s @2x
iPhone SE @2x

三者关系图

ref:https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

iad10.2

ref:https://medium.com/@hacknicity/how-ipad-apps-adapt-to-the-new-10-2-ipad-5d050b565fca
On 10th September 2019, Apple announced a 7th generation iPad with a 10.2″ screen. There are now five different iPad resolutions (in landscape):
9.7″: 1024×768 points (2048×1536 pixels)
10.2″: 1080×810 points (2160×1620 pixels)
10.5″: 1112×834 points (2224×1668 pixels)
11.0″: 1194×834 points (2388×1668 pixels)
12.9″: 1366×1024 points (2732×2048 pixels)

高德地图的bundle缺失错误

错误

无效的资源bundle,请检查AMap.bundle是否正确导入

这种错误一般是由于pod错误引起的。

解决

  1. 手动:在高德开发包MAMapKit.framework 中,通过项目文件管理器找到AMap.bundle,加入到项目中,一般放置于resource目录下,注意去掉file inspector 中的membership,否则可能报重复的错误问题
  2. pod 自动:重新执行pod update 或者 pod install

xcode appicon使用纪要

正常步骤

  1. AppIcon需要的文件,要加入本地的工程目录下,这样才能正确打包和调用。
    注意:每一个资源icon文件,加入后,其 file inspector 的target membership 都要勾选当前目标程序,否则可能出问题

  2. 需要在asset catalog下面创建 AppIcon对象

  3. 在plist中配置正确的AppIcon 相关字段,其中CFBundleIconName字段要一模一样,注意大小写和空格,避免低级错误。

其他问题

问题1:
上传商店时,一直莫名提示:

ERROR ITMS-90713: "Missing Info.plist value. A value for the Info.plist key 'CFBundleIconName' is missing in the bundle 'com.xxx.xxx'. Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7."

解决:
原来是CFBundleIconName节点的内容错误导致,正确的内容为在plist xml文件中添加如下:

<key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>icon-20-ipad</string>
                <string>icon-20</string>
                <string>icon-29-ipad</string>
                <string>icon-29</string>
                <string>icon-40</string>
                <string>icon-60</string>
                <string>icon-76</string>
                <string>icon-83.5</string>
                <string>ItunesArtwork</string>
            </array>
            <key>CFBundleIconName</key>
            <string>AppIcon</string>
        </dict>
    </dict>

成功后,在UI中表现就是出现:
Icon files (iOS 5) 相关的节点内容

ps:刚开始不知道怎么配置,看到此字段带了个括号iOS 5,以为是陈旧的格式,随手就把这个删除了,后面一直在网上找的不对的配置格式,各种折腾都无果,最后还是在github 代码片段的帮助下搞定了这个问题。

ERROR ITMS-90704:1024 by 1024 pixels icon problem

现象

在app上传时遇到如下的error:

ERROR ITMS-90704: "Missing App Icon. An app icon measuring 1024 by 1024 pixels in PNG format must be included in the Asset Catalog of apps built for iOS, iPadOS, or watchOS. Without this icon, apps cannot be submitted for review. For details, see https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/app-icon/."

各种搜索,大部分讨论都在 stackoverflow, 比如:https://stackoverflow.com/questions/44667434/how-to-solve-missing-marketing-icon-ios-apps-must-include-a-1024x1024px/61618816#61618816

搜索分析

无非以下几种排查思路:
1. 遗漏1024分辨率icon文件的,补上文件就ok了
2. 检查文件的alpha 和透明度
3. plist配置文件错误的。

经过仔细排查以上几点,都无果:
– 所有的AppIcon集合,都正常,只是提示这个1024的一直有问题,
– 用图片工具,确认过第二点,也没问题
– 配置的问题,多方搜索比较,也排查完了已有的问题,最后只剩下这个1024的问题

解决

后面根据字面意思:must be included in the Asset Catalog 进行猜测和尝试,最终得以解决:
建立新的Asset catalog,并将之前的AppIcon目录移过去,然后就ok了。所以之前虽然icon得以正确调用,能正确显示icon但实际的asset catalog配置是没通的,导致这个app store需要的1024 icon一直找不到。

以上方法,仅供片面参考!

com.apple.amp.itmstransporter 下载

  1. github上有相关资源,如果速度可以,可以直接从github上下载,直接搜索就可以找到。
  2. 对于github速度不给力的,做了一个国内的链接:https://gitee.com/hiproz/com.apple.amp.itmstransporter ,为了做源,6k左右的速度下载了将近2个小时,中间无数次断链,这也就是在xcode中无法直接一次成功的原因,实际上底层的操作已经中断了,所以等再久也没有用。