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

Posts under Xcode tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Is it possible to change the Xcode template type?
I've got a few years old app which was created using an Xcode template type of app. I'd like to split the model part of the code (model as in model-view-controller) out into a framework. Removed the view/controller source files to leave the model code is quick and easy, however the model code is large and complex with a couple of hundred of source files. Rather than create a new Xcode template type of framework and move the source files into there, is it possible to simply just change the template type of the existing project from app to framework?
1
0
99
2w
Crashing in WKWebview Often, when the video is loaded in the webview using an HTML file
Hello, Team. We used WKWebView for our project. We loaded the HTML file into the webview and added the following configuration. weak var webView: WKWebView! func configWebView() { let webViewConfig = WKWebViewConfiguration() let controller = WKUserContentController() controller.add(self, name: "sometest") webViewConfig.userContentController = controller webViewConfig.processPool = WKProcessPool() webViewConfig.setValue(true, forKey: "allowUniversalAccessFromFileURLs") webViewConfig.mediaTypesRequiringUserActionForPlayback = [] let webpagePreferences = WKWebpagePreferences() webpagePreferences.allowsContentJavaScript = true webViewConfig.defaultWebpagePreferences = webpagePreferences webViewConfig.websiteDataStore = WKWebsiteDataStore.default() webView = WKWebView(frame: .zero, configuration: webViewConfig) webView.navigationDelegate = self webView.uiDelegate = self webView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(webView) NSLayoutConstraint.activate([ webView.topAnchor.constraint(equalTo: view.topAnchor), webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), webView.trailingAnchor.constraint(equalTo: view.trailingAnchor) ]) loadWebView() } func loadWebView() { guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } let contentFolderURL = documentsDirectoryURL.appendingPathComponent("content") let assetFolderURL = contentFolderURL.appendingPathComponent(interactiveGUID) if FileManager.default.fileExists(atPath: assetFolderURL.path) { let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! let documentsURL = URL(fileURLWithPath: documentsPath) let fileToLoadPath = (documentsPath as NSString).appendingPathComponent("content/index_p.html") let fileURL = URL(fileURLWithPath: fileToLoadPath) autoreleasepool { DispatchQueue.main.async { [weak self] in guard let self = self else { return } self.webView.loadFileURL(fileURL, allowingReadAccessTo: documentsURL) } } } We are experiencing webview crashes when loading an HTML file. What happened when I loaded the video file? It automatically looped. Webview frequently crashes when the HTM/JS file is loaded. When a webview crashes, the delegate method usually calls webViewWebContentProcessDidTerminate. This method calls webview.reload(). Also we are clear and cache/ deallocate eveything when i initialized those configuration mentioned as the above. Can you suggest a solution to this? Why is webview crashing? Thank you.
0
0
121
2w
Can't compile asset catalog when including iMessage App Icon asset
I'm trying to add an iMessage extension to my app, and upon adding the iMessage App Icon set, I ran into an issue with one specific icon size: 1024x768px, aka 1x 1024x768pt. When I remove this one icon from the icon set, it compiles and runs fine, however I can't push it to the App Store as I get the error: "Asset validation failed. Missing Image Asset. Your app is missing the Large App Icon asset 'AppIcon' in 'Payload/Runner.app/PlugIns/MessagesExtension.appex'." I'm assuming this refers to 1024x768px, as this size placeholder appears upon adding a New Messages Extension Icon to my assets folder, and 1024x1024 is already included and compiles fine with it. However, when I add the 1024x768 icon, and try to run the app, I get the error: "Command CompileAssetCatalog failed with a nonzero exit code" The app icon's filename is correct, it is exactly 1024x768 px, and my contents.json correctly includes : { "filename" : "AppIcon_1024x768.png", "idiom" : "ios-marketing", "platform" : "ios", "scale" : "1x", "size" : "1024x768" } as is the same format for all of my other icons that work. Why am I running into this issue upon inclusion of this one required size? How do I fix it?
1
0
160
2w
Debugging a macOS IPS dump
I have a macOS application built via command line (xcodebuild) using Xcode 16.1. Developed on ARM but end user is on Intel (same macOS 15.1). App crashed and they sent me a .IPS dump. From what MacGPT tells me: Reading an IPS (Incident Processing System) file from a macOS crash report in Xcode isn’t as straightforward as with iOS device logs. I can open the dump using Console. I see the IPS dump is partially symbolicated. Line in the dump says: Meteorologist 0x103e0348f 0x103d88000 + 504975 Referencing this article: Adding identifiable symbol names to a crash report | Apple Developer Documentation I run this command and see the same UUID for x86_64 as in the dump. dwarfdump --uuid /Users/ed/meteorologist/trunk/Build/Meteorologist.xcarchive/dSYMs/Meteorologist.app.dSYM/Contents/Resources/DWARF/Meteorologist I run this command: atos -arch x86_64 -o /Users/ed/meteorologist/trunk/Build/Meteorologist.xcarchive/dSYMs/Meteorologist.app.dSYM/Contents/Resources/DWARF/Meteorologist -l 0x103d88000 0x103e0348f And it says: fg: no current job Suggestions for what I’m missing?
1
0
120
2w
Adding a Safari Extension to Capacitor iOS App as an Application Extension
Hello everyone, I’m working on adding a Safari extension as an application extension to an iOS app created using Capacitor (generated from a React app). My goal is to bundle the Safari extension within the Capacitor app, allowing it to serve as a companion app for the extension. However, I’ve run into issues where the extension does not show up in Safari's extension settings when I run the app on a device or simulator. Here's an overview of what I’ve done so far: I initially used Capacitor’s command line tools to generate the iOS app from my React project. This app runs fine on its own. To add the Safari extension, I’m not developing a platform-specific extension from scratch; instead, I used the Xcode command line to convert a Chrome extension to a Safari iOS extension. The converted extension functions correctly if paired with the default Swift app that comes with the conversion. Right now, I effectively have two products: The base Capacitor app (without the extension), which I want as my main app. The standalone Safari extension bundled with the Swift app (from the conversion process). My question is: How can I merge these two products so that the Capacitor app becomes the companion app for the Safari extension, allowing the extension to show up in Safari's settings? Are there specific configurations I should adjust in Xcode or within the manifest files to make this work seamlessly? Any guidance or best practices from others who have integrated Safari extensions into non-Xcode-based projects would be much appreciated! Thank you!
1
0
197
2w
How to force update data from child phone ? FamilyControls / Screen Time Api / DeviceActivity
The data displayed about a child’s apps can be outdated (DeviceActivityReport), leading to misinformation for the user. When I access the “Screen Time” section (for child in the parent device) in the iPhone settings, I see there is an update functionality to force load the actual data. I have tried various workarounds, such as attempting to force an update on the child’s device to call DeviceActivityReport and opening system settings, but none of these have been successful :( How can I implement something similar? Is there a way to force update this data ?
0
2
162
2w
Cannot delete iOS 18.1 Simulator
When I try to delete an iPhone 16 Pro iOS 18.1 Simulator in XCode 16.1, I get an error message "“data” couldn’t be moved because you don’t have permission to access “Deleting-8366D3CC-37EC-49C0-8674-0599BCE1DA12”.". I had that same issue with iOS 18.0 Simulator but never with previous versions (17.5). Note that I'm stuck using the iOS 18.1 Simulator because iCloud synchronization is paused (potentially due to low data mode). And I cannot use iOS 18.0 Simulator as well because unit tests run hangs for some other mysterious reason. The fallback to iOS 17.5 Simulator is not satisfactory.
1
3
309
2w
iOS Simulator Safari JS PushManager.subscribe(...) empty keys
When I run the following code in XCode iOS Simulator on Safari (connecting via Safari DevTools): navigator.serviceWorker.ready.then((reg) => reg.pushManager.subscribe({ userVisibleOnly: true, applicationServiceKey: "..." }).then((sub) => console.log(sub.toJSON()))) I get the response: { keys: { p256dh: "", auth: "" } } But I'm expecting p256dh and auth (and endpoint) to be filled out. Why is it not?
0
1
145
2w
AccessibilityControlsExtension crash on Simulator
Hi there, when I run any app on the Xcode 16/16.1 with iOS/tvOS 18/18.1, it generates a crash on the AccessibilityControlsExtension process. 0x1048b8000 - 0x10493bfff dyld (*) <6beafde4-b011-3e47-8aae-4d7b6e4bb7e8> /usr/lib/dyld 0x1047fc000 - 0x104803fff com.apple.AccessibilityUIServer.AccessibilityControlsExtension (1.0) <a67e159b-253d-306c-b6fb-dd3fec38bd0f> /Volumes/VOLUME/*/AccessibilityUIServer.app/PlugIns/AccessibilityControlsExtension.appex/AccessibilityControlsExtension If run in Catalist mode - there are no crash reports. I also made a clean install of macOS 15.1 + Xcode and received that error again. Device: Mac15,13 Any suggestions on how to fix it? Full crash log in attach. AccessibilityControlsExtension-crash.log
1
2
156
2w
Send UDP Protocol is not working in Xcode 16 iOS18
func setupUDPSocket() { stopSearch() udpSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: DispatchQueue.main) do { try udpSocket?.bind(toPort: 4012) try udpSocket?.beginReceiving() try udpSocket?.joinMulticastGroup("239.255.255.250") } catch let error { DispatchQueue.main.async { print(Thread.current) print(error) print(error) } } } private func search() { guard let udpSocket = udpSocket else { print("not set udpSocket") stopSearch() return } let message = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "MX: 3\r\n" + "ST: ssdp:all\r\n" + "\r\n" let data = message.data(using: .utf8)! udpSocket.send(data, toHost: "239.255.255.250", port: 1900, withTimeout: -1, tag: 0) } This is my send SSDP code, my project was inited in Objective-C, recently I update xcode to 16, I get Error Domain=NSPOSIXErrorDomain Code=65 "No route to host", when I send UPD data in iOS 18, but iOS 17 is ok. Even I found, if I init a new project in Swift, this bug is disappear.
1
0
180
2w
Crash due to missing symbols from libc++ [macOS 11.7.10] [Big Sur]
We are seeing a crash on Big Sur 11.7.10 after switching the build system to use Xcode 15 Excerpt from crash Time Awake Since Boot: 1700 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: DYLD, [0x4] Symbol missing Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Symbol not found: __ZNSt3__17codecvtIDiDu11__mbstate_tE2idE Referenced from: /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon Expected in: /usr/lib/libc++.1.dylib in /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon Build system has the following specs : ProductName: macOS ProductVersion: 14.3.1 BuildVersion: 23D60 Xcode 15.2 Build version 15C500b CMAKE PROPS set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
5
0
319
2w
Setting up app lunch argument using ProcessInfo.processInfo.arguments not working in iOS 18
Hi, I'm trying to set up FIRDebugEnabled as launch arguments in app delegate based on user choice using ProcessInfo.processInfo.arguments. Which is working fine in iOS 17 and below devices and stoped working in iOS 18 Here is my sample, if condition { var arguments = ProcessInfo.processInfo.arguments arguments.append("-FIRDebugEnabled") ProcessInfo.processInfo.setValue(arguments, forKey: "arguments") }
2
0
212
2w
iOS simulator freezes on macOS Sequoia during test execution
Hello! 👋 We are seeing a bug on macOS Sequoia related to the test running. When attempting to run tests, the iOS simulator becomes stuck indefinitely. This can occur whether we run tests for a specific module, all unit tests, or even a single test. We narrowed down the issue and is due to the OS failing to copy some named pipes (FIFO). For example: db.realm.note db.realm.management/access_control.new_commit.cv db.realm.management/access_control.pick_writer.cv We saw in the CoreSimulator log file the following error: NSCocoaErrorDomain Code=512 ""access_control.new_commit.cv" couldn't be copied The copy fails and then a new clone of the simulator is created retrying the process. And this goes on and on. What is happening? When running the tests for the iOS app on the simulator, under the hood, the OS tries to clone the simulator device. A list of folders is created, including one Shared/AppGroup. Under the AppGroup folder, the list of multiple UDIDs corresponds to the specific App Group containers created for individual app targets or extensions that are sharing data within that App Group. One of these folders contains the Realm DB files. There are a few files called named pipes which are invisible in Finder (even if you have hidden files to true). You need to list them with ls -l. So, when we select the test target and run the tests, the OS clones the permanent simulator and copies all files from its folders. All files are being copied except those pipes. When the OS attempts to copy the pipes, the operation fails with the error Code=512. Reproduction Steps Run the iOS app on a simulator (e.g. iPhone SE 3rd gen. with iOS 18.1). Quit Xcode and the iOS simulator. Reopen Xcode. Select a test target to run. Select the same simulator you previously ran the iOS app. Run the tests (CMD + U). The simulator is now stuck. Are there any workarounds available? Yes. We found that running the tests works if we first “Erase All Content and Settings” from the simulator. Another workaround is to remove all simulators and reinstall the iOS runtimes. This prevents the issue for a longer period (almost a full day), but eventually, the problem reoccurs. Alternatively, we can delete the named pipes from the App Groups directory before running the tests. Have we tried to give full disk permissions? Yes, we tried to give full disk permissions to a lot of things (Xcode, simulator, file paths, directories, etc.) but with no luck. We still get the same error. Is the issue happening on a specific version of Xcode? No, it happens for multiple Xcode versions: Xcode 15.4 Xcode 16.0 Xcode 16.1 Is the issue happening on a specific macOS Sequoia version? No, it happens on multiple macOS Sequoia versions: 15.0 Beta 8 15.0 RC 15.0 15.1 Stacktrace Oct 29 17:41:18 CoreSimulatorService[14079] <Error>: New device is stuck in creation state, deleting: Clone 712 of iPhone SE (3rd generation) (58D6DED6-2C55-4E7C-BBB4-E0D661DC41A1, iOS 18.1, Creating) Oct 29 17:41:20 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:20 com.apple.dt.Xcode[90147] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:30 CoreSimulatorService[14079] <Warning>: Device 6C270BDB-2945-42B5-A985-884F93BFD3E1 encountered in creation state at launch. The device will be re-created. Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to re-create device that was encountered in the creation state (Clone 713 of iPhone SE (3rd generation) (6C270BDB-2945-42B5-A985-884F93BFD3E1, iOS 18.1, Creating)): Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:41:40 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:50 CoreSimulatorService[14079] <Warning>: Device C6DEBFBB-6EFA-4E4C-B51B-9DDA08AF9BDB encountered in creation state at launch. The device will be re-created. Oct 29 17:41:55 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffb000 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:42:06 CoreSimulatorService[14079] <Warning>: Device 032BAE7E-E345-48F2-86EB-4DF1AD4D5291 encountered in creation state at launch. The device will be re-created.
0
0
181
3w
Xcode fails to compile visionOS app that has a Front layer in AppIcon asset
I'm trying to create the app icon for my visionOS app. The Assets catalog already contains AppIcon for iOS and I've added another AppIcon for visionOS. If I only add the Back layer of the visionOS icon, compiling succeeds despite there being an error The visionOS App Icon "AppIcon" must have at least 2 layers with applicable content. Although it has 3 layers, only 1 has applicable content. As soon as I add one of the other two layers, say the Front layer, compiling fails, but this time Xcode only shows a generic compiler error Command CompileAssetCatalogVariant emitted errors but did not return a nonzero exit code to indicate failure If I click that message, a long build log opens containing among other things: 2024-10-31 11:28:15.258 AssetCatalogSimulatorAgent[66919:1456355] -[TDTextureRawRenditionSpec _createImageRefWithURL:andDocument:format:] Texture image asset file:///~/Documents/apps/myApp/xcode/iOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/icon_layer3.heic not in one of supported formats ... libc++abi: terminating due to uncaught exception of type NSException Command CompileAssetCatalogVariant failed with a nonzero exit code What is the problem? I filed FB15642844.
0
0
118
3w
Xcode 16.1 & iOS 18.1
After upgrading to mac os 15.1 my Xcode has been complaining about iOS 18.1 that is missing. No matter what I do I cannot get it installed, I ended up clearing all caches, re-installing Xcode but that also failed. Downgrading to 16.0 or upgrading to 16.2 beta has the same issue. Currently I cannot create any simulator or install any version of the iOS platform. Xcode would say it's installing but the runtime would not show up in the list. I have tried adding runtimes using xcrun simctl and also other methods indicated here. Another colleague of mine that updated to OSX 15.1 also has the same issue so this doesn't seem like a isolated problem. In the screenshots below you'll see 18.1 is installed but does not show up as an installed runtime.
7
3
1.5k
3w
How to use a lower version macos SDK?
My macos update automatically and the new macos SDK are not fit for my program, so how to use a lower version macos SDK? And I have another problem, once I installed Xcode, the SDK will be set path to Xcode path, also I have a command line path which is /Library/Developer/CommandlineTools. In this path, there is also a SDKs directory which contains some different versions of macos SDK? How to set a default SDK path?
2
0
162
2w