ARSession crashes with Testflight, not with Xcode - ios

I have made an app that tracks 2D body motion data using the back camera. I have followed Apple's example to create an ARView from the storyboard, and have added this code in my viewDidAppear:
arView.session.delegate = self
// If the iOS device doesn't support body tracking, raise a developer error for
// this unhandled case.
guard ARBodyTrackingConfiguration.isSupported else {
fatalError("This feature is only supported on devices with an A12 chip")
}
// Run a body tracking configration.
let configuration = ARBodyTrackingConfiguration()
arView.session.run(configuration)
When I open the app everything works perfectly when installing from Xcode, but the app crashes when installing from TestFligth. Crash log shows me the last backtrace log at arView.session.delegate = self

I've found a workaround in case someone faces the same problem. According to Apple this is a known issue in XCode 11. To solve it, you need to manually add RealityKit to your target’s Link Binary with Libraries build phase. Hope this helps

Related

SKStoreProductViewController crashes for unrecognized selector named sceneDisconnected: in iOS 15.6 beta5

In iOS 15.6 beta5 and iOS 16.0 beta:
When an UISceneDidDisconnectNotification was posted, any active SKStoreProductViewController instance would crash for the unrecognized selector named sceneDisconnected.
-[SKStoreProductViewController sceneDisconnected:]: unrecognized selector sent to instance 0x115161a00
This crash only happened in the latest iOS15.6 and iOS16 beta version. Yet I can't find the selector name in any official documents……
Any solutions? Or Is there anything I haven't done right?
Looks like this was fixed in the iOS 15.6 release candidate that was realeased today.
Sept 14 2022 Update: Apple re-introduced this crash in the official 15.7 release. It only seems to happen when the app is force quit so it should not affect users. I've filed a ticket to Apple on feedbackassistant.apple.com and would encourage others to do the same.
Not a solution, but a clear indication that this is Apple's bug to fix. Starting with a clean sample project, all you need to do is present a SKStoreProductViewController and then force quit your application:
import StoreKit
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let storeKitViewController = SKStoreProductViewController()
storeKitViewController.loadProduct(withParameters: [
SKStoreProductParameterITunesItemIdentifier: NSNumber(integerLiteral: 364709193)
])
present(storeKitViewController, animated: true)
// Force quit after presentation to trigger crash
// -[SKStoreProductViewController sceneDisconnected:]: unrecognized selector sent to instance
}
}
I've filed this with Apple via Feedback Assistant.
The crash has been fixed in iOS16
below is an explanation by Apple Framework Engineer
This crash happens in the public release of iOS/iPadOS 15.7, and seed releases of iOS/iPadOS 16 prior to seed 4 [1]. It does not occur in the public release of iOS 16.
The crash primarily happens when the app is in the background and is about to be terminated by the operating system. As a result, these crashes are not expected to be visible to the majority of end users. (One exception is on iPad with an app that supports multiple scenes, and a user manually terminates a scene.)
Your analytics will show an increased in crash rate, however your customers should not be affected by this issue.
We are actively working to address the crash.
[1] In which case you should update to the most recent release.
source: https://developer.apple.com/forums/thread/714464?answerId=729646022#729646022
Able to reproduce a crash with the same stack symbols locally and the code below stops the crash from occurring. The code is creating empty functions to handle the unrecognized selector message and restricting this extension to iOS 15.7:
#available(iOS, introduced: 15.7, obsoleted: 16.0)
#objc extension SKStoreProductViewController {
func sceneDisconnected(_ arg: AnyObject) {}
func appWillTerminate() {}
}
Add this code in application(_:didFinishLaunchingWithOptions:) (at least before the app is terminated). It adds the methods at runtime if they don’t exist.
if #available(iOS 15.7, *) {
if #unavailable(iOS 16.0) {
class_addMethod(
SKStoreProductViewController.self,
Selector(("appWillTerminate")),
unsafeBitCast({ _, _ in } as #convention(c) (SKStoreProductViewController, Selector) -> Void, to: IMP.self),
"v#:"
)
class_addMethod(
SKStoreProductViewController.self,
Selector(("sceneDisconnected:")),
unsafeBitCast({ _, _, _ in } as #convention(c) (SKStoreProductViewController, Selector, NSNotification) -> Void, to: IMP.self),
"v#:#"
)
}
}
It seems they removed appWillTerminate and sceneDisconnected(_:) methods in iOS 15.7, but forgot to remove the code that adds UIApplication.willTerminateNotification and UIScene.didDisconnectNotification observers to the NotificationCenter.
Edit: They seem to have re-added appWillTerminate and sceneDisconnected(_:) methods in iOS 15.7.1. So I’ve updated the code to add the methods only in iOS 15.7.
Edit: They removed the methods AGAIN in iOS 15.7.2 and the crash recurred. I’ve reverted the code.
This is actually an inaccurate reporting because it doesn't actually cause the crash.
I reproduced the reported scene: click on the app-download advertisement in your app, pop up the in-app App Store download page, and then back to the background, the crash message is generated in this time -- but no crash actually occurred, and nothing changed when I returned to the foreground. Everything works fine. The next time the app starts, the crash information will be reported.
So no need to do anything now, just wait for Apple to fix it.
Since version 15.7.1 has been released, we see a decrease in crashes in Firebase Crashlytics. Also when filtering the crashes on iOS version, version 15.7.1 is not present in the list.
This seems a good indication that Apple has finally resolved this issue in 15.7.1.
Please share your observations from your own crash reports to verify that my assumption is correct.

Why am I getting a AXServer error when sharing data via Snapchat SDK?

I am using the example xcode project for sharing media between my app and Snapchat directly. I have successfully authenticated my app by this point (it loads bitmoji + user info and I can print the access token). The code that causes the error is invoked after the UIPicker has selected an image:
from line 38 of MediaPickerViewController.swift
fileprivate func shareImage(image: UIImage) {
let snapPhoto = SCSDKSnapPhoto(image: image)
let snapContent = SCSDKPhotoSnapContent(snapPhoto: snapPhoto)
// Send it over to Snapchat. This produced the error below
snapAPI.startSending(snapContent)
}
Then when you pick an image from the gallery:
2020-03-23 17:49:54.487603-0700 CreativeKitSample[20966:5903027]
[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:
Permission denied portName:'com.apple.iphone.axserver' PID:20969
This is running on my iPhone, debugging over USB. I'm new to Swift development, and my best guess is that my app is developer certificate signed, perhaps it is sandboxed on iOS 13 from communication with prod apps? Or is the AXServer more of a Core UI thing or Accessibility? This project uses Interface Builder/Storyboards. I tried disabling accessibility checkbox on UI elements. I'm at a loss here, searching for AXServer permission errors has not been useful.
some AX errors:
https://github.com/TimOliver/TOCropViewController/issues/402
https://forums.developer.apple.com/thread/120696 (clue that it may be inter-app permission)
https://bugs.webkit.org/show_bug.cgi?id=203618 (sandbox extension?)
I'm an idiot. When I created my Apple Developer Cert and Provisioning Profile, I had a collision with the package identifier, so I changed it in the provisioning settings but neglected to update the snapchat portal's bundle ID. Leaving the question here for anyone else with the same problem.
They could make their error a bit more descriptive...
I got maybe a solution... I'm dismissing before the current View Controller, then present the SFSafariViewController.
Using following Code does help me out! (Xcode 11.3.1, macOS 10.14.6, iOS 13.3)
DispatchQueue.main.async(execute: {
// code goes here
})
// my solution...
DispatchQueue.main.async {
self.present(safariVC, animated: true, completion: nil)
}

transferCurrentComplicationUserInfo is unavailable for WCSession?

This is as straightforward as is sounds; when I try to use session.transferCurrentComplicationUserInfo(_:), I get the error message written in the title, word for word.
Looking at the documentation (transferCurrentComplicationUserInfo, WCSession) there's no indication that it's been deprecated... plus, if something is deprecated it says so in the error message and will still show up in Xcode's intellisense (albeight with strikethrough). For me, neither is happening.
So why Xcode saying it's unavailable?
This is my barebones code that causes the error message:
let userInfo: [String:Any] = [:]
let _ = session?.transferCurrentComplicationUserInfo(userInfo)
For some background, I'm using Xcode 10.1 and Swift 4.2. My app's deployment target is iOS 9.3 and my watch extension's is watchOS 4.0.
Probably, you are trying to call it from the Watch Extension, where it appears as unavailable.
The function transferCurrentComplicationUserInfo can only be called from the iOS app.

Swift - Vidyo SDK problems in TestFlight releases

I'm currently using Vidyo iOS SDK on Swift.
Everything works great, except for the TestFlight releases of the app, that works different from local installations (directly from Xcode).
The problems come from the initialization of the VCConnector for custom handling of views, (nil instead of UnsafeMutableRawPointer(&vidyoView)).
connector = VCConnector(nil,
viewStyle: .default,
remoteParticipants: 10,
logFileFilter: UnsafePointer("warning"),
logFileName: UnsafePointer(""),
userData: 0)
The resulting version in TestFlight will not display the self camera (the preview of my video).
Has it occurred to someone?
If you are uploading to TestFlight then it's likely a release build where speed optimization included Speed [-O].
Try to switch onto default one (for release): Build Settings -> "Swift Compiler - Code Generation" -> Optimization level: No optimization [-Onone] OR Optimize for Size [-Osize].

SPErrorGizmoInstallNeverFinishedErrorMessage in Watchkit

I am running a watchkit app which uses app groups and I can't seem to get it running at all. Anytime I try and run the app I get an alert which says "SPErrorGizmoInstallNeverFinishedErrorMessage".
The code in my glance controller is relatively short.
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
override func willActivate() {
super.willActivate()
sharedDefaults = NSUserDefaults(suiteName: sharedGroupName)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}
func update() {
println(sharedDefaults?.valueForKey("timeMessage") as! String)
}
The code in my ViewController.swift is short as well also just setting this share defaults object:
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
sharedDefaults?.setObject(timeMessage.text, forKey: "timeMessage")
sharedDefaults?.synchronize()
This error is preventing me from running any watchkit app at all. Not the main app or the glance or notification.
I have one app group which is listed in the info.plist.
I have a custom build setting to the app groups name.
Any help would be greatly appreciated.
I fixed this issue by going to the simulator's watch companion app, unchecking the installation for the watch app, then turning it back on. Nothing else worked.
The only thing that worked for me was to Reset Content and Settings in the simulator. Toggling the watch app off and on in the Apple Watch settings app didn't do it for me.
From reading other Apple Developer forum messages, SPErrorGizmoInstallNeverFinishedErrorMessage seems to occur when the Watch App info.plist has an invalid setting.
I was trying different versions of WKCompanionAppBundleIdentifier and that was my error. When I deleted the copied line, that worked again.
This message started appearing when I added custom keys in the info.plist file.
After much trial and error I was able to fix this by unplugging my external display from my computer. Whether this was the real issue I don't know. All I know is that when I had the external monitor plugged in I got this error and when I unplugged it the error went away. I tested it several times.
For me, it was "Targeted Device Family" settings
For parent app, you could keep it iPhone/iPad (or iPhone, up to you);
For watchkitextension, set it to iPhone;
For watchkitapp, if you want to run in the simulator, set it to iPhone. For actually device, the value seems to be 4 (which you cannot set directly from Xcode yet as of 20150416)
I did nothing but restart Simulator & Clean-build app, then it worked again. :)
If you want to use the group to share the data with IOS app and your apple watch kit using the NSUserdefault, you can follow these steps:
1. Add the group app id in capabilities part of IOS targets app and target watch kit
2. when you want to save the data to NSUSerDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
// note that suiteName is group app id
// var str = "demotest"
groupData?.setObject(newYearLabel.text, forKey: "timeRemaining")
groupData?.synchronize()
3. when you want to take the data from NSuserDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
groupData?.synchronize()
if groupData?.objectForKey("timeRemaining") != nil {
var str = groupData?.objectForKey("timeRemaining") as String
println("str \(str)")
self.myLabel.setText(str)
} else {
println("error")
}
Hope this help :)
I found a solution in Xcode 8.3. Make sure that the build setting "Targeted Device Family" is set to iPhone in the WatchKit extension.
I Deleted the App from the simulator, and reinstalled. Seemed to work.
I tried a couple of the other option.
CMD SHIFT K - clean
CMD RUN - run
the error dissapears!

Resources