I have an iOS application view that contains an AVCaptureSession, AVCaptureVideoPreviewLayer (created with the AVCaptureSession), and a UIImageView (in the backend the app takes the output of the AVCaptureSession, runs it through a Semantic Segmentation model, and displays the output in the UIImageView).
When I pause the app and run the “Debug View Hierarchy”, it shows the UIImageView, the relevant buttons and labels.
However, it does not seem to show AVCaptureVideoPreviewLayer that I have set up in my application.
Is there some special set up that needs to be done to be able to view Camera Related features?
The following is part of the view code, a component that is used to render the AVCaptureVideoPreviewLayer (not sure if this is enough, please let me know if its not):
class CameraViewController: UIViewController {
var session: AVCaptureSession?
var frameRect: CGRect = CGRect()
var rootLayer: CALayer! = nil
private var previewLayer: AVCaptureVideoPreviewLayer! = nil
init(session: AVCaptureSession) {
self.session = session
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()
setUp(session: session!)
}
private func setUp(session: AVCaptureSession) {
previewLayer = AVCaptureVideoPreviewLayer(session: session)
previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
previewLayer.frame = self.frameRect
DispatchQueue.main.async { [weak self] in
self!.view.layer.addSublayer(self!.previewLayer)
//self!.view.layer.addSublayer(self!.detectionLayer)
}
}
}
struct HostedCameraViewController: UIViewControllerRepresentable{
var session: AVCaptureSession!
var frameRect: CGRect
func makeUIViewController(context: Context) -> CameraViewController {
let viewController = CameraViewController(session: session)
viewController.frameRect = frameRect
return viewController
}
func updateUIViewController(_ uiView: CameraViewController, context: Context) {
}
}
Xcode
RSS for tagBuild, test, and submit your app using Xcode, Apple's integrated development environment.
Posts under Xcode tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Dear Sirs,
I'm searching for the most straightforward way to identify the root of a "Publishing changes from within view updates is not allowed, this will cause undefined behavior." warning. It is a complex SwiftUI project and I think there should be a better way than just try and error with disabling/removing and enabling/adding different screen elements to check if the warning still is shown. I tried to set a symbolic breakpoint for "os_log" in my XCode project and indeed this is triggered right before the warning appears but the callstack doesn't give me a direct hint to the part of my code which causes this warning. What would be the most direct way and is there something like an exception handler in such cases?
Thanks and best regards,
Johannes
I'm using SwiftData with an @Model and am also using an @ModelActor. I've fixed all concurrency issues and have migrated to Swift 6. I am getting a console error that I do not understand how to clear. I get this error in Swift 6 and Swift 5. I do not experience any issue with the app. It seems to be working well. But I want to try to get all issues taken care of. I am using the latest Xcode beta.
error: the replacement path doesn't exist:
"/var/folders/1q/6jw9d6mn0gx1znh1n19z2v9r0000gp/T/swift-generated-sources/@_swiftmacro_17MyAppName14MyModelC4type18_PersistedPr> opertyfMa.swift"
I am editing my iOS project in Xcode 16 and want to use the "Swift Compiler - Upcoming Features" section of the build settings to selectively enable the new Swift 6 language features.
I have read the instructions for doing this and have dowloaded an Apple sample project and can see that section under the project and target-level Build Settings in the sample project
However, when I open my Xcode project in XCode 16 that section does not appear.
Is there any way for me to influence how Xcode 16 displays the build settings?
In fact, no "Swift Compiler" sections appear at all under my project Build Settings (All | Combined). There is a "User-Defined" section that has the Swift Version, Compilation Mode and Optimization level.
The project itself is several years old and was on a very old project version. I have upgraded my project document format to "Xcode 16" but it made no difference.
I have compared my project and the sample project in a text editor and both seem to have similar structure. I tried removing unused and outdated settings from my project but that also had no effect.
Is there an alternative to deleting my project file and adding the source files to it? I have a large project with multiple targets so that would be something I'd rather not do.
I can sucessfully send pushes to an app (which has been installed/run via Xcode) when the pushes are going through the Apple sandbox server.
However I want to test the server is configured correctly to send them through the Apple production server.
In the Xcode scheme I tried to change the build configuration to release (and ticked debug executable off) ,however the pushes still only work when sent through the sandbox.
Is there a way of installing/running the app using Xcode such that its compatible with the push production environment?
Does the APS Environment entitlement come into play here? this only ever says development.
(The app is on behalf of a 3rd party company, they've added me to their apple developer account but with limited powers, I can't upload to Testflight nor make an ad-hoc release with with to test with)
I'm attempting make to make a distribution build of an app.
In the Xcode target the supported destinations has only iPhone and build active architectures only is set to NO.
I created an archive, then selected Distribute App/ Debugging, but then got this error:
Provisioning profile "iOS Team Provisioning Profile: com.abc.def" doesn't include the currently selected device "DT-iPad-XXXX" (identifier YYYY-YYYYYY).
I've no idea what this device is, it's nothing to do with me, somebody must have added it to the provisioning profile. But that should be beside the point shouldn't it? Because this device has never ever been connected to my Mac/Xcode and so can't be "the currently selected device".
So I tried again. I changed build active architectures to YES and connected an iPhone to the Mac/Xcode and created an archive again. But it was the exact same error.
What's going on, why is Xcode saying this iPad is the currently selected device when attempting to make a distribution?
Hi all,
I got the email saying my certificate(s) will be expiring in 30 days.
I can view my certificates (distribution, distribution managed, and 2x developments) on my account page.
The distribution expires in 30 days (4/20/2023)
The distribution managed expires in 6 months
Development #1 (under my name) expires in 30 days (4/20/2023)
Development #2 (also under my name) expires in 2 months (5/26/2023)
However, I don't see any way to renew them.
I have read other posts that talk about 'edit' or 'generate' buttons, but I don't see that and I presume those posts are just out of date.
When I look in my xcode project, I see that I am using 'automatically manage singing'.
Xcode also shows that a provisioning profile is expiring in 2 months. I presume that is something different? It has the same expiration date as my development #2 certificate (5/26/2023).
It's also unclear what is going to happen when these certificates expire.
I read that devices running builds with the expired distribution cert will stop working.
Is that just for internal builds downloaded from something like Test Flight?
Will live builds, downloaded by actual players from the AppStore, stop working if I don't push a release with a new cert in the next month?
I am the one that set this all up and 'maintains' it, but I don't engage with it often enough to remember the bits and bobs.
My apologies for all the newbie questions.
Thank you for your assistance
I'm new to Xcode and decided to give it a try, however, I'm unable to preview even the default "hello, world" message.
I've tried downloading Xcode on the App Store on Mac and from the official website, but I couldn't go pass the "Preparing (Automatic) iPhone Simulator."
I've also tried the following line of code on Terminal, but nada:
xcrun simctl erase all
Here's what I see for almost two hours now (it makes no sense):
My system specs:
iMac Retina 4K, 21.5-inch, 2019, 3 GHz Intel Core i5 6-Core, Radeon Pro 560X 4 GB, 8 GB 2667 MHz DDR4 (two 4gb core each), 1TB SSD.
I've coded way bigger web projects using various applications, but Xcode can't even preview the sample file?
Please, help. I would really like to code using Swift. :)
E aí pessoal, tudo certo?
Estou desenvolvendo um app com React Native no front-end e Node.js no back-end, usando o Firebase como banco de dados (e possivelmente para autenticação também, dependendo da solução). Preciso implementar o "Sign in with Apple" e estou com algumas dúvidas em como integrar tudo isso.
A ideia é: o usuário clica no botão "Entrar com a Apple" no app (React Native), o backend (Node.js) processa a autenticação com a Apple e, em seguida, armazena as informações necessárias (nome, email, etc.) no Firebase.
Se alguém já trabalhou com essa combinação (React Native, Node.js, Firebase e Sign in with Apple) e puder compartilhar alguma experiência, dicas, exemplos de código ou até mesmo um boilerplate, seria de grande ajuda!
Hi,
I'm trying to register the application with Xcode Cloud.
For that, I click on the "cloud" button in Xcode.
First steps goes OK, but it fails at "create App on App Store Connect"
The error is Cannot register the product
Usually, I change the bundle name, but this time it gets weird, as Xcode managed to create the Identifier, as it is not taken.
So the identifier is created in the developer portal but it fails anyway.
I also tried to create the app directly in the portal, and it works, therefore the app name is not the problem.
Then I delete the app and try again with Xcode and it fails...
Any solution for this issue please?
I have a problem regarding the application that I built using flutter, I use the camera library, when I test in xcode with the debug / release schema the camera can open, but when I try to send it to the testflight testers I can't open the camera, for the permissions I have added and the testers have received the required permissions.
I am trying to build my watch app on my series 4 Apple watch currently running WatchOS 10.3 with a deployment target of 10.2 and Xcodes claims that my watch's OS version is too low. I have fully updated my watch to 10.3, tried to downgrade the deployment target to no avail. Xcode doesn't seem to be getting any data on what OS version my watch is running. It says watchOS () in the manage run destinations page. I imagine this is a problem with the connection between my watch and my mac but I cannot solve it. Any advice?
I have tried all of the above options, cleaned cached data, restarted several times, did not work.
The tunnel connection failed while the system tried to connect to the device.
Domain: com.apple.dt.RemotePairingError
Code: 4
System Information
macOS Version 15.2 (Build 24C101)
Xcode 16.2 (23507) (Build 16C5032a)
iOs 18.1.1
Hello.
We have a few iOS devices connected to CI macs. We test our 3D engine, so we really need hardware devices for that. The issue is that Xcode loses connection to the devices once in a while, mostly after mac reboot, which requires a human to enter test room and unplug and plug cable again. Even if device is visible and accessible in Finder, Xcode may still don't see it, and devicectl shows it as disconnected.
Are there any hacks to make connection stable? The best what we could achieve so far was to remove iOS device screen lock - otherwise mac reboot would in 100% cases require human interaction to reconnect the device.
Both iOS and mac are logged into the same Apple ID.
Mac is logged in automatically after reboot
iOS devices have no screen lock
Thank you.
When dealing with SwiftUI and searchable modifier, I know you can use URL or hard code data to search when building projects in Xcode.
I am looking to see if you can use a txt file as a way or storing string data of lists to search from when your device is offline when using the search modifier. Then when connected to internet you can update the search with url connection that then updates the txt file so you can do new searches the next time you are offline again.
Is this something that is possible?
until previous version of the Xcode, I can see the backtrace of view by edit scheme -> Diagnostics -> Logging -> check Malloc Stack and select All Allocation and Free History` but the option just gone in Xcode 16.
Crash Log
We have a issue with our watch app. When we do a release build with xcode 16 the watch app will not launch and crashes on watchOS 10 and below devices.
It does not do this on debug builds...and it does not do this on xcode 15 release/debug builds.
Anybody running into watch crashes on xcode 16?
Thanks
I use the code below for a non-consumable in-app purchase in my apps. Has anybody worked out how to handle this without using any of the deprecated items?
SKPaymentQueue - deprecated,
SKPayment - deprecated,
SKProduct - deprecated,
transactionState - deprecated,
SKPaymentTransaction - deprecated,
finishTransaction - deprecated
func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool
{
true
}
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
{
for transaction in transactions
{
switch transaction.transactionState
{
case .purchasing:
break
case .purchased:
SKPaymentQueue.default().finishTransaction(transaction)
// Hide the restore button
navigationItem.setRightBarButton(nil, animated: true)
// Set the ProVerion in the Db to true
IAPHandler.setProVersionToPurchased()
// Also hide the Purchase button
UIView.animate(withDuration: 1.0, animations: { [weak self] in
self?.purchaseBtn_Outlet.alpha = 0
}) { [weak self] (success) in
if self!.theDevice.isOneOf(K.Device_Groups.SE_3_iPhone8) {
self?.segControlTop_Constraint.constant = 10
} else if self!.theDevice.isPhone {
self?.segControlTop_Constraint.constant = 30
}
}
case .failed:
if let error = transaction.error
{
let errorDescription = error.localizedDescription
print("Transaction failed due to error: \(errorDescription)")
}
case .restored:
SKPaymentQueue.default().finishTransaction(transaction)
// Hide the restore button
navigationItem.setRightBarButton(nil, animated: true)
// Set the ProVerion in the Db to true
IAPHandler.setProVersionToPurchased()
// Also hide the Purchase button
UIView.animate(withDuration: 1.0, animations: { [weak self] in
self?.purchaseBtn_Outlet.alpha = 0
}) { [weak self] (success) in
if self!.theDevice.isOneOf(K.Device_Groups.SE_3_iPhone8) {
self?.segControlTop_Constraint.constant = 10
} else if self!.theDevice.isPhone {
self?.segControlTop_Constraint.constant = 30
}
}
case .deferred:
break
@unknown default:
if let error = transaction.error
{
let errorDescription = error.localizedDescription
print("Transaction failed due to error: \(errorDescription)")
}
break
}
}
}
// Sets the purchase to true in the Db
class IAPHandler: NSObject {
//Get the ProVersion Status
static func isProVersionPurchased() -> Bool
{
let VC_String = "IAPHandler"
var theStatus = false
do {
let settings = try Database.shared.databaseConnection!.read { db in
try My_Settings.fetchOne(db)
}
let theStatusText = settings?.ProVersion ?? "false"
theStatus = theStatusText == "true" ? true : false
} catch {
print("Getting the ProVersion Status failed! \(VC_String) \(error)")
}
return theStatus
}
// Set ProVersion to true.
static func setProVersionToPurchased()
{
let VC_String = "IAPHandler"
do {
try Database.shared.databaseConnection!.write { db in
try db.execute(sql: "UPDATE My_Settings SET ProVersion = :proVersion WHERE Settings_ID = :id",
arguments: ["proVersion": "true", "id": 1])
}
} catch {
print("Update set pro version, failed! \(VC_String)s \(error)")
}
}
}// End of class
I was invited to a new development team yesterday, and I can not choose that team under the Team drop down of Signing & Capabilities in Xcode. Also, when I first login to Apple Developer, this team is not in the main drop down (the teams dropdown). But if I go into "Apps", then I can see the team in the teams dropdown in the top right of the screen and switch to it. Anyone know what's going on?
When overriding the following seek functions in a custom subclass of AVPlayerItem, a "method does not override method from its superclass" error occurs, causing the build to fail. This issue only happens after updating to Xcode 16. Do you have any suggestions on how to fix it?
https://developer.apple.com/documentation/avfoundation/avplayeritem/seek(to:completionhandler:)-91gnw
https://developer.apple.com/documentation/avfoundation/avplayeritem/seek(to:tolerancebefore:toleranceafter:completionhandler:)
(This error disappears 3 seconds after the build fails or temporarily disappears when the function's position in the file is changed.)