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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

ASWebAuthenticationSession not working in Preview
class ViewModel : NSObject, ObservableObject, ASWebAuthenticationPresentationContextProviding { private var authSession: ASWebAuthenticationSession? func signInWithOpenID(provider: OAuthProvider) { let url = getOIDCAuthenticationURL(provider: provider) authSession?.cancel() authSession = nil authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: "com.ninjanutri") { callbackURL, error in if let error = error { print("Error: \(error.localizedDescription)") return } guard let callbackURL = callbackURL else { return } guard let idToken = callbackURL.valueOf("id_token") else { return } self.signInWithIdToken(provider: provider, idToken: idToken) } authSession?.prefersEphemeralWebBrowserSession = false authSession?.presentationContextProvider = self authSession?.start() } public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { return ASPresentationAnchor() } } struct ContentView: View { @StateObject private var viewModel = ViewModel() var body: some View { Button { viewModel.signInWithOpenID(provider: .github) } label: { Text("Test") } } } when the prefersEphemeralWebBrowserSession is false, the alert and webview is totally working fine in Simulator and Real device, but not XCode Preview. Is this behaviour expected or it's a bug?
1
0
473
Dec ’24
How to -disable-dynamic-actor-isolation FLAG
I built my app with Xcode16 and now the app is crashing. I suspect that the dynamic actor isolation check is the cause, so I'm trying to set the "-disable-dynamic-actor-isolation" flag, but the app crashes, so I don't think I'm setting it correctly. How to set "-disable-dynamic-actor-isolation" flag? Swift Complier - Custom Flags Other Swift Flags Debug Any Architecture | Any SDK -disable-dynamic-actor-isolation Release Any Architecture | Any SDK -disable-dynamic-actor-isolation I have it set up as shown above.
1
1
180
Dec ’24
Xcode 构建失败:无法加载传输的 PIF,GUID 冲突错误
在使用 Xcode 构建项目时,我遇到了以下错误: Showing All Errors Only Prepare packages Prepare build Build service could not create build operation: unable to load transferred PIF: The workspace contains multiple references with the same GUID 'PACKAGE:1Y9CU7L2QFO7OX4UJBYP19ZPPL5MJNV3R::MAINGROUP' Activity Log Complete 2024/12/24, 15:26 0.2 seconds 问题描述: 1. 我正在开发一个使用 Swift Package Manager (SPM) 管理依赖的多模块 iOS 项目。 2. 构建过程中,Xcode 无法加载传输的 PIF 文件,并提示某个 GUID 存在重复引用。 3. 这个问题导致整个项目无法正常构建。 已尝试的解决方案: 1. 检查了 Swift Package Manager 的依赖管理: • 确认没有重复添加相同的依赖。 2. 清理了 Derived Data: 3. 检查了 project.pbxproj 文件,搜索 GUID 'PACKAGE:1Y9CU7L2QFO7OX4UJBYP19ZPPL5MJNV3R::MAINGROUP': • 没有发现明显的重复引用。 4. 删除并重新添加了所有的 Swift 包依赖。 5. 删除并重新生成了 .xcworkspace 文件。 结果: • 尝试以上解决方案后问题依然存在,构建仍然失败。 • 这可能是由于某些依赖的重复引用或 Xcode 内部的问题。 Xcode 16.2 Mac OS 15.2 如果有人遇到过类似问题或者知道该如何解决,能否分享一下解决方案? 非常感谢!
1
1
1.1k
Dec ’24
How to -disable-dynamic-actor-isolation FLAG
When I built my app with xCode16.2, the app crashed at runtime. When building, I got a warning "UIWebView' is deprecated: first deprecated in iOS 12.0 - No longer supported; please adopt WKWebView.", so I suspected the dynamic actor isolation check. When building, I tried setting the "-disable-dynamic-actor-isolation" flag, but the app still crashed. However, I think the flag is not set properly, so how should I set the "-disable-dynamic-actor-isolation" flag? I tried setting it as follows. Is this the correct way to set it? Swift Compiler - Custom Flags Other Swift Flags Debug Any Architecuture | Any SDK -disable-dynamic-actor-isolation Release Any Architecuture | Any SDK -disable-dynamic-actor-isolation
0
0
192
Dec ’24
Some colors are missing during first app launch
Recently I decided to download my app from the App Store and found out that during the first launch some colors were missing or displayed incorreclty. For example one button was blue, although switching dark mode on and off solved button color it. Some colors were completely missing and the tab bar buttons were blue as well. Any advices? I'm using iOS 18.2 and XCode 16.1
1
0
347
Dec ’24
Xcode version 14.2 crashes as soon as opened in mac os 15.0.1
I have downloaded xcode version 14.2 from apple official archive. I ran xcode using these steps: Right click -> Show Package content Go to folder Contents -> Macos -> Xcode Run the xcode terminal app After this as soon as I try to open a project, xcode crashes. How do i run xcode of lower version as that specific version is required, I don't want to downgrade my macos as it will result in clearing my data or I have to transfer data. Please help me with this issue.
1
0
342
Dec ’24
Apple Watch Connectivity Issues XCode
Whenever I try to build on my Apple Watch using Xcode, I often encounter connection issues. It typically takes about an hour of troubleshooting, including restarting devices, restarting Xcode, erasing the Apple Watch, and other steps. I was wondering if anyone else has experienced similar problems and if there are any effective solutions.
0
1
547
Dec ’24
you don't have permission to view it
there are other unresolved posts on this issue but maybe mine is solvable. I copied the files I contributed from a working project to a new project using the finder (drag and drop). So I did not copy entitlements. Xcode automatically added the files to the project just fine. My app uses data on a removable drive, or used to, because I now get the error above. At one point I copied the product app to the desktop hoping to get the permissions alert window, but it never came. Oddly, in System Settings/Privacy & Security/Files & Folders my "new" app is listed with "Removable Volumes" slider = on. The file permissions (unix-like) on that drive haven't changed between projects and allow everyone to read. How can I fix this?
3
0
487
Dec ’24
Has `xcodebuild -showdestinations` been changed since macOS Sequoia?
Hi, I just upgraded MBP M3 Pro and mac mini M1/M2 to macOS 15.1 Sequoia and these macs not showing its available destination candidates after update. DEVELOPER_DIR=`xcode-select -p` xcodebuild -scheme myapp -derivedDataPath ./derived_data -showdestinations Command line invocation: /Applications/Xcode/Xcode_16.2.app/Contents/Developer/usr/bin/xcodebuild -scheme myapp -derivedDataPath derived_data -showdestinations User defaults from command line: IDEDerivedDataPathOverride = /path/to/myapp/derived_data IDEPackageSupportUseBuiltinSCM = YES Available destinations for the "approduce_calc_v2" scheme: { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00006020-001971C422C3C01E, name:My Mac } { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device } { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device } While my macs got all the simulator runtimes/devices installed and available. $ DEVELOPER_DIR=/Applications/Xcode/Xcode_16.2.app xcrun simctl list devices == Devices == -- iOS 17.5 -- iPhone 15 Pro (48C3EFC6-2B93-4C9D-8C7B-F841CE09E901) (Shutdown) iPhone 15 Pro Max (E2C4D8AA-BF0A-42B4-9D83-70F0CFD21934) (Shutdown) iPhone 15 (350882E2-5A78-47E7-879F-E548F8810386) (Shutdown) iPhone 15 Plus (9FE3F7F6-FAC0-4ACA-96A6-0E8DBBA17068) (Shutdown) ... and in my other macs, still in Sonoma 14.5, xcodebuild -showdestinations command still works well(shows the entire list of available simulator devices). My question is: Did you change the specs of xcodebuild -showdestinations command from the ones working in macOS Sequoia, not to show all the destinations available?
1
0
843
Dec ’24
Error downloading the Predictive Code Completion Model
Hi, I'm setting up Xcode and after updating MacOS to 15.2 and Xcode to 16.2, I cannot download the Predictive Code Completion Model. I've done some research and I haven't found any solution, specially since most people suggest that it randomly fixed itself, which for me hasn't been the case. I've tried restarting my Mac, uninstalling and reinstalling Xcode multiple times, I've also reinstalled MacOS from Recovery and haven't found any success (I'm also not running Xcode inside a VM, as I've seen this can cause some problems in this case). This is the error that I receive when I attempt to download the model: And here are the details: The operation couldn’t be completed. (IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $11eba9a90).DownloadError error 3.) Domain: IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $11eba9a90).DownloadError Code: 3 User Info: { DVTErrorCreationDateKey = "2024-12-26 23:09:25 +0000"; } -- There was an error processing the asset. Domain: IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $11eba9a90).DownloadError Code: 3 -- System Information macOS Version 15.2 (Build 24C101) Xcode 16.2 (23507) (Build 16C5032a) Timestamp: 2024-12-26T17:09:25-06:00 For the record, I'm a new developer and I'm still learning, so thank you very much!
4
5
1.1k
Dec ’24
Mac App getting error - Could not launch “App Name” with Xcode 16.2 and Mac sequoia
Mac App getting error - Could not launch “App Name” with Xcode 16.2 and Mac sequoia Error - Could not launch “App Name” Domain: IDELaunchErrorDomain Code: 20 Recovery Suggestion: LaunchServices has returned error -54. Please check the system logs for the underlying cause of the error. User Info: { DVTErrorCreationDateKey = "2024-12-27 12:16:34 +0000"; DVTRadarComponentKey = 113722; IDERunOperationFailingWorker = IDELaunchServicesLauncher; } The operation couldn’t be completed. (OSStatus error -54.) Domain: NSOSStatusErrorDomain Code: -54 User Info: { "_LSFunction" = "_LSOpenStuffCallLocal"; "_LSLine" = 4224; }
1
1
319
Dec ’24
Xcode simulator & preview not loading
Hello, I recently decided to start learning how to code for iOS. I don't have much coding experience but I still wanted to explore it for fun at least. I downloaded Xcode on my Macbook, and opened a new iOS file after downloading iOS 18.1 so I could run the simulator/get a preview of my code. Even though I only had the basic "Hello World!" that is auto-generated in my code, the preview would never show and sat at a loading screen for multiple hours, saying "Preparing (Automatic) iPhone Simulator" at the top. There is probably a simple solution that I'm missing. I would appreciate any tips! Thanks.
2
0
929
Dec ’24
Xcode 15 preview loads indefinitely
I've recently started learning how to make IOS apps, but when trying to load the preview, it just shows the loading animation indefinitely. I am running xcode 15.2 (because my mac is a bit old and doesn't run the latest version) I have tried using version 15.1 but it still doesn't work, only works when I go down to version 14.3.1, but that changes the swift code.
1
1
531
Dec ’24
Cannot find 'detailline' in scope
I'm using xcode 16 with swift. I'm trying to call a function in another file. It used to work. Now I'm getting: Cannot find 'detailline' in scope. Detailline is the function I'm calling. I just added variables to the top. I have since deleted them. Please help.
9
0
531
Dec ’24
Widget Extension scheme causes "failed to find valid container bundle" errors when ran
I've got a macOS app with a Widget Extension. When I try to run the scheme attached to this extension, WidgetKit Simulator "unexpectedly quits" and I get plenty of errors such as the ones below, that do not seem to be at all linked with the purpose nor the functionalities explicitly used by the app (nor the extension). That's what I get in Xcode's console: com.apple.siri.AssistantSettingsControls failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/AssistantSettingsControlsExtension.appex/ at /System/Library/ExtensionKit/Extensions/AssistantSettingsControlsExtension.appex com.apple.settings-intents.LoginItemsIntents failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/LoginItemsIntentsExtension.appex/ at /System/Library/ExtensionKit/Extensions/LoginItemsIntentsExtension.appex com.apple.SoftwareUpdate.SoftwareUpdateSettingsWidget failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/SoftwareUpdateSettingsWidgetExtension.appex/ at /System/Library/ExtensionKit/Extensions/SoftwareUpdateSettingsWidgetExtension.appex com.apple.settings-intents.PrinterScannerIntents failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/PrinterScannerIntentsExtension.appex/ at /System/Library/ExtensionKit/Extensions/PrinterScannerIntentsExtension.appex com.apple.settings-intents.WallpaperIntents failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/WallpaperIntentsExtension.appex/ at /System/Library/ExtensionKit/Extensions/WallpaperIntentsExtension.appex com.apple.settings-intents.ScreenSaverIntents failed to find valid container bundle for file:///System/Library/ExtensionKit/Extensions/ScreenSaverIntentsExtension.appex/ at /System/Library/ExtensionKit/Extensions/ScreenSaverIntentsExtension.appex In the error log (Console crash logs), the error description: Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x000000010428507c Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [31252] I have observed that even if I try creating a new blank project and add a Widget Extension (keeping everything default) and try to run the scheme, I end up (after setting IDEPreferLogStreaming to YES in the environment variables) with the exact same errors. What is the issue? How can I fix it?
1
2
455
Dec ’24
undefined symbol errors
hello, when i try to archive my unity game through xcode to publish it on app store connect i get these 4 undefined symbol errors: undefined symbol:_initializeclass, undefined symbol: _initializeunityobject, undefined symbol: _onrequestasync, undefined symbol: _onrequestsync. is there anyway to get rid of this error ? the only solution i found was enabling module verifier in build settings but when i do that i get this error:error: Sandbox: mkdir(24068) deny(1) file-write-create , i get rid of this by choosing no to user script sandboxing in builds settings, but when i do that i get these errors: double-quoted include "LifeCycleListener.h" in framework header, expected angle-bracketed instead, "RedefinePlatforms.h can only be used after UndefinePlatforms.h got included before.", double-quoted include "RenderPluginDelegate.h" in framework header, expected angle-bracketed instead, umbrella header for module 'UnityFramework' does not include header 'RedefinePlatforms.h', umbrella header for module 'UnityFramework' does not include header 'RedefinePlatforms.h', fatal) could not build module 'Test'. what should i do ?
2
1
1.1k
Dec ’24
Xcode 16.2 not running unit tests
I update my Xcode to latest 16.2. However I am unable to run the unit tests which were working fine when I used Xcode 15. Also I am using a CI/CD tools which has Xcode 15.3 and also using iOS 17.5 device to run unit tests and those are also working fine. I am getting following 3 different types of errors when I try running tests. Command SwiftCompile failed with a nonzero exit code Command SwiftEmitModule failed with a nonzero exit code PhaseScriptExecution failed with a nonzero exit code Any help how I can fix this?
3
1
1.2k
Dec ’24