pod repo remove cocoapods
pod repo remove master
iOS
pod常用格式
platform :ios, '13.0'
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
inhibit_all_warnings!
use_frameworks!
target 'test' do
pod 'appstore-card-transition'
pod 'SwifterSwift'
pod 'Kingfisher'
pod 'SwiftyJSON'
pod 'HandyJSON'
pod 'IQKeyboardManagerSwift'
end
安装cocoapods的两种方式
方式一:
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
gem sources -l
sudo gem install -n /usr/local/bin cocoapods //此命令既可以安装,也可以升级
方式二:
brew install cocoapods // 用此命令安装后,要去.zshrc中增加环境变量
安装之后,可以将仓库镜像替换为清华镜像:
pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
pod repo update
设置Xcode格式化代码快捷键
前提:安装XCFormat
升级到Xcode15后项目出现大量Duplicate symbols
升级到Xcode 15后,原先Xcode14可以编译的项目出现大量Duplicate symbols,且引用报错指向同一个路径(一般为Framework)下的同一个文件。经过查找相关解决,可通过
在Xcode -> Target -> Build Setting -> Other Linker Flags 添加一行"-ld64"
即可解决该问题
原因是Xcode15采用了新的链接器(Linker),被称作“ld_prime”。新的连接器有诸多好处,尤其是对合并库的支持方面,具体可以查看WWDC 2023 SESSION 10268 Meet mergeable libraries.。然而,链接器的升级可能会出现不兼容老库的情况出现。遇到这种情况,可以通过恢复旧的连接器来解决这个问题。从Other Linker Flags添加"-ld64"后,就会覆盖Xcode编译时选择的链接器,因此可以正常访问。
iOS杂记
验证正式环境的远程推送是否正常
可以用Ad Hoc的分发方式,打包上传蒲公英,然后安装到手机。
解决xcode14.3打包失败的问题
不必在用CertificateSigningRequest.certSigningRequest
iOS创建开发者证书,不需要再通过CertificateSigningRequest.certSigningRequest申请。应该直接用Xcode,window-organizer-选一个archive-distribute App-Development-next-Distribution certificate下拉框中选择manage Certificates-点加号即可新增一个证书。
Unwanted Communication Reporting Extension
Unwanted Communication Reporting Extension
骚扰电话报告拓展(不想要的通信报告拓展)
SMS and Call Spam Reporting
骚扰短信和骚扰电话上报
Create an app extension that lets users report unwanted SMS messages and calls as junk. 创建一个应用扩展程序,让用户将来电号码标记为骚扰电话并上报。
To report SMS messages and calls as spam, the user must enable an Unwanted Communication Reporting extension, called an SMS/Call Reporting extension in the Settings app (see Settings > Phone > SMS/Call Reporting).
要上报骚扰电话和短信,用户必须启用“骚扰电话报告拓展”,在手机设置中,找到“电话-短信/来电报告”,并勾选你想启用的“骚扰电话报告拓展”。
The user can only enable one Unwanted Communication Reporting extension at a time.
用户一次只能启用一个“骚扰电话报告拓展”。
In order to report calls, the user swipes left on an item in the Recents list and selects Report.
启用拓展之后,打开“电话”-“最近通话”,选择其中一个条目,向左滑动即可标记且上报。
For SMS messages, they press the Report Messages button when it appears in the Messages transcript. Users can also select messages by long-pressing a message and selecting additional messages, then selecting Report Messages.
至于短信,用户可以长按,然后点击“更多…”,然后点击“报告垃圾信息”,也可以在短信列表的底部,直接点击“报告所有垃圾信息”。
When the user reports an SMS message or call, the system launches your Unwanted Communication Reporting extension. Your extension gathers additional information from the user, before deciding whether to report or block the number, as shown in the figure below:
当用户上报骚扰电话和短信时,系统会启动“骚扰电话报告拓展”,在完成上报之前,你的扩展程序可以让用户填报更多信息,比如“外卖”“快递”“推销”等,如下图所示:
Specifically, the system:
1.Instantiates your extension’s ILClassificationUIExtensionViewController subclass;
2.Calls your controller’s prepare(for:) method and presents the controller to the user
Use your ILClassificationUIExtensionViewController subclass to gather data from the user. Override the prepare(for:) method to configure your controller.
具体来说,系统:
1.实例化子类:ILClassificationUIExtensionViewController;
2.调用控制器的prepare(for:)方法并将控制器呈现给用户,并从用户那里收集数据。
(你需要重写prepare方法来配置你的控制器)
The system provides a Cancel and a Done button for the controller. By default, the system disables the Done button.
系统为控制器提供了一个取消和完成按钮(如图),默认情况下,完成按钮是灰色的,无法点击。
As soon as the user has entered all the information you require, enable the Done button by setting the view controller’s isReadyForClassificationResponse property to true.
当用户选择了“外卖”“快递”“推销”等标签之后,你可以将isReadyForClassificationResponse设为true,然后“完成”按钮就可以点击了。
self.extensionContext.isReadyForClassificationResponse = true
If the user presses Done, the system calls your view controller’s classificationResponse(for:) method, passing in an ILClassificationRequest object (see the figure below)
如果用户点击“完成”,系统会调用控制器的classificationResponse方法,并传入一个对象(见下图):
Override the classificationResponse(for:) method to return a ILClassificationResponse based on the data the user has entered and information about the SMS message or call from the request object.
重写此方法,可返回一个ILClassificationResponse对象,此对象包含对应的来电/短信信息,也包含了当前页面收集到的数据信息。
The system takes different actions based on the response. For ILClassificationAction.none, the system dismisses your view controller, but doesn’t take any other action.
根据不同的ILClassificationResponse,系统会采取不同的行动。对于ILClassificationAction.none,系统将关闭页面,不执行任何其他操作。
For ILClassificationAction.reportNotJunk or ILClassificationAction.reportJunk, the system generates a report based on your response’s action and userInfo properties and then posts it to a network endpoint or sends it using an SMS message, depending on the keys specified in your extension’s Info.plist file.
对于ILClassificationAction.reportNotJunk或ILClassificationAction.reportJunk,系统将生成报告,然后将其通过网络端点发送,具体取决于您的扩展文件中指定的键。(也可以通过短信发送,这个操作太骚,此处故意忽略,不翻译)
To send a response over the network connection, you must add an associated domain to your extension. For general instructions, see Supporting associated domains. Note that you must use classificationreport instead of webcredentials when specifying the domains. You must also specify the network endpoint’s address using the ILClassificationExtensionNetworkReportDestination key in your extension’s Info.plist file.
要通过网络发送响应,您必须将关联域添加到您的扩展。至于什么是关联域,请参阅https://developer.apple.com/documentation/xcode/supporting-associated-domains。请注意,在指定域时,必须使用classificationreport而不是webcredentials。还必须在拓展应用的info.plist文件中使用ILClassificationExtensionNetworkReportDestination键指定网络端点的地址。
cocoapods
sudo gem update –system //首先更新gem,一般都很慢,毕竟服务器在国外 sudo gem install cocoapods // 安装cocoapods,此命令亦可用于升级cocoapods的版本 ------------------------------------ platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'AFNetworking', '~> 2.6' pod 'ORStackView', '~> 3.0' pod 'SwiftyJSON', '~> 2.3' end ------------------------------------ pod install