在Xcode中运行Release版本的应用程序,通常是为了在发布前测试其性能和稳定性。Release模式会启用代码优化、移除调试信息并禁用断言,从而生成更小、更快的二进制文件。以下是具体操作步骤:
- 切换到Release构建配置
打开Scheme编辑器:点击Xcode顶部工具栏中的产品名称(通常显示为你的应用名称,如“YourApp”),然后选择“Edit Scheme...”。
选择运行配置:在弹出的Scheme编辑器左侧列表中,选择“Run”。
更改构建配置:在右侧的“Build Configuration”下拉菜单中,选择“Release”。
关闭编辑器:点击“Close”按钮。
运行应用 - 在 Xcode 项目中配置 Release 签名
手动配置证书或者自动配置证书
手动配置证书:
打开你的 Xcode 项目。
在项目导航器中,点击顶部的项目名称,进入“General”设置页。
确保左上角的 “Release” 配置被选中(通常在“Configurations”下拉菜单中)。
向下滚动到 “Signing & Capabilities” 区域。
确保 “Team” 已选择你的开发者账号。
在 “Signing Certificate” 部分,Xcode 通常会自动选择正确的发布证书。若未自动选择,可手动点击下拉菜单,选择“iOS Distribution”证书。
在 “Provisioning Profile” 部分,手动选择你之前导入的发布描述文件(如“App Store”或“Ad Hoc”类型)。
Xcode的BuildSettings里面
signing的code signingidentiy和Provisioning Profile设置对的证书和Provisioning Profile
3.完成上述配置后,你可以像平常一样运行应用:
快捷键:按下 Cmd + R。
菜单栏:点击顶部菜单栏的“Product” > “Run”。
此时,Xcode将使用Release配置编译并运行你的应用。请注意,由于Release模式下断言被禁用且代码经过优化,你将无法在Release版本中正常使用断点进行调试。如果需要调试,应切换回Debug模式
xcode运行release报错:Ensure “SuperLivePlus” is not already running, and fangfangcheng has permission to debug it.,控制台打印:error: attach by pid '767' failed -- attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)


之前debug是勾选Debug executable

Scheme切换到Release,不勾选Debug executable, Xcode运行release就不报错了
