标签: xcode14

图表无法在 Xcode 14 上编译

我在图书馆中面临以下错误 -

  • 类型“ ChartDataSet ”不符合协议“ RangeReplaceableCollection

  • 使用不可用的实例方法“ replaceSubrange(_:with:) ”来满足协议“ RangeReplaceableCollection ”的要求。

charts xcode ios swift xcode14

29
推荐指数
1
解决办法
2万
查看次数

Xcode 14 和 Bitcode 禁用后应用程序大小增加(几乎翻倍)

Apple 已弃用 Bitcode,并不再接受从 Xcode 14 开始使用启用 Bitcode 的应用程序的任何提交。我们 PhonePe 禁用了Bitcode并将应用程序上传到 App Store,通过 Xcode 14 连接,现在看到应用程序大小大幅增加。189 MB从(启用 Xcode 13 和 Bitcode)到使用 Xcode 14 ,应用程序的大小几乎增加了一倍342 MB

\n

有没有人面临类似的问题或有任何解决方案来减小应用程序的大小?

\n
\n

弃用

\n
    \n
  • 从 Xcode 14 开始,watchOS 和 tvOS 应用程序不再需要位码,并且 App Store 不再接受来自 Xcode 14 的位码提交。

    \n
  • \n
  • 如果项目显式启用位码,Xcode 不再默认构建位码并生成警告\n消息:\xe2\x80\x9cBuilding with\nbitcode 已被弃用。请更新您的项目和/或目标设置以禁用位码。\xe2\x80\x9d 使用位码构建的功能\n将在未来的 Xcode 版本中删除。包含位码的 IPA\n将在提交到 App\nStore 之前删除位码。过去提交的位码的调试符号仍然可供\n下载。(86118779)

    \n
  • \n
  • 由于位码现已弃用,因此 iOS、tvOS 和 watchOS 的构建\n默认情况下不再包含位码。(87590506)

    \n
  • \n
\n
\n

xcode ios swift bitcode xcode14

26
推荐指数
1
解决办法
3213
查看次数

为什么清除新的 iOS 16 SwiftUI NavigationPath 到“弹出到根目录”时不能平滑地返回到根视图?

我有一个新的 iOS 16 SwiftUI NavigationStack,其导航由 NavigationDestination 修饰符确定,效果很好。

我的问题是,如果您在堆栈深处有多个视图,那么在清除 NavigationPath 时,为什么它不能通过滑回根视图来平滑地进行动画处理?

如果您只有一层深度,它会起作用,但任何低于该深度的内容都会导致“弹出到根”仅跳回到根视图而没有滑动动画。

这是一个“功能”还是错误,还是我做错了什么?

重新创建问题的步骤

  • 运行下面的示例代码。
  • 单击第一个导航链接,然后单击“弹出到根视图” - 请注意,它“平滑地”滑回到根视图。
  • 单击第一个或第二个链接 - 然后单击显示视图 3 的“导航到视图 3”。
  • 然后单击“Pop to Root”,您会注意到它跳回到根视图而不是幻灯片。这就是我的问题——它应该跳回来还是滑回来?

发行演示

在此输入图像描述

演示代码(使用 Xcode 14.0 和 iOS 16.0):

import SwiftUI
struct DemoPop: View {

    @State private var path = NavigationPath()
    
    var body: some View {
        
        VStack {
            
            NavigationStack(path: $path) {
                   
                List {
                    Section("List One") {
                        NavigationLink("Navigate to View 1", value: "View 1")
                        NavigationLink("Navigate to View 2", value: "View 2")
                    }
                }
                .navigationDestination(for: String.self) …
Run Code Online (Sandbox Code Playgroud)

swiftui ios16 xcode14 swiftui-navigationstack

25
推荐指数
2
解决办法
5520
查看次数

Xcode 14.1:错误:UINavigationBar 解码为 UINavigationController 未锁定,或 navigationBar 委托设置不正确。?

这是什么意思 ?我还没有在我的项目中添加 UINavigationBar 。UINavigationController通过编辑器->嵌入->导航控制器嵌入。

[断言] UINavigationBar 解码为 UINavigationController 未锁定,或 navigationBar 委托设置不正确。配置不一致可能会导致问题。导航控制器=<UINavigationController:0x13b80c600>,导航栏=<UINavigationBar:0x13b5079f0;帧=(0 0;0 50);不透明=否;自动调整大小=W;层=<CALayer:0x600000f56620>>委托=0x13b80c600

xcode ios xcode14

22
推荐指数
0
解决办法
1万
查看次数

如何使用 iOS16 删除 SwiftUI Plain List 中的节标题顶部填充

当我们使用 SwiftUI List 组件并需要一个节标题时,顶部填充将出现在每个节的标题上。

iOS15下,我们用它UITableView.appearance().sectionHeaderTopPadding = 0来解决这个问题。查看附件iOS15&Xcode14构建截图。

但在iOS16中,这个设置似乎不起作用。查看附件iOS16&Xcode14构建截图,滚动时:iOS16&Xcode14构建滚动

所以,我的问题是如何在iOS16中删除节标题顶部填充,并且当滚动列表时,其节标题将被固定,就像附件iOS15&Xcode14构建滚动一样。

从iOS16开始,SwiftUI List组件似乎使用UICollectionView而不是UITableView,所以我尝试通过全局设置UICollectionView的section top padding来解决这个问题。不幸的是,我没有找到设置 UICollectionView 的部分顶部填充的方法。

我的代码如下。

//
//  ContentView.swift
//  ListIniOS16
//
//  Created by Eric on 2022/07/23.
//

import SwiftUI

struct ContentView: View {
    @State private var collections: [ListData] = ListData.collection

    init() {
        let appBarTheme = UINavigationBarAppearance()
        appBarTheme.configureWithOpaqueBackground()
        appBarTheme.backgroundColor = UIColor(.gray)
        UINavigationBar.appearance().standardAppearance = appBarTheme
        UINavigationBar.appearance().scrollEdgeAppearance = appBarTheme
        if #available(iOS 15.0, *) {
            // can fix sectionHeaderTopPadding issue in iOS15, …
Run Code Online (Sandbox Code Playgroud)

swiftui swiftui-list ios16 xcode14

21
推荐指数
1
解决办法
5467
查看次数

Xcode 14 单元测试克隆模拟器

在 Xcode 14 中,运行单元测试似乎是在创建模拟器“克隆”(名为“iPhone 的克隆 1/2..”)。在较旧的机器上,这可能需要很长时间。每次从运行应用程序切换到运行测试时都会发生这种情况。例如,运行应用程序将启动模拟器。运行测试将启动新的一个或多个模拟器(...的克隆),再次运行应用程序将重新加载原始模拟器。
有什么办法可以控制这个吗?这使得在旧机器上运行测试变得非常痛苦。

xcode14

21
推荐指数
1
解决办法
3641
查看次数

'init(destination:isActive:label:)' 在 iOS 16.0 中已弃用:在 NavigationStack 或 NavigationSplitView 中使用 NavigationLink(value:label:)

我已经尝试了该网站上发布的示例的不同版本,但没有任何进展。

我也尝试过遵循此处列出的示例:

导航到新的导航类型:

我在这篇文章的标题中收到关于弃用 NavigationLink(destination:isActive) 的警告

struct PhoneLogin: View {
    @StateObject var phoneLoginData = PhoneLoginViewModel()
    @State var isSmall = UIScreen.main.bounds.height < 750
    
    var body: some View {
        VStack {
            VStack {
                Text("Continue With Phone")
                    .font(.title2)
                    .fontWeight(.bold)
                    .foregroundColor(.black)
                    .padding()
                
                Image("phone_logo")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .padding()
                
                Text("You'll receive a 4-digit code \n to verify next")
                    .font(isSmall ? .none : .title2)
                    .foregroundColor(.gray)
                    .multilineTextAlignment(.center)
                    .padding()
                
                // Mobile Number Field . . . . .
                
                HStack {
                    VStack(alignment: .leading, spacing: 6) {
                        Text("Enter Your Number")
                            .font(.caption) …
Run Code Online (Sandbox Code Playgroud)

deprecation-warning swiftui-navigationlink ios16 xcode14

21
推荐指数
1
解决办法
1万
查看次数

并发执行代码中捕获的 var 的突变

我在 Swift 5.5 中遇到了问题,但我不太明白解决方案。

import Foundation

func testAsync() async {

    var animal = "Dog"

    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        animal = "Cat"
        print(animal)
    }

    print(animal)
}

Task {
    await testAsync()
}
Run Code Online (Sandbox Code Playgroud)

这段代码会导致错误

Mutation of captured var 'animal' in concurrently-executing code
Run Code Online (Sandbox Code Playgroud)

但是,如果将animal变量移离此异步函数的上下文,

import Foundation

var animal = "Dog"

func testAsync() async {
    
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        animal = "Cat"
        print(animal)
    }

    print(animal)
}

Task {
    await testAsync()
}
Run Code Online (Sandbox Code Playgroud)

它会编译。我知道这个错误是为了防止数据竞争,但为什么移动变量会使其安全?

async-await swift xcode14

20
推荐指数
2
解决办法
1万
查看次数

使用 Xcode14 编译时,出现错误:不支持 Swift 架构。怎么解决这个问题呢?

切换到 xcode 14 构建系统后。为我们的 pod 框架生成的标头开始看起来像这样:

#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
... bridging for arm64
#else
#error unsupported Swift architecture
#endif
#if 0
#elif defined(__x86_64__) && __x86_64__
// Generated by Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
... bridging for x86
#else
#error unsupported Swift architecture
#endif
Run Code Online (Sandbox Code Playgroud)

如果我查看标题,我会看到以下场景:

arm64 已定义且 x86 已定义 - 应该没问题 arm64 已定义而 x86 未定义 - 应该是错误 arm64 未定义而 x86 已定义 - 应该是错误 因此为了避免错误,应定义两种架构。这会导致客户端应用程序构建失败并出现错误:错误不支持的 Swift 架构。

即使 ONLY_ACTIVE_ARCH …

xcode build ios swift xcode14

20
推荐指数
2
解决办法
1万
查看次数

Xcode 14 - 无法进行代码签名,因为目标没有 Info.plist 文件

我在我的项目中使用cocoapods,它工作正常,但升级到 Xcode 14 后,它给出了不同的类型或错误。

首先它要求提供位代码,后来要求开发团队提供,我使用 podfile 中的以下脚本解决了这个问题

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      #config.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
      config.build_settings['ENABLE_BITCODE'] = 'YES'
      config.build_settings["DEVELOPMENT_TEAM"] = " Your Team ID "
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

解决这些错误后,另一个错误开始出现,即

错误构建:无法进行代码签名,因为目标没有 Info.plist 文件并且不会自动生成。使用 INFOPLIST_FILE 构建设置将 Info.plist 文件应用到目标,或者通过将 GENERATE_INFOPLIST_FILE 构建设置设置为 YES(推荐)来自动生成一个 Info.plist 文件。

我的豆荚已更新,可可豆荚版本是1.11.3。我该如何解决这个错误?

编辑:

这里提到了一些细节,但没有一个对我有用。

cocoapods xcode14

18
推荐指数
2
解决办法
2万
查看次数