uni-app iOS打包自定义基座失败

发布于 1周前 作者 yuanlaile 来自 Uni-App

uni-app iOS打包自定义基座失败

操作步骤:

  • 开始iOS uts插件使用到了import { NSURLConnection, URLRequest, URLSession, Data } from ‘Foundation’;这些库,在info和.entitlements文件也有申请了NSAppTransportSecurity和NSAllowsArbitraryLoads的权限

预期结果:

  • 打自定义基座成功

实际结果:

  • 打自定义基座失败

bug描述:

  • Appid: UNI D94028D
  • Command line invocation:
    • /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild archive -sdk iphoneos17.5 -project [PackagePath]/HBuilder.xcodeproj -archivePath [PackagePath]/XArchive/HBuilder.xcarchive -scheme HBuilder -configuration Debug
  • User defaults from command line:
    • IDEArchivePathOverride = [PackagePath]/XArchive/HBuilder.xcarchive
    • IDEPackageSupportUseBuiltinSCM = YES
  • Build settings from command line:
    • SDKROOT = iphoneos17.5
  • Prepare packages
  • ComputeTargetDependencyGraph
  • note: Building targets in dependency order
  • note: Target dependency graph (1 target)
  • Target ‘HBuilder’ in project ‘HBuilder’ (no dependencies)
  • GatherProvisioningInputs
  • CreateBuildDescription
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk -x objective-c -c /dev/null
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk -x c -c /dev/null
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --version --output-format xml1
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --print-asset-tag-combinations --output-format xml1 [PackagePath]/HBuilder/Assets.xcassets
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --version --output-format xml1
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -v
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk -x c -c /dev/null
  • ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details
  • Build description signature: e611d5944db997287e0de14a1747b7d6
  • Build description path: /Users/[Name]/Library/Developer/Xcode/DerivedData/HBuilder-dnrjcsjbyzeyuofltmkqwdrerbhr/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/IntermediateBuildFilesPath/XCBuildData/e611d5944db997287e0de14a1747b7d6.xcbuilddata
  • [PackagePath]/HBuilder.xcodeproj: error: Provisioning profile “IOSUniAppProfile” doesn’t include the NSAllowsArbitraryLoads and NSAppTransportSecurity entitlements. Profile qualification is using entitlement definitions that may be out of date. Connect to network to update.
  • warning: Run script build phase ‘Run Script’ will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking “Based on dependency analysis” in the script phase.
  • — xcodebuild: WARNING: Using the first of multiple matching destinations:
  • { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
  • { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008112-001408E93AA3401E, name:My Mac }
  • { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
  • { platform:iOS Simulator, id:A66E81EE-FC0D-43CC-A8DE-2276E3EEAEFF, OS:17.2, name:iPad (10th generation) }
  • { platform:iOS Simulator, id:A66E81EE-FC0D-43CC-A8DE-2276E3EEAEFF, OS:17.2, name:iPad (10th generation) }
  • { platform:iOS Simulator, id:375629A7-6907-42C0-8CD3-B59E4434D358, OS:17.5, name:iPad (10th generation) }
  • { platform:iOS Simulator, id:375629A7-6907-42C0-8CD3-B59E4434D358, OS:17.5, name:iPad (10th generation) }
  • { platform:iOS Simulator, id:4A2DA7F5-22B8-48BC-BA63-0ABB4F4D743E, OS:17.2, name:iPad Air (5th generation) }
  • { platform:iOS Simulator, id:4A2DA7F5-22B8-48BC-BA63-0ABB4F4D743E, OS:17.2, name:iPad Air (5th generation) }
  • { platform:iOS Simulator, id:C1BF841D-D72E-4D99-9E34-054A96A5B277, OS:17.5, name:iPad Air 11-inch (M2) }
  • { platform:iOS Simulator, id:C1BF841D-D72E-4D99-9E34-054A96A5B277, OS:17.5, name:iPad Air 11-inch (M2) }
  • { platform:iOS Simulator, id:507BAEA4-B802-4E61-97C9-520CE1BBB068, OS:17.5, name:iPad Air 13-inch (M2) }
  • { platform:iOS Simulator, id:507BAEA4-B802-4E61-97C9-520CE1BBB068, OS:17.5, name:iPad Air 13-inch (M2) }
  • { platform:iOS Simulator, id:36CA859E-4C3F-4A09-8BA6-F1693CE3F2B3, OS:17.2, name:iPad Pro (11-inch) (4th generation) }
  • { platform:iOS Simulator, id:36CA859E-4C3F-4A09-8BA6-F1693CE3F2B3, OS:17.2, name:iPad Pro (11-inch) (4th generation) }
  • { platform:iOS Simulator, id:1D4DB61E-9556-4F6A-92E5-90E94516F22C, OS:17.2, name:iPad Pro (12.9-inch) (6th generation) }
  • { platform:iOS Simulator, id:1D4DB61E-9556-4F6A-92E5-90E94516F22C, OS:17.2, name:iPad Pro (12.9-inch) (6th generation) }
  • { platform:iOS Simulator, id:63223F2D-6521-47BE-BA37-E347539E6889, OS:17.5, name:iPad Pro 11-inch (M4) }
  • { platform:iOS Simulator, id:63223F2D-6521-47BE-BA37-E347539E6889, OS:17.5, name:iPad Pro 11-inch (M4) }
  • { platform:iOS Simulator, id:26C24D2D-1759-417B-A389-E9B34C58F398, OS:17.5, name:iPad Pro 13-inch (M4) }
  • { platform:iOS Simulator, id:26C24D2D-1759-417B-A389-E9B34C58F398, OS:17.5, name:iPad Pro 13-inch (M4) }
  • { platform:iOS Simulator, id:5A1E9A9A-2D18-4E7B-AED5-58A77814B8F8, OS:17.2, name:iPad mini (6th generation) }
  • { platform:iOS Simulator, id:5A1E9A9A-2D18-4E7B-AED5-58A77814B8F8, OS:17.2, name:iPad mini (6th generation) }
  • { platform:iOS Simulator, id:8434BFB8-54C6-453A-B795-26A5BFECACB1, OS:17.5, name:iPad mini (6th generation) }
  • { platform:iOS Simulator, id:8434BFB8-54C6-453A-B795-26A5BFECACB1, OS:17.5, name:iPad mini (6th generation) }
  • { platform:iOS Simulator, id:C96D540B-E769-4C13-8E87-8697329D4728, OS:17.2, name:iPhone 15 }
  • { platform:iOS Simulator, id:C96D540B-E769-4C13-8E87-8697329D4728, OS:17.2, name:iPhone 15 }
  • { platform:iOS Simulator, id:C7A2AEA6-FD2E-435A-9828-6278F3DB9ADF, OS:17.5, name:iPhone 15 }
  • { platform:iOS Simulator, id:C7A2AEA6-FD2E-435A-9828-6278F3DB9ADF, OS:17.5, name:iPhone 15 }
  • { platform:iOS Simulator, id:41FF3AEA-F95F-4EC7-9932-0CD6714535D1, OS:17.2, name:iPhone 15 Plus }
  • { platform:iOS Simulator, id:41FF3AEA-F95F-4EC7-9932-0CD6714535D1, OS:17.2, name:iPhone 15 Plus }
  • { platform:iOS Simulator, id:AC1299D1-1F78-42DC-B94C-277628DCCDFC, OS:17.5, name:iPhone 15 Plus }
  • { platform:iOS Simulator, id:AC1299D1-1F78-42DC-B94C-277628DCCDFC, OS:17.5, name:iPhone 15 Plus }
  • { platform:iOS Simulator, id:C6AF505A-BBE8-4669-8A36-27821F62A0E1, OS:17.2, name:iPhone 15 Pro }
  • { platform:iOS Simulator, id:C6AF505A-BBE8-4669-8A36-27821F62A0E1, OS:17.2, name:iPhone 15 Pro }
  • { platform:iOS Simulator, id:30F5DBAF-B5D6-462D-87A7-CE1F79FEB7C7, OS:17.5, name:iPhone 15 Pro }
  • { platform:iOS Simulator, id:30F5DBAF-B5D6-462D-87A7-CE1F79FEB7C7, OS:17.5, name:iPhone 15 Pro }
  • { platform:iOS Simulator, id:60596786-6C3E-4529-9734-417B37D53A5B, OS:17.2, name:iPhone 15 Pro Max }
  • { platform:iOS Simulator, id:60596786-6C3E-4529-9734-417B37D53A5B, OS:17.2, name:iPhone 15 Pro Max }
  • { platform:iOS Simulator, id:A5028598-3FC6-46E7-AFCE-7CEC9713E217, OS:17.5, name:iPhone 15 Pro Max }
  • { platform:iOS Simulator, id:A5028598-3FC6-46E7-AFCE-7CEC9713E217, OS:17.5, name:iPhone 15 Pro Max }
  • { platform:iOS Simulator, id:7DDCD2C3-00A2-4EC6-98B3-83D31A938CAD, OS:17.2, name:iPhone SE (3rd generation) }
  • { platform:iOS Simulator, id:7DDCD2C3-00A2-4EC6-98B3-83D31A938CAD, OS:17.2, name:iPhone SE (3rd generation) }
  • { platform:iOS Simulator, id:FF00A80D-30A7-411B-A8D7-06087A911FA1, OS:17.5, name:iPhone SE (3rd generation) }
  • { platform:iOS Simulator, id:FF00A80D-30A7-411B-A8D7-06087A911FA1, OS:17.5, name:iPhone SE (3rd generation) }
  • ARCHIVE FAILED

6 回复

你没有在苹果后台勾选开启NSAllowsArbitraryLoads和NSAppTransportSecurity对应的能力,开启后重新生成profile文件再提交云端打包。 关键错误信息: error: Provisioning profile “IOSUniAppProfile” doesn’t include the NSAllowsArbitraryLoads and NSAppTransportSecurity entitlements.


您好,请问我在苹果后台那具体勾选哪个Capabilities,我没有看到NSAllowsArbitraryLoads和NSAppTransportSecurity的介绍,谢谢回答!

我在4.24版本打自定义基座是没有问题的,更新到4.32-alpha就出问题了

NSAppTransportSecurity数据是配置在Inf.plist文件中,不要在uts插件的UTS.entitlements中配置NSAppTransportSecurity数据。 UTS.entitlements中只能配置Capabilities相关的能力数据。

好了,现在能够打包了,谢谢!

在解决uni-app iOS打包自定义基座失败的问题时,通常涉及到几个关键步骤和配置文件的检查。以下是一些常见的排查步骤和代码示例,帮助你定位并解决问题。

1. 检查Xcode环境

首先确保你的Xcode版本符合uni-app的要求。你可以在uni-app的官方文档中查找支持的Xcode版本。

# 查看Xcode版本
xcodebuild -version

2. 验证uni-app项目配置

确保你的manifest.json文件中的iOS配置正确无误。以下是一个示例配置:

{
  "mp-weixin": {},
  "app-plus": {
    "name": "your-app-name",
    "distribute": {
      "ios": {
        "bundleIdentifier": "com.yourcompany.yourapp",
        "appid": "your-app-id",
        "provisioningProfile": "path/to/your/provisioning/profile",
        "developmentTeam": "your-development-team-id"
      }
    }
  }
}

3. 自定义基座配置

如果你正在使用自定义基座,确保你已经正确配置了基座信息。在HBuilderX中,你可以通过以下步骤创建和配置自定义基座:

  • 打开HBuilderX,选择“发行” -> “原生App-云打包”。
  • 点击“制作自定义基座”,并填写相关信息。
  • 确保基座证书(.p12文件)和配置文件(.mobileprovision文件)路径正确。

4. 清理和重建项目

在Xcode中,尝试清理(Clean)和重建(Build)项目。

# 在Xcode的终端中执行以下命令
xcodebuild clean
xcodebuild -project YourProjectName.xcodeproj -scheme YourSchemeName -configuration Release

5. 检查日志输出

在Xcode中运行项目,并查看控制台输出日志,寻找可能的错误信息。

6. 更新依赖和插件

确保所有依赖和插件都是最新的,特别是与iOS相关的依赖。

# 更新npm依赖
npm update

# 如果你使用了CocoaPods,也更新一下
pod install

7. 重新生成Provisioning Profile

有时候,Provisioning Profile可能会过期或配置不正确。确保你的Provisioning Profile是最新的,并且与你的App ID、证书和开发团队匹配。

结论

如果以上步骤都无法解决问题,建议查看uni-app的官方社区或提交issue,可能是一个已知的问题或需要更具体的帮助。在提交问题时,提供详细的错误日志和配置信息将有助于快速定位问题。

回到顶部