引言

  1. Xcode13新建项目不显示Products目录的解决方案
  2. Xcode13新建的工程恢复从前的Info.plist同步机制的方法
  3. 自动管理签名证书时拉取更新设备描述文件的方法。

I 显示Products目录的解决方案

问题:Xcode13 新建的项目不显示Products目录

解决方式: 修改project.pbxproj 文件的productRefGroup配置信息

效果:

iOS小技能:Xcode13的使用技巧_描述文件

应用场景:Products目录的app包用于快速打测试包。

1.1 从Xcodeeproj 打开project.pbxproj

iOS小技能:Xcode13的使用技巧_iOS_02

1.2 修改productRefGroup 的值

将mainGroup 对应的值复制给productRefGroup 的值,按command+s保存project.pbxproj文件,Xcode将自动刷新,Products目录显示出来了。

iOS小技能:Xcode13的使用技巧_iOS_03

1.3 应用场景

通过Products目录快速定位获取真机调试包路径,使用脚本快速打包。


打包脚本核心逻辑:在含有真机包路径下拷贝.app 到新建的Payload目录,zip压缩Payload目录并根据当前时间来命名为xxx.ipa。

#!/bin/bash
echo "==================(create ipa file...)=================="
# cd `dirname $0`;
rm -rf ./Target.ipa;
rm -rf ./Payload;
mkdir Payload;
APP=$(find . -type d | grep ".app$" | head -n 1)
cp -rf "$APP" ./Payload;
data="`date +%F-%T-%N`"
postName="$data"-".ipa"
zip -r -q "$postName" ./Payload;
rm -rf ./Payload;
open .
# 移动ipa包到特定目录
mkdir -p ~/Downloads/knPayload
cp -a "$postName" ~/Downloads/knPayload
open ~/Downloads/knPayload
echo "==================(done)=================="
exit;


II 关闭打包合并Info.plist功能

Xcode13之前​​Custom iOS Target Properties​​面板和Info.plist的配置信息会自动同步。

Xcode13新建的工程默认开启打包合并Info.plist功能,不再使用配置文件(Info.plist、entitlements),如果需要修改配置,直接在Xcode面板​​target - Info - Custom iOS Target Properties​​​和​​build settings​​中设置。

iOS小技能:Xcode13的使用技巧_描述文件_04

Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor.

2.1 设置Info.plist为主配置文件

由于GUI配置面板没有配置文件plist的灵活,不支持查看源代码。所以我们可以在​​BuildSetting ​​​ 将​​Generate Info.plist File​​设置为NO,来关闭打包合并功能。

iOS小技能:Xcode13的使用技巧_ios_05

关闭打包合并功能,重启Xcode使配置生效,​​Custom iOS Target Properties​​​面板的信息以​​info.plist​​的内容为准。

每次修改​​info.plist​​​都要重启Xcode,info.plist的信息才会同步到​​Custom iOS Target Properties​​面板。

iOS小技能:Xcode13的使用技巧_xcode_06

2.2 注意事项

注意: 关闭打包合并Info.plist功能 之前记得先手动同步​​Custom iOS Target Properties​​​面板的信息到​​Info.plist​

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>iOS逆向</string>
<key>CFBundleIdentifier</key>
<string>blog.csdn.net.z929118967</string>
<key>CFBundleName</key>
<string>YourAppName</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchScreen</key>
<dict>
<key>UILaunchScreen</key>
<dict/>
</dict>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

III 自动管理签名证书时如何拉取最新设备描述文件?

方法:根据描述文件的创建时间来删除旧的自动管理证书的描述文件


原理:在​​~/Library/MobileDevice/Provisioning\ Profiles ​​文件夹中删除之前的描述文件,然后系统检测到没有描述文件则会自动生成一个新的