Build, test, and submit your app using Xcode, Apple's integrated development environment.

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

{Project}-LinkMap-normal-arm64.txt changed?
I upgraded xcode to 16.2 and found that the txt file generated by Write Link Map File is different from before, no longer containing detailed data. So, how to set it up to obtain the same link map file as the previous xcode version. # Path: /Users/....../xxx.app/__preview.dylib # Arch: arm64 # Object files: [ 0] linker synthesized # Sections: # Address Size Segment Section 0x00004000 0x00000000 __TEXT __text # Symbols: # Address Size File Name
0
0
90
Mar ’25
Swift, kevent, and wth?!?!?
I have this code: var eventIn = kevent(ident: UInt(self.socket), filter: Int16(EVFILT_WRITE), flags: UInt16((EV_ADD | EV_ENABLE)), fflags: 0, data: 0, udata: nil ) I looked at it and thought why do I have those extra parentheses? So I changed it to var eventIn = kevent(ident: UInt(self.socket), filter: Int16(EVFILT_WRITE), flags: UInt16(EV_ADD | EV_ENABLE), // changed line! fflags: 0, data: 0, udata: nil ) and then kevent gave me EBADF. Does this make sense to anyone?
0
0
241
Feb ’25
The location coming out of geocoder in CLPlacemark has altitude 0, differently of the input CLLocation
When I execute: geoCoder.reverseGeocodeLocation(location, completionHandler:{[weak self](placemarks, error) in print("reverse geocoding location after altitude: ",location.altitude) print("placemark location first", placemarks?.first?.location?.altitude ?? -1) The input CLLocation has correct altitude 25, instead the location in the output placemarks have altitude 0, when of course they should have the same location. Moreover it is impossible to retrofit any data in the returned placemarks as they are portrayed as a read only property.
0
0
59
Apr ’25
Error Missing required module 'RxCocoaRuntime' in xcframeworks
Hi. I have a xcframework that has a dependency on 'RxSwift' and 'RxCocoa'. I deployed it using SPM by embedding it in a Swift Package. However when I import swift package into another project, I keep getting the following error: "Missing required module 'RxCocoaRuntime" How can I fix this? Below are the steps to reproduce the error. Steps Create Xcode proejct, make a dependency on 'RxSwift' and 'RxCocoa' (no matter doing it through tuist or cocoapods) Create XCFramework from that proejct. (I used commands below) xcodebuild archive \ -workspace SimpleFramework.xcworkspace \ -scheme "SimpleFramework" \ -destination "generic/platform=iOS" \ -archivePath "./SimpleFramework-iphoneos.xcarchive" \ -sdk iphoneos \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES xcodebuild archive \ -workspace SimpleFramework.xcworkspace \ -scheme "SimpleFramework" \ -archivePath "./SimpleFramework-iphonesimulator.xcarchive" \ -sdk "iphonesimulator" \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES xcodebuild -create-xcframework \ -framework "./SimpleFramework-iphoneos.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \ -framework "./SimpleFramework-iphonesimulator.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \ -output "./SimpleFramework.xcframework" Embed in Swift Package, and deploy. // swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "SimplePackage", platforms: [.iOS(.v16)], products: [ .library( name: "SimplePackage", targets: ["SimplePackage"]), ], dependencies: [ .package(url: "https://github.com/ReactiveX/RxSwift", from: "6.8.0") ], targets: [ .binaryTarget( name: "SimpleFramework", path: "Sources/SimpleFramework.xcframework" ), .target( name: "SimplePackage", dependencies: [ "SimpleFramework", "RxSwift", .product(name: "RxCocoa", package: "RxSwift") ] ) ] ) Download Swift Package in another project and import module. I resolved this by removing dependencies from the Swift Package, downloading package in another project, and fetching dependencies by cocoapods. Thist works, but I don't want to use another dependency manager while using SPM. Development Environment CPU : Apple M4 Max MacOS : Sequoia 15.3 Xcode : 16.2
0
0
270
Mar ’25
Sequential Animation on Reality Composer Pro
Dear Developers, I am having some problems with Reality Composer Pro on Mac. Specifically, I don't understand how to manage some timeline functions. I have an object that has a double animation, an opening animation and a closing animation. On a first tap the object should open through animation 1, while on the second tap the object should close through animation 2. Only the two animations conflict. In addition, animation 1 does not stop at the last frame but returns the object to the position of frame 0. Do you have any solutions? Thank you all
0
0
350
Feb ’25
How to Export OBJ with Texture (JPG + MTL) from ARKit LiDAR Scan in iOS?
I am using ARKit with RealityKit to scan objects using LiDAR on iOS. I can generate an OBJ file from ARMeshAnchors, but I am missing the texture export (JPG + MTL). What I Have So Far: Successfully capturing mesh using ARMeshAnchor. Converting mesh into MDLAsset and exporting .obj. I need help generating the .jpg texture and linking it to the .mtl file. private func exportScannedObject() { guard let camera = arView.session.currentFrame?.camera else { return } func convertToAsset(meshAnchors: [ARMeshAnchor]) -> MDLAsset? { guard let device = MTLCreateSystemDefaultDevice() else {return nil} let asset = MDLAsset() for anchor in meshAnchors { let mdlMesh = anchor.geometry.toMDLMesh(device: device, camera: camera, modelMatrix: anchor.transform) // Apply a gray material to the mesh let material = MDLMaterial(name: "GrayMaterial", scatteringFunction: MDLScatteringFunction()) material.setProperty(MDLMaterialProperty(name: "baseColor", semantic: .baseColor, float3: SIMD3(0.5, 0.5, 0.5))) // Gray color if let submeshes = mdlMesh.submeshes as? [MDLSubmesh] { for submesh in submeshes { submesh.material = material } } asset.add(mdlMesh) } return asset } func export(asset: MDLAsset) throws -> URL { let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let url = directory.appendingPathComponent("scaned.obj") if MDLAsset.canExportFileExtension("obj") { do { try asset.export(to: url) return url } catch let error { fatalError(error.localizedDescription) } } else { fatalError("Can't export USD") } } if let meshAnchors = arView.session.currentFrame?.anchors.compactMap({ $0 as? ARMeshAnchor }), let asset = convertToAsset(meshAnchors: meshAnchors) { do { let url = try export(asset: asset) showScanPreview(url) } catch { print("export error") } } } extension ARMeshGeometry { func vertex(at index: UInt32) -> SIMD3<Float> { assert(vertices.format == MTLVertexFormat.float3, "Expected three floats (twelve bytes) per vertex.") let vertexPointer = vertices.buffer.contents().advanced(by: vertices.offset + (vertices.stride * Int(index))) let vertex = vertexPointer.assumingMemoryBound(to: SIMD3<Float>.self).pointee return vertex } // helps from StackOverflow: // https://stackoverflow.com/questions/61063571/arkit-3-5-how-to-export-obj-from-new-ipad-pro-with-lidar func toMDLMesh(device: MTLDevice, camera: ARCamera, modelMatrix: simd_float4x4) -> MDLMesh { func convertVertexLocalToWorld() { let verticesPointer = vertices.buffer.contents() for vertexIndex in 0..<vertices.count { let vertex = self.vertex(at: UInt32(vertexIndex)) var vertexLocalTransform = matrix_identity_float4x4 vertexLocalTransform.columns.3 = SIMD4<Float>(x: vertex.x, y: vertex.y, z: vertex.z, w: 1) let vertexWorldPosition = (modelMatrix * vertexLocalTransform).columns.3 let vertexOffset = vertices.offset + vertices.stride * vertexIndex let componentStride = vertices.stride / 3 verticesPointer.storeBytes(of: vertexWorldPosition.x, toByteOffset: vertexOffset, as: Float.self) verticesPointer.storeBytes(of: vertexWorldPosition.y, toByteOffset: vertexOffset + componentStride, as: Float.self) verticesPointer.storeBytes(of: vertexWorldPosition.z, toByteOffset: vertexOffset + (2 * componentStride), as: Float.self) } } convertVertexLocalToWorld() let allocator = MTKMeshBufferAllocator(device: device); let data = Data.init(bytes: vertices.buffer.contents(), count: vertices.stride * vertices.count); let vertexBuffer = allocator.newBuffer(with: data, type: .vertex); let indexData = Data.init(bytes: faces.buffer.contents(), count: faces.bytesPerIndex * faces.count * faces.indexCountPerPrimitive); let indexBuffer = allocator.newBuffer(with: indexData, type: .index); let submesh = MDLSubmesh(indexBuffer: indexBuffer, indexCount: faces.count * faces.indexCountPerPrimitive, indexType: .uInt32, geometryType: .triangles, material: nil); let vertexDescriptor = MDLVertexDescriptor(); vertexDescriptor.attributes[0] = MDLVertexAttribute(name: MDLVertexAttributePosition, format: .float3, offset: 0, bufferIndex: 0); vertexDescriptor.layouts[0] = MDLVertexBufferLayout(stride: vertices.stride); let mesh = MDLMesh(vertexBuffer: vertexBuffer, vertexCount: vertices.count, descriptor: vertexDescriptor, submeshes: [submesh]) return mesh } } What I Need Help With: How do I generate the JPG texture from the AR scene? How do I save an MTL file linking the OBJ model to the texture? How can I correctly apply the texture when viewing the OBJ in an external 3D viewer? I appreciate any guidance, including sample code or resources! If you have a complete working solution, I’d love to discuss further via private channels.
0
0
481
Feb ’25
WatchOS app - installation not working
Hi everyone, I’ve been trying since yesterday to set up an Apple Watch app alongside my iOS app, but it’s not working at all. I created the app by adding a new target, selected watchOS > App, and linked it to my iOS project. When I run the Apple Watch scheme directly, the app works, but if I try to install it on my Apple Watch via the iOS app, it doesn’t work. Every time I tap install, I get a message saying that the installation failed. While reading the documentation, they mention an Info.plist file that is supposed to be generated with the watchOS app, but when I check, I don’t see any .plist file. Is that normal? Thanks for your help.
0
0
65
May ’25
The behavior of the app using the Promises library changes between Xcode 15.4 and Xcode 16.2.
I’m creating code that performs asynchronous processing using the Promises library (https://github.com/google/promises). In this context, when building the app in Xcode 15.4 and Xcode 16.2, the behavior differs between the two. I’m using version 2.1.1 of the library. Also, I’ve tried using the latest version, 2.4.0, but the result was the same. Has anyone encountered the same issue or know an effective solution? Here's a simple code that reproduces this issue. @IBAction func tapButton(_: UIButton) { _ = getInfo() } func getInfo() -> Promise<Void> { Promise(on: .global(qos: .background)) { fulfill, _ in self.callApi() .then { apiResult -> Promise<ApiResult> in print("\(#function), first apiResult: \(apiResult)") return self.callApi() // #1 } .then { apiResult in print("\(#function), second apiResult: \(apiResult)") // #2 fulfill(()) } } } func callApi() -> Promise<ApiResult> { Promise(on: .global(qos: .background)) { fulfill, _ in print("\(#function), start") self.wait(3) .then { _ in let apiResult = ApiResult(message: "success") print("\(#function), end") fulfill(apiResult) } } } struct ApiResult: Codable { var message: String enum CodingKeys: String, CodingKey { case message } } The Swift Language version in the build settings is 5.0. The console output when running the above code is as follows: When built with Xcode 15.4: 2025/03/21 10:10:46.248 callApi(), start 2025/03/21 10:10:46.248 wait 3.0 sec 2025/03/21 10:10:49.515 callApi(), end 2025/03/21 10:10:49.535 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 10:10:49.535 callApi(), start 2025/03/21 10:10:49.536 wait 3.0 sec 2025/03/21 10:10:52.831 callApi(), end 2025/03/21 10:10:52.832 getDeviceInfo(), second apiResult: ApiResult(message: "success") The process proceeds from #1 to #2 after completing the code comment in #1. When built with Xcode 16.2: 2025/03/21 09:45:33.399 callApi(), start 2025/03/21 09:45:33.400 wait 3.0 sec 2025/03/21 09:45:36.648 callApi(), end 2025/03/21 09:45:36.666 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 09:45:36.666 callApi(), start 2025/03/21 09:45:36.666 wait 3.0 sec 2025/03/21 09:45:36.677 getDeviceInfo(), second apiResult: Pending: ApiResult 2025/03/21 09:45:39.933 callApi(), end The process does not wait for the code comment in #1 to finish and outputs the #2 print statement first. Additionally, even with Xcode 16.2, when changing the #2 line to "print("(#function), second apiResult: (apiResult.message)")", the output becomes as follows. From this, it seems that referencing the ApiResult type, which is not a String, might have some effect on the behavior. 2025/03/21 10:05:42.129 callApi(), start 2025/03/21 10:05:42.131 wait 3.0 sec 2025/03/21 10:05:45.419 callApi(), end 2025/03/21 10:05:45.437 getDeviceInfo(), first apiResult: ApiResult(message: "success") 2025/03/21 10:05:45.437 callApi(), start 2025/03/21 10:05:45.437 wait 3.0 sec 2025/03/21 10:05:48.706 callApi(), end 2025/03/21 10:05:48.707 getDeviceInfo(), second apiResult: success Thank you in advance
0
0
158
Mar ’25
How to exclude header files from 3rd party pods from getting the Apple Clang warning policies?
I have the 'warnings as errors' policy set to Yes for Apple Clang and Swift compiler. As far as I know, there is no way to make exceptions to the warning policies from Swift compiler (correct me if I am wrong), what about Clang warning policies, specifically when it comes to header files from 3rd party pods? They don't show up on the Compile Sources so I can't apply flags such as -Wno-error=deprecated to them. Adding #pragma GCC... to them won't help as a fresh pod install will wipe the #pragma statements out. Is there a way to exclude the header files from pods from getting the warning policies from Clang so I won't see errors from them when compiling Clang modules that's a part of the build process?
0
0
320
Feb ’25
NSE Filtering Entitlement Rejected Repeatedly – Seeking Advice & Possible Solutions
Hi everyone, I’m facing a major roadblock with my family location tracking app, and I need some advice or guidance from the community. Background Back in 2021, I implemented NSE filtering entitlement to send location-based notifications and retrieve the device's location in return (as suggested by Apple’s technical code support). Over time, I built my app around this entitlement, adding many features that depend on it. When Location Push Service Extension was introduced for iOS 15+, I adapted accordingly: NSE filtering was used for devices below iOS 15 Location Push Service Extension was used for iOS 15+ NSE filtering also played a crucial role in: ✅ Accepting/rejecting location-based notifications ✅ Checking device settings & location permissions (since location push won’t work without proper permissions) The Issue In November 2024, I created a new developer account to change my business entity. Since then, I’ve been requesting the NSE entitlement repeatedly for four months, but Apple keeps rejecting it. Meanwhile, they approved the Location Push Entitlement, but without NSE filtering, I’m forced to rewrite a huge part of my app’s core functionality. I’ve sent multiple emails explaining my use case, but I keep getting rejected without any clear explanation or workaround. My Ask Has anyone faced a similar issue with NSE entitlement? Are there any alternative approaches to achieve the same functionality? Any advice on how to escalate this to Apple or get proper feedback on why it's being rejected? I’ve invested years into this app, and a forced rewrite would take months. Any help, insights, or contacts who could assist would be greatly appreciated! Thanks in advance! 🙏
0
0
62
Mar ’25
Xcode 16 Automatically Builds & Runs Simulator While Editing Storyboard
I’m experiencing an issue in Xcode 16 where the app randomly builds and runs in the simulator while I’m designing items in the storyboard. Here’s what I’ve tried so far to stop this behavior: Disabled "Show Live Issues" in the General settings Removed all key bindings related to Build & Run in the Key Bindings settings Checked for unintentional shortcut triggers, but nothing seems to be causing it Update XCode from 16.1 to 16.2 Delete Derived Data Despite these actions, Xcode still automatically builds and launches the simulator at unexpected times, disrupting my workflow. Is there any setting or hidden configuration that could be causing this? How can I completely prevent Xcode from running the simulator automatically while editing UI in the storyboard? Would really appreciate any guidance on this!
0
0
107
Mar ’25
Integrating binary inside Framework via SPM
So I will summary an issue one of our clients has asked us on GitHub: https://github.com/pendo-io/pendo-mobile-sdk/issues/233 Project that is a custom framework that uses different SPM packages (one of them is Binary package), we have our main logic inside that framework and we have different targets that use this framework, everything works on the simulator, but running the app on the actual device provokes a crash saying "Binary framework was not found". We have like 20 other SPM packages that work fine, this is the first one we have an issue with. Please note I understand that SPM will not copy paste the Binary for the magic framework as it does for the apps so I suggested to embed it manually. So my question is what the best(easy) way to do it. Please refer to the following issue for more details: https://github.com/pendo-io/pendo-mobile-sdk/issues/233
0
0
91
Mar ’25
Stale Issues, refreshAllObjects() is not working
Hi Experts, Could you please help. Issue at high level: After Editing a View contains a Table entries, saved and hit back button to display View, Table entries are duplicated or displaying previous and current entries together. Here is my Issue in detailed. List view display, clicking on any row, would navigate to DisplayView of a record. I am displaying a table in DisplayView. DisplayView contains "row" as parameter, and it must be initialized in "init" method, where I use row.key and fetch another table (say ColorTab) using Color.Key. DisplayView contains "NavigationView", with Edit button. it displays fetched Colors. example Red and Green. when user click on Edit, it takes to EditPage. user can remove / add colors. Once user made changes, saved and hit back button. Table entries are duplicated or showing previous and current entries. Options tried, a) init method is only triggering 1st time, not triggering when back button clicked, I failed to use FetchRequest outside of init method, I tried on OnAppear too. i didn't trigger. b) Failed to use FetchRequest inside of var Body too. c) tried using viewContext.refreshAllObjects() .. it is not refreshing the table. Could you please help if there is solution for the issue. Thanks, Bhanu
0
0
82
May ’25
launchd_sim and AppleSpell deadlock
I've got a 2019 Intel iMac running Sequoia 15.4.1 and Xcode 16.3. Every time I try to view a storyboard Xcode locks up and beachballs on me. It takes minutes to load the file. When I force-quit Xcode, the report that shows up has this as the reason: Processes reached dispatch thread soft limit (64): launchd_sim [96305] [unique pid 194673], launchd_sim [96260] [unique pid 194628] Deadlock: AppleSpell [1494] thread 0x1df0c4 DispatchQueue 313 -> AppleSpell [1494] thread 0x1df0c4 DispatchQueue 313 Deadlock: AppleSpell [1494] thread 0x1df114 DispatchQueue 86 -> AppleSpell [1494] thread 0x1df114 DispatchQueue 86 Blocked by Deadlock: 1 task - AppleSpell [1494] I'm wondering, why is AppleSpell trying to spell-check a plist file? Is there any way to tell AppleSpell to ignore a file?
0
0
74
Apr ’25
XCFrameworks deploying .a / include to output target directory
Hello Friends, We have a strange bug that Xcode is deploying static binaries from within .XCFramework into the CONFIGURATION_BUILD_DIR An example of our xcframeworks structure is: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AvailableLibraries</key> <array> <dict> <key>BinaryPath</key> <string>libglfw3.a</string> <key>HeadersPath</key> <string>Headers</string> <key>LibraryIdentifier</key> <string>macos-arm64_x86_64</string> <key>LibraryPath</key> <string>libglfw3.a</string> <key>SupportedArchitectures</key> <array> <string>arm64</string> <string>x86_64</string> </array> <key>SupportedPlatform</key> <string>macos</string> </dict> </array> <key>CFBundlePackageType</key> <string>XFWK</string> <key>XCFrameworkFormatVersion</key> <string>1.0</string> </dict> </plist> for open source creative coding toolkit https://github.com/openframeworks/openFrameworks Can you see any issues in the above. Some ideas for me is to generate xcarchive instead of deploying the .a in the xcframeworks, however that does not explain the include being packaged there, so I think this might be a Xcode issue
0
0
175
Mar ’25
Xcode is is throwing error when I run my Unity Build
When I try to build my project in Xcode (from Unity AR) project, it throws me these errors: I feel like I've tried everything to make the LaunchScreen work. I downloaded xcode the night I tried running this build, so the whole deleting and redownloading and restarting everything didn't work. I've tried making sure my macbook and terminal are fully up to date. I literally can't find a solution! Please help!! I will also say, I'm fairly new to App building, Xcode, and Unity. But this does seem like a barrier that is stopping me from testing my project.
0
0
159
Mar ’25