I'm trying to retrieve the overall memory peak of a process. I've looked into retrieving it through task_vm_info struct defined in task_info.h
By logging the members of the struct, it seems neither resident_size_peak, internal_peak or ledger_phys_footprint_peak is matching what the peak memory value that's being detected by xcode instrument. Can anyone point me to the correct way to retrieve that peak value? Is it the summation of some of the fields in task_vm_info` or is there a more complicated algorithm involved in deriving that value?
Xcode
RSS for tagBuild, test, and submit your app using Xcode, Apple's integrated development environment.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi there!
Was there a change in Xcode regarding incremental builds / updating an active Simulator with a new build? We use xcodebuild to manage our internal build framework and out of the sudden, incremental builds are not launched anymore and the Simulator is stuck waiting for the new build to be launched. This was not happening for the last 10+ years.
If there is an xcodebuild flag and/or guide of this new behavior, it would help a lot.
Thanks everyone!
After 7-8 months of intense studying, I'm working on my first App. After a couple of months coding it, I saw that Swift Data wasn't cutting it, I decided to restart the project and implement Core Data.
To cut to the chase, I'm using 3 models (entities) in my app. One of those entities has 2 Transformable attributes: an array of strings and an array of doubles.
I've implemented a Transformer, made sure it's added to each entity, but no matter what, I'm getting this error with random Entities and Attributes. At first it referenced the entity Quote, but then it referenced the entity MoneyElement (attribute title). This is the error:
autonome crashed due to an uncaught exception NSInvalidArgumentException. Reason: -[MoneyElement setTitle:]: unrecognized selector sent to instance 0x600001736c00.
I'm attaching screenshots of the different entities, as well as the code for the Entity's class that has both Transformable attributes.
If anyone could help me, I'd appreciate it greatly. I'm getting the error not even making a fetch request, just trying to paint a mere and humble Text("Hello, world!") in my canvas.
public class Quote: NSManagedObject, Identifiable {
@NSManaged public var clientName: String
@NSManaged public var quoteNumber: String
@NSManaged public var dateOfCreation: Date
@NSManaged public var dateOfApproval: Date?
@NSManaged public var dateOfCancellation: Date?
@NSManaged public var ServicesProvided: [String]?
@NSManaged public var servicesCost: [Double]?
@NSManaged public var netAmount: Double
@NSManaged public var vatTax: Int
@NSManaged public var irpfTax: Int
@NSManaged public var grossAmount: Double
@NSManaged public var currentStatus: String
}
class QuoteContainer {
let persistentContainer: NSPersistentContainer
init(forPreview: Bool = false) {
ValueTransformer.setValueTransformer(QuoteStringArrayTransformer(), forName: NSValueTransformerName("QuoteStringArrayTransformer"))
ValueTransformer.setValueTransformer(QuoteDoubleArrayTransformer(), forName: NSValueTransformerName("QuoteDoubleArrayTransformer"))
persistentContainer = NSPersistentContainer(name: "Models")
if forPreview {
persistentContainer.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
persistentContainer.loadPersistentStores { _, _ in}
if forPreview {
addMockData(moc: persistentContainer.viewContext)
}
}
}
class QuoteStringArrayTransformer: NSSecureUnarchiveFromDataTransformer {
override class func transformedValueClass() -> AnyClass {
return NSData.self
}
override func transformedValue(_ value: Any?) -> Any? {
guard let array = value as? [String] else { return nil }
return try? JSONEncoder().encode(array)
}
override func reverseTransformedValue(_ value: Any?) -> Any? {
guard let data = value as? Data else { return nil }
return try? JSONDecoder().decode([String].self, from: data)
}
}
class QuoteDoubleArrayTransformer: ValueTransformer {
override class func transformedValueClass() -> AnyClass {
return NSData.self
}
override func transformedValue(_ value: Any?) -> Any? {
guard let array = value as? [Double] else { return nil }
return try? JSONEncoder().encode(array)
}
override func reverseTransformedValue(_ value: Any?) -> Any? {
guard let data = value as? Data else { return nil }
return try? JSONDecoder().decode([Double].self, from: data)
}
}
I'm trying to get our CI working to build our own machine image AMI descriptions. Part of that is to download the correct runtime versions so that we can pre-create the simulators we use for testing on these machine image descriptions.
When running the code like
xcodebuild -downloadPlatform <platform> -exportPath "$<temp_folder_path>"
Locally I get a result and download a runtime, but on CI I just get All available platforms are downloaded. Why is this message happening and how can I specify specific platforms to download over CI to configure our machine setup?
Our use case is that we need to run a CLI script (on Mac) to set up some backend configuration for a UITest that then runs on iOS (simulator or actual device). The setup logic is test specific so using pre-build scripts is not a an option. Is that support in any way or what would be alternatives to go about this.
I'm getting a crash saying SKAdNetwork can't be found in storekit. How do I fix this problem
Topic:
Developer Tools & Services
SubTopic:
Xcode
Here is a modified code from the documentation example
https://www.swift.org/documentation/server/guides/memory-leaks-and-usage.html#troubleshooting :
class ViewController: UIViewController {
var closure: () -> Void = { () }
public func doNothing() {}
public func doSomethingThatLeaks() {
self.closure = {
// This will leak as it'll create a permanent reference cycle:
//
// self -> self.closure -> self
self.doNothing()
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Memory leak example:
doSomethingThatLeaks()
// Abandoned memory example:
// NotificationCenter.default.addObserver(forName: .init("Abandoned"), object: nil, queue: nil) { _ in
// print("\(self)")
// }
}
deinit {
print(#function, Self.self)
}
}
If you place it, for example, in a navigation controller, do a push-pop several times, deinit will not be printed.
But if you look in the Debug Memory Graph, it will not even show that there is a strong reference to this controller:
Only if you manually select:
You can see that it is held by the closure context, which it holds:
This is definitely not abandoned memory (like the commented piece of the code example), but it is not shown either in the Debug Memory Graph or in Instruments Leaks.
Why?
Hello everyone,
I recently upgraded from Xcode 15.4 to Xcode 16.0. While the build generated using Xcode 15.4 worked perfectly, I encountered an issue with the release build after the upgrade. Specifically, the release build fails to communicate with a BLE 4.2-based device.
I’ve compared the ‘Project Properties’ between Xcode 15.4 and 16.0 but couldn’t identify any differences that might be causing this issue.
Could anyone provide insights into what might be causing this problem? Is a specific library used in my project incompatible with Xcode 16.0, or is this an issue with Xcode 16.0 itself?
No warning or exception is visible when debugging an Xcode 16.0-based release mode application.
Any help or suggestions would be greatly appreciated!
Thank you!
Hello, today I encountered strange xcodebuild command behaviour when building an application on my company CICD machine. Our app has the standard settings for the IOS platform, without any changes to the Build Settings, but building on the machine for CICD (mac mini M1) fails during build of SPM library. The aforementioned library is simple local SPM Package which wrapps swift-dependencies library, adds macros and few structures. Build log show that the process attempted to build a macro with the x86_64 architecture(log fragment at the end). Building on my local machine succeeds. Unfortunately I've run out of ideas, so I'm hoping that maybe someone here has encountered something similar and will be able to help me solve the problem.
Used command:
xcodebuild -workspace $WorkSpaceName.xcworkspace -scheme SchemeName -configuration Release -destination generic/platform=iOS -skipPackagePluginValidation -skipMacroValidation clean archive
Package.swift:
https://gist.github.com/pelekon/4a563b7f279c0d2f02060b8c554d76b2
Basic system env info:
MacOS 15.1.1, Xcode 16.1 (16B40)
Log fragment:
https://gist.github.com/pelekon/d008ff366124e333d4318fa152062797
Topic:
Developer Tools & Services
SubTopic:
Xcode
As today I was checking my Command line folder and there I found 5 SDK folder, which include latest and older version of SDK of MACOSX.
If I delete the older Version will it create problem to my commands in my terminal
Topic:
Developer Tools & Services
SubTopic:
Xcode
When attempting to fix an issue that is only happening on a specific iOS build I noticed that I am not able to install that specific build on my simulator. Is there any way to get specific iOS builds that are not available through Xcode?
Example: The bug I am trying to fix is only happening on 17.6.1 and 17.7.1. These specific builds are not available through Xcode.
Attempted Resolution: I found a iPhone14,5_17.6.1_21G101_Restore.ipsw file but was not able to import it into Xcode for use nor was I able to use it on a physical device.
I noticed that IBDesignable was deprecated in the Xcode 16 release notes, and IBInspectable was deprecated in the Xcode 16.1 release notes.
So, I performed some tests on IBDesignable and IBInspectable in Xcode.
I wrote the following code:
@IBDesignable
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get {
layer.cornerRadius
}
set {
layer.cornerRadius = newValue
}
}
@IBInspectable var borderWidth: CGFloat {
get {
layer.borderWidth
}
set {
layer.borderWidth = newValue
}
}
@IBInspectable var borderColor: UIColor {
get {
UIColor(cgColor: layer.borderColor ?? .init(red: 1, green: 1, blue: 1, alpha: 0))
}
set {
layer.borderColor = newValue.cgColor
}
}
}
I cannot access the IBInspectable property in Xcode 16.
However, I can access the IBInspectable property in Xcode 16.1 and Xcode 16.2 Beta, where the Interface Builder shows it in the Attributes Inspector.
Is it possible that this will be updated later, as it differs from the release notes?
Thank you.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Simulators sometimes draw the screen with the wrong aspect ratio and appear distorted. I'm on macOS 14.7 and using Xcode 16.1, but Xcode 16 was also sometimes doing this. This is happening in both iPhone simulator and iPad simulators.
Is anyone else seeing this? It's not just the Home Screen, it happens in apps too.
I have a weird bug when testing on the iPad simulators and I can't tell if it is a bug in the simulator or in my app. All my iPads are broken, so I can't actually test on device right now.
While creating PR from Xcode I can only see first 100 branches
Topic:
Developer Tools & Services
SubTopic:
Xcode
I've just updated to macOS 15.2 Beta and Xcode 16.2 Beta and just noticed I can't build my visionOS app as before.
I have a separate /Volumes/Development APFS volume for Xcode projects, plus utilising a Relative setting for DerivedData so that these are located in the projects' directories – in this case, subfolder on this volume mentioned.
I just found that when attempting to build the app in either Xcode 16.1 or 16.2 Beta with visionOS 2.1 SDK, I'm getting a following error:
Finished processSwiftFiles() with a failure 'You don’t have permission to save the file “CustomComponentUSDInitializers.usda” in the folder “RealityAssetsGenerated”.'
Sandbox: realitytool(6216) deny(1) file-write-create /Volumes/Development/travel-visionos/DerivedData/Tripomatic/Build/Intermediates.noindex/RealityKitContent.build/Debug-xrsimulator/RealityKitContent_RealityKitContent.build/DerivedSources/RealityAssetsGenerated/CustomComponentUSDInitializers.usda.sb-02874eb3-PS4qfZ
Failure creating schema - 'You don’t have permission to save the file “CustomComponentUSDInitializers.usda” in the folder “RealityAssetsGenerated”.'
This for sure worked previously with 15.0/16.0 or 15.1/16.1 as I've even published the app to the App Store.
It seems to be some shenanigans related to sandboxing & permissions for Xcode tools which I can hardly work around. I have Xcode added to Developer Tools and Full disk access sections in Privacy & Security, yet that doesn't really change anything in relation to this issue.
When I move the project to a subfolder in my home directory, the build succeeds. The same applies to switching DerivedData setting to the default value to that DD are generated in ~/Library/Developer folder for all projects opened in Xcode.
Thus, either macOS or Xcode now has an issue with running realitytool to generate files on my dedicated volume.
Should I consider this Xcode or macOS Beta issue? Report it via Feedback Assistant maybe?
How can Xcode15 reduce parallel compile thread count, it consumes too many memory.
Hello! Recently, I noticed that my build isn’t including additional assets (icons). I tried using two different versions of Xcode (16.1 and 15.4) on separate Macs, but I’m getting the same result. Not all icons are being included in the build. However, I found that if I set my minimum deployment version to 14, all of the icons appear as expected.
Starting from target version 15 in Xcode, no additional icons are included. Is there any way to resolve this?
Topic:
Developer Tools & Services
SubTopic:
Xcode
I updated to xcode 16. But I can't load version of package dependencies. My project only use SPM. I try Reset package caches and Resolve package version but not success. How to fix?
Topic:
Developer Tools & Services
SubTopic:
Xcode
Capturing a Metal workload in Xcode, exporting a .gputrace file, is there a way to export the data using the command line, just like .memgraph can use malloc_history --quiet to export the data as text
Hi,
in my previous macOS app I used to archive a dictionary to a preference file using
[NSArchiver archivedDataWithRootObject:dictionary];
and to unarchive it using
[NSUnarchiver unarchiveObjectWithData:dataFromDisk];
Now I would like to replace the 2 deprecated methods with
NSError *error;
NSSet *classSet = [NSSet setWithObjects:[NSDictionary class], [NSArray class], [NSString class], [NSNumber class], [NSData class], nil];
NSDictionary *dictionary = [NSKeyedUnarchiver unarchivedObjectOfClasses:classSet fromData:dataFromDisk error:&error];
But I get a nil dictionary and the error 4864: non-keyed archive cannot be decoded by NSKeyedUnarchiver. So I guess I should first keep on unarchiving the preferences dataFromDisk using the old deprecated method
[NSUnarchiver unarchiveObjectWithData:dataFromDisk];
Then I could use the new NSKeyedArchiver and NSKeyedUnarchiver methods for the upcoming release.
But, if this deprecated method
[NSUnarchiver unarchiveObjectWithData:dataFromDisk];
fails to unarchive the old data (and on some machines now it fails), how could I use the new methods? Should I consider my old preference file gone?
Is a way to force the new NSKeyedUnarchiver method to unarchive data previously archived with NSArchiver ?
Topic:
Developer Tools & Services
SubTopic:
Xcode