标签: xcode

如何修复 Xcode 中的“无法将索引文件重置为修订版本‘HEAD’”问题?

我正在尝试启动 Xcode,但收到一条警告:“\xe2\x80\x9cProject\xe2\x80\x9d 目前存在冲突。您想中止当前操作吗?我按中止键,然后收到此错误:

\n\n
\n

无法将索引文件重置为修订版“HEAD”。

\n
\n\n

我无法从存储库中提取数据,也无法签出其他分支。我尝试使用终端来修复此问题,但没有成功。

\n

xcode

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

具有用户选择的文件读写权限的 MacOS 应用程序被 Mac App Store 拒绝,因为 SQLite 在写入数据库时​​创建临时文件

我有一个 MacOS 应用程序,我想将其放在 Mac App Store 上,因此必须将其放入沙盒中。使用该应用程序,用户创建多个 SQLite 数据库文件来存储他们创建的信息,有点类似于 Excel 电子表格文件,但我在应用程序中利用 SQLite 来创建、读取和编辑文件。他们将这些文件存储在 Mac 上的 Documents 文件夹中。我为此添加了一项权利:com.apple.security.files.user-selected.read-write。\n该应用程序可以很好地读取这些数据库文件,但如果我尝试写入它们,则会失败。

\n\n

根据 Mac 控制台应用程序的日志,错误为:

\n\n
\n

沙箱:MyApp Helpe(16378) 拒绝(1) 文件写入创建\n /Users/steve/Documents/myFile1.sqlite-journal

\n\n

违规:拒绝(1)文件写入创建/Users/steve/Documents/myFile1.sqlite-journal

\n
\n\n

所以它失败了,因为 SQLite 在幕后创建了一个与访问的文件同名的临时文件,但通过向其附加“-journal”来更改扩展名。因此,如果用户打开一个名为 myFile1.sqlite 的文件,它会打开并读取正常,但如果他们尝试写入该文件,SQLite 将在该过程中创建一个名为 myFile1.sqlite-journal 的临时文件,然后将其删除。但由于用户没有打开或保存名为 myFile1.sqlite-journal 的文件,因此该文件不在沙箱中,因此被拒绝。

\n\n

我通过在 Finder 中创建一个名为 myFile1.sqlite-journal 的空文件并从我的应用程序中打开它(从而将其作为用户选择的文件添加到沙箱中)来确认这是问题所在,然后能够写入 myFile1.sqlite。

\n\n

这是一个已知问题,每个文档似乎都有一个使用“相关项目”的解决方案:\n https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth。 html。

\n\n

下面是相关文本,但这是我的第一个 Mac 应用程序,这些说明清晰如泥。和他们鬼混了好几天了,仍然不知道我应该做什么。下面提到了扩展,但 sqlite 没有设置扩展。您只需使用您想要的任何扩展名(比方说 .sqlite)。有人可以解释我需要添加哪些属性到 info.plist 中吗?

\n\n
\n

相关项目:

\n\n

应用程序沙箱的相关项目功能允许您的应用程序访问与用户选择的文件同名但扩展名不同的文件。此功能由两部分组成:应用程序 Info.plist 文件中的相关扩展列表和告诉沙箱您正在做什么的代码。

\n\n

有两种常见情况可以说明这一点:

\n\n

场景1:(与我的问题无关)

\n\n

场景 2:您的应用需要能够打开或保存多个具有相同名称和不同扩展名的相关文件(例如,自动打开与电影文件同名的字幕文件,或者允许 SQLite 日志文件)。 …

sqlite macos xcode mac-app-store swift

7
推荐指数
1
解决办法
1600
查看次数

如何将 float3 转换为 SIMD3<Float> (Xcode 11 Swift 5 对 float3 和 float4 给出折旧警告)

我试图让我的代码没有警告。因为我刚刚更新了 Xcode,并且知道收到警告信号。我也尝试在下面解决这个问题。

这是给我警告的代码:

代码:

extension float4x4 {
var translation: float3 {
    return float3(columns.3.x, columns.3.y, columns.3.z)
}

init(translation vector: float3) {
    self.init(float4(1, 0, 0, 0),
              float4(0, 1, 0, 0),
              float4(0, 0, 1, 0),
              float4(vector.x, vector.y, vector.z, 1))
 }
}

extension float4 {
  var xyz: float3 {
    return float3(x, y, z)
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

这是我尝试翻译的内容如下:

代码:

extension SIMD4 {
var translation: SIMD3<Float> {
    return SIMD3(columns.3.x, columns.3.y, columns.3.z)
}

  init(translation vector: SIMD3<Float>) {
    self.init(SIMD4<Float>(1, 0, 0, 0),
              SIMD4<Float>(0, 1, 0, 0),
              SIMD4<Float>(0, 0, 1, 0), …
Run Code Online (Sandbox Code Playgroud)

floating-point xcode swift

7
推荐指数
2
解决办法
3855
查看次数

swift 5 中没有这样的模块“FacebookCore”

我正在做自己的测试应用程序,作为 iOS 开发学习过程的一部分(在 Xcode 11.0 上使用 swift 5)。我想在我的登录页面上添加 Facebook 登录,但在导入库时我一直收到No such module 'FacebookCore'消息。

在此输入图像描述

我按照developer.facebook上的说明尝试使用cocoaPods实现SDK,这是我的Podfile

 # Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'TestApp' do

  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TestApp
  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'

  target 'TestAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'TestAppUITests' do
    # Pods for testing
  end

end
Run Code Online (Sandbox Code Playgroud)

按照 Facebook 的指示执行 …

xcode facebook-login cocoapods swift facebook-sdk-4.x

7
推荐指数
2
解决办法
7854
查看次数

UIEdgeInsets 不适用于 TabBar 中的系统图像

我正在使用 XCode 系统图像(SF 符号)作为UITabBarItem图像。我想删除UITabBarItem我已经完成的标题。但也要UITabBarItem稍微向下移动图像。

过去,当我不使用系统映像时,使用UIEdgeInsets. 但是,这似乎对系统映像没有影响。

代码:

let imageConfiguration = UIImage.SymbolConfiguration(weight: .regular)
    let imageInsets = UIEdgeInsets(top: 8, left: 0, bottom: -8, right: 0)

lazy var activityTabBarItem: UITabBarItem = {
        let image = UIImage(systemName: "stopwatch")?.applyingSymbolConfiguration(imageConfiguration)
        let tabBarItem = UITabBarItem(title: nil,
                                      image: image,
                                      selectedImage: image)
        tabBarItem.imageInsets = imageInsets
        return tabBarItem
    }()
Run Code Online (Sandbox Code Playgroud)

有解决方法吗?

xcode uitabbaritem uiedgeinsets swift sf-symbols

7
推荐指数
1
解决办法
587
查看次数

如何删除Podfile.lock?

Xcode 最近更新了,我的代码在 STPAPIClient.m 中给出了此错误:

Incompatible block pointer types sending '__strong STPAPIResponseBlock _Nonnull' (aka 'void (^__strong)(__strong ResponseType, NSHTTPURLResponse *__strong, NSError *__strong)') to parameter of type 'void (^)(STPSource *__strong, NSHTTPURLResponse *__strong, NSError *__strong)'
Run Code Online (Sandbox Code Playgroud)

编辑:我找到了 podfile.lock,但每次删除它并安装 pod 时,我都会检查项目目录,Podfile.lock 仍然存在。有谁知道如何删除它?谢谢!

xcode cocoapods swift podfile-lock

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

尝试在 Swift 中使用 API 连接时出现 SSL 错误

有人可以告诉我为什么会出现以下连接错误吗?我可以通过浏览器访问 API URL,但是当我的应用程序尝试建立连接时,会出现错误。是我的网络吗?我的机器上需要某种证书吗?

在此输入图像描述

已完成,但出现错误 [-1200] 错误域=NSURLErrorDomain 代码=-1200“发生 SSL 错误,无法与服务器建立安全连接。”

ssl xcode ssl-certificate ios swift

7
推荐指数
2
解决办法
3693
查看次数

如何将旧版本的 Xamarin.iOS 与 Visual Studio Mac 结合使用?

您好,我错误地将 Visual Studio for Mac 升级到 8.5.2(内部版本 13),其中 Xamarin.iOS 版本:13.16.0.13(Visual Studio 社区)。

事实证明,这不适用于 XCode 11.3.1,需要 XCode 11.4,这意味着我需要将操作系统从 Mojave 升级到 Catalina;我还没有准备好升级操作系统..

我尝试在 Microsoft 网站上搜索,但看不到任何明显的降级或选择其他 Xamarin.iOS 版本的链接

如何将 Xamarin.iOS 回滚到与 XCode 11.3 兼容的版本?

xcode xamarin.ios visual-studio-mac macos-mojave macos-catalina

7
推荐指数
1
解决办法
3403
查看次数

取消向后滑动时,SwiftUI 应用程序冻结并占用 100% CPU

以下代码可能会使正在运行的应用程序在 iPhone(不是 iPad)或 iPhone 模拟器上无响应。Xcode 显示应用程序消耗 100% CPU,同时分配越来越多的内存。

struct SecondView: View {
    @State private var keyboardHeight: CGFloat = 0

    private let showPublisher = NotificationCenter.Publisher.init(
        center: .default,
        name: UIResponder.keyboardWillShowNotification
    ).map { (notification) -> CGFloat in
        if let rect = notification.userInfo?["UIKeyboardFrameEndUserInfoKey"] as? CGRect {
            return rect.size.height
        } else {
            return 0
        }
    }

    var body: some View {
        VStack(spacing: 20) {
            if keyboardHeight == 0 {
                Text("This is shown as long as there's no keyboard")
            }
            Text("This is the SecondView. Drag from …
Run Code Online (Sandbox Code Playgroud)

crash xcode freeze ios swiftui

7
推荐指数
1
解决办法
1060
查看次数

GitHub 操作 IOS xcode QA/Staging 以及证书和配置文件的问题

我正在使用 xcode 11.3 的 IOS 的 GitHub 操作。我能够构建、导出存档并推送到开发环境的应用程序中心。但是,我在暂存/QA 环境中遇到错误。

如果我提供与暂存/QA 中的开发环境相同的证书和配置文件,我在导出存档时会收到错误(构建成功):-

#Export Archives
##[error]Process completed with exit code 70.
Run xcodebuild -exportArchive -archivePath abc.xcarchive -exportPath abc.ipa -exportOptionsPlist ./abc/ExportOptions.plist          
2020-04-16 15:57:11.154 xcodebuild[7404:37990] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/abcStaging_2020-04-16_15-57-11.153.xcdistributionlogs'.
error: exportArchive: No profiles for 'com.abc.Staging' were found
** EXPORT FAILED **

Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.abc.Staging' were found" UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=No profiles for 'com.abc.Staging' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.abc.Staging'. Automatic …
Run Code Online (Sandbox Code Playgroud)

xcode github ios github-actions

7
推荐指数
1
解决办法
2955
查看次数