I downloaded a sample project from here(haptic sampler) and I cannot run because of several issues.
I solved signing identifier.
The error messages say:
~/PlayingACustomHapticPatternFromAFile/HapticSampler/ViewController.swift:66:19: Type 'CHHapticEngine.StoppedReason' has no member 'gameControllerDisconnect'
~/PlayingACustomHapticPatternFromAFile/HapticSampler/ViewController.swift:68:19: Type 'CHHapticEngine.StoppedReason' has no member 'engineDestroyed'
if I delete these parts, another error says:
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Here are my questions.
Do same issues happen to you?
How can I fix this problem?
Here's my environment specification.
macOS Catalina 10.15.6
Xcode 11.6
iPhone 7 iOS 13.6
Haptic feedback needs an actual device since it uses a vibration motor. It can not be run on a simulator. That is why you are getting the error message "Failed to create engine!". To fix it connect to an actual device and select a team in "Signing & Capabilities" and run.
The problem is that the enum cases
.gameControllerDisconnect
And
.engineDestroyed
Were introduced in iOS 14, Xcode 12 beta. But you are running an earlier version so, as the error message says, they don’t exist.
Replace the following lines of ViewController.swift Line 48 in the createEngine() function.
if engine == nil {
print("Failed to create engine!")
}
With:
guard let engine = engine else {
print("Failed to create engine!")
return
}
That should resolve the compile + runtime errors you're currently getting
Related
[default] LSPrefs: could not find untranslocated node for <FSNode 0x600003002ae0> { isDir = ?, path = '/private/var/folders/k7/zdtfstr13gxcrwg98wc0k1dm0000gn/X/14ADFEAC-68C8-59CF-AC5B-21F464164A42/d/Wrapper/Dicee-iOS13.app' }, proceeding on the assumption it is not translocated: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
I am getting similar messages in the console when running an iOS app from XCode on the target myMac (Designed for iPad).
However, as far as I am concerned, this is just a warning that does not prevent the app from running.
More information on translocation here: https://eclecticlight.co/2021/04/19/ios-apps-are-translocated-when-run-in-macos/
I also had a similar error on the target My Mac (Designed for iPad).
M1 Mac, Xcode 14.0.1, MacOS Monterrey 12.6.
The app builds fine on all other targets. It started crashing on the Mac target when I added MKLookAroundViewController to the storyboard, as shown at 36:00 in https://developer.apple.com/videos/play/wwdc2022/10035/
To solve this, I deleted the Look Around view controller from the storyboard and added it programmatically instead.
FaceID allows storage of credentials but not retrival. I'm seeing this error when inspecting via the xcode console. If I run the same code from xcode locally everything works fine.
returned Error Domain=com.apple.LocalAuthentication Code=-1004 "Caller is not running foreground."
To make it even more strange if I install a different version from testflight and then reinstall the original broken version it starts working again.
We've encountered this error as well in our app, but as it turned out, it was caused by having multiple apps with the same Product Name on one device.
In our case this means that we will not have this on our live app, but this came up on devices of our tester.
This error always comes up for me as -1004 so I added a check to my error handling block like this:
...
if let error = authError as? LAError {
if (error.code.rawValue == -1004) { //bizarre facial recognition error
completion(true, //do some code..)
}
completion(false, error)
}...
works on my production application
I have a very strange problem with UIDocumentBrowserViewController when testing on iOS 13. The importHandler(newDocumentURL, .move) seems to crash without any reason :
[DocumentManager] Cannot create urlWrapper for url file:///.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt.
error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt':
Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt': Invalid argument}.
Here is a two step process to reproduce :
Create a new Xcode project "Document Based App"
Type in this code in the documentBrowser(_: , didRequestDocumentCreationWithHandler:)
let newDocumentURL: URL? =
URL(fileURLWithPath: NSTemporaryDirectory())
.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("txt")
// Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler.
// Make sure the importHandler is always called, even if the user cancels the creation request.
if newDocumentURL != nil {
print(newDocumentURL!)
try! "My file content".write(to: newDocumentURL!, atomically: true, encoding: .utf8)
importHandler(newDocumentURL, .move)
} else {
importHandler(nil, .none)
}
Launch it on an iOS 13 simulator, create a new document, and the error is printed out and nothing else happens.
If you execute the same code on iOS 12, it perfectly works, the file is moved and is opened by the app.
The problem occurs on iOS 13 beta 7, wether it's compiled by Xcode 11 beta 7 or Xcode 10.3
Any idea?
EDIT: The problem still occurs when you create the file in the document directory instead of the temporary directory :
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
EDIT 2: The problem still exists with Xcode 11 GM (11A419c)
EDIT 3: The problem persists only the simulator. On device with iOS 13 GM, UIDocumentBrowserViewController works as expected.
EDIT 4: Problem still present on simulators with official Xcode 11 release 11A420a (aka GM Seed 2.)
EDIT 5: Problem only occurs on Mojave and seems to be absent on Catalina
I've verified that the bug exists with Xcode 11.1 GM running on Mac OS Mojave.
The issue does not occur when running on Catalina Beta 9. (FWIW I ran Catalina Beta 9 in a Parallels virtual machine because I don't know if it is stable enough to upgrade to for production work.)
Looking for workarounds, will post if I find any (but note this is not my area of expertise, just proceeded on a hunch that turned out to be correct.)
You may want to update the Radar you filed to indicate that this is probably specific to Mojave.
Recently I started getting this error from Xcode:
Error Screenshot
This 'className' property belongs to NSObject. Here is the official documentation.
Why is this happening and how do I solve this (without avoiding using this property)?
The strange thing is that the exact same code worked just fine a few days ago on both the macOS AND the iOS target. Then it started showing this error AFTER the build successfully completed (i could run the project just fine), but now the iOS target won't even build...
I tried (1) purging my derivedData folder many times, (4) doing clean checkouts, (3) restarting Xcode, and (2) restarting the system, all of that in the correct order, but no success...
I'm using Xcode Version 8.2.1 on macOS 10.12.3 and my deployment targets are 10.2 for iOS and 10.12 for macOS.
I can't find any explanation of why this property has been removed, but it does appear to be!
I did find a solution, Get class name of object as string in Swift
String(describing: type(of: self))
As pointed out by #JamesP in a comment above the className property is clearly documented to exist only on macOS 10.0+, and not on iOS, which i failed to notice...
This means that my problem came from the fact that i changed my implementation's target settings from macOS only to macOS and iOS during development.
Because i'm using Objective-C i ended up replacing entity.className with
NSStringFromClass([entity class])
The answer from #Russel shows how to solve this in Swift.
A neat little extension should do the trick.
public extension NSObject {
var nameOfClass: String {
String(describing: type(of: self))
}
}
I couldn't find any related topic so I am starting the new one.
I have macOS Sierra and latest xcode 8.
When I attach my iPhone to macbook and try to build even clean project in xcode I get following swift compiler errors:
Attempting to use the forward class 'UIViewController' as superclass of 'UIActivityViewController'
Attempting to use the forward class 'UIViewController' as superclass of 'UIAlertController'
And so on. Error count is 21 and is always same no matter what project I choose.
Someone have same problem? Any solution?
Thanks for any answer.