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

Xcode Documentation

Post

Replies

Boosts

Views

Activity

Issues with SwiftData @Relationships in Swift Testing
Is it a known issue that when attempting to test SwiftData objects with relationships in Swift Testing there are errors that do not occur when the app is running? Example: @Relationship(deleteRule: .cascade, inverse: \MBAccount.book) var accounts: [MBAccount] = [] and @Relationship var book: Microbook? Then the test: let book = Microbook(name: "Julia's Cupcakes") let account1 = MBAccount(name: "Chase Business Account") let account2 = MBAccount(name: "Cash Drawer") account1.book = book account2.book = book #expect(account1.name == "Chase Business Account") #expect(account2.type == "asset") } Produces a fatal error while running test: SwiftData/PersistentModel.swift:321: Fatal error: Unable to find relationship on MBAccount for KeyPath \MBAccount.book Any ideas?
0
0
13
3h
UI Tests Runner application does not launch manually.
I need to run my tests bundle independently from Xcode. Previously, I used to deploy it and run as regular iOS application, it would execute test cases and display 'Automation running' label. I needed to execute tests some time after deploy and in different time of the day, so it is a problem for my team right now. So, UI Tests Runner app file does not launch and 'Automation Running' label is not displayed, is there any possible ways to run tests as it was or other ways to run tests not from Xcode.
0
0
30
5h
Crash in Xcode code review
Crash in Xcode code review When you enable Enable Code Review in the upper right corner of Xcode, Xcode crashes or loads infinitely. I don't think this problem existed in previous versions of Xcode, but it is very serious in the current version 15.4. It doesn't crash in all parts of Code Review, but Xcode crashes or loads infinitely in certain parts. I really hope this will be fixed in the next Xcode version. It happens so often that I'm going crazy. Seriously Especially if there are many or wide changes in the swift file, the crash occurs in that part.
0
0
36
8h
xcodebuild segmentation fault
I am getting a segmentation fault with xcodebuild: 2024-06-17 17:08:52.749 xcodebuild[26052:114044] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path "/var/folders/m0/fb9pgvx50vngfz_tcpgyxzhw0000gn/T/macnbagent_2024-06-17_17-08-52.747.xcdistributionlogs". zsh: segmentation fault /usr/bin/xcodebuild -exportArchive -archivePath -exportOptionsPlist Version: xcodebuild -version Xcode 15.4 Build version 15F31d Is there any know segmentation fault bug with xcodebuild?
0
0
47
12h
Running application on 17.4 Simulator from Xcode 16.0 beta is crashing due to missing SwiftUICore.framework
Hi, I have a project that is pretty complex and includes mostly UIKit/Swift code with some SwiftUI added on top. I also have some SPM modules and internal Cocoapods libraries linking in. The project builds fine with the latest release version of Xcode (15) and runs on 17.4 simulator. WIth Xcode 16.0 Beta however, the project builds and runs fine on iOS 18 simulators, however there is a specific crash that happens at startup on iOS 17.4 simulators. Please see crash log below with the name of my application redacted: dyld[91294]: Library not loaded: /System/Library/Frameworks/SwiftUICore.framework/SwiftUICore Referenced from: <14C085D7-ECA8-3287-8038-5DE320ADCEBD> /Users/xxxxxx/Library/Developer/CoreSimulator/Devices/C23AA8A9-8475-4EE2-86B3-136A0EBCC362/data/Containers/Bundle/Application/95A49FCF-A7E3-4A8B-93F1-C4CDDBA74B60/xxxxxx.app/Frameworks/SwiftUI_Common.framework/SwiftUI_Common Reason: tried: '/Users/xxxxxx/Library/Developer/Xcode/DerivedData/xxxxxx-fglltpkbphqqjzgdgdadysinonmq/Build/Products/Debug-iphonesimulator/SwiftUICore.framework/SwiftUICore' (no such file), '/Users/xxxxxx/Library/Developer/Xcode/DerivedData/xxxxxx-fglltpkbphqqjzgdgdadysinonmq/Build/Products/Debug-iphonesimulator/PackageFrameworks/SwiftUICore.framework/SwiftUICore' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file), '/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file, not in dyld cache), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file) It seems like for some reason Xcode is building the app thinking there would be a SwiftUICore.framework on device, but since this framework is new in iOS 18 and does not exist on iOS 17.4, the system is unable to find it and crashes. I have the min deployment target set to iOS 14.5, so I'm not sure why Xcode would make the assumption that SwiftUICore.framework will be available for linking on runtime. Interestingly, I cannot reproduce this same issue on a clean project created using Xcode 16 and targeting min deployment of iOS 15. I was wondering if anyone has any suggestions regarding specific build settings to check and see where the issue might be coming from. Thanks
0
0
37
13h
Gather Crash Logs for Tunnel Extension
Our iOS app also has a Safari Extension and a Packet Tunnel Extension. When trying to gather crash logs from the packet tunnel extension, we get an error like: ***@***[dot]com failed with error: Access Restricted. Even the account holder account was unable to access these crash logs. Is there any access level that does allow access, or are they restricted in all cases for all permission levels?
0
0
35
17h
How to configure Signin with Google in Xcode 15 for IOS
I'm working on my 1st IOS app and I'm trying to follow the instructions from: https://developers.google.com/identity/sign-in/ios/start-integrating It instructs me to edit the info.plist file but I can't find it in my project (it appears that Xcode 15 doesn't generate the file anymore?). Do I have to add the Google client IDs somewhere else in the UI? If yes, does anyone have links to a step-by-step instruction on how to do it? I'm really new to this. Thanks!
0
0
30
18h
Xcode 15.4 from the App Store will not open on MacOS 14.5
Howdy! New Apple developer here, running a MBP 2023 M2. A year ago I used Xcode to test a Flutter app I was working on, as well as a Godot app I was making. It worked fine to open, edit, and test those projects in the simulator. Today I attempted to open Xcode and it would never load past the following window: I let it sit there and spin for probably 30 minutes while I did other tasks, but it never changed. Here is what I tried after discovering the issue: Google various generic terms relating to "No selection" and "xcode". Restart the computer. No change. Update MacOS. I hadn't updated to the latest 14.5. No change afterward when opening Xcode. Update Xcode. I updated to the latest version in the App Store 15.4. No change after update. Remove Xcode (move app to Trash from Applications, remove Library/Developer, empty trash) and fresh install from App Store. No change when opening Xcode. Reinstall command line tools (since they were removed in step 3) "xcode-select --install" and then used the UI to continue install. No change. I can't really think of what else to do, as there's not a lot of information to go off of. I don't even know what that loading screen is supposed to show when it works (maybe a list of recent projects?). All options on the Xcode menu bar and the window itself are unresponsive and just show the spinning beach ball as the cursor. What else can I do to 'reset' Xcode, and/or to clear out whatever files are preventing it from loading? Thank you in advance!
3
0
62
19h
Binding to Shared User Defaults might fail in Xcode storyboards
While binding to the Shared User Defaults in .xib files is very easy I had hard times to achieve application wide preferences in projects based on storyboards. The behavior is a bit strange/unexpected and even in Xcode 15.4 it seams not to be completely solved. Issue is that IB only creates a single instance of a Shared User Default controller for the first scene, where it was requested and linking to this instance from other scenes offers no functionality. Even worse IB suggests this as first binding proposal. Here an example to deal with this issue. add slider and label to view of ViewController in IB storyboard add MenuItem to windows menu in the Application Scene When running the app this menu item remains disabled as no action is connected bind value of the created menu item to the Shared User Defaults with Model Key Path: “showTerminal“ This creates a Shared User Defaults Controller instance that we use later. Now running the app the menu item is enabled and the checkmark toggles each time add a checkbox to the view add a User Default Controller to the View Controller Scene This must be repeated for any further Window- or View- Controller scene where a binding to the user defaults is required. bind the checkbox to the newly added User Defaults Controller (but not the Shared User Defaults Controller) keeping the suggested Controller key values and set the Model Key Path to “showTerminal“ as above now bind the slider and the label to the same User Defaults controller using an identical Model key If accidentally bound to the Shared User Defaults Controller (this is what IB suggests) no functional binding will take place! Register the defaults early (before the nib is being loaded) to set default values like for example: class AppDelegate: NSObject, NSApplicationDelegate { override init() { super.init() UserDefaults.standard.register(defaults: [ "first": 0.0 , "showTerminal": false ] ) } … } [https://github.com/MissingManual/UserDefaultsBindingsInStoryboard] ATTENTION: Suggestion is, to create the first Defaults Controller as a Shared User Defaults Controller inside the Application scene. Somehow Xcode remembers settings of the Shared User Default Controller and otherwise bindings might fail. MESSAGE: Never bind to the “Shared User Default Controller“ but to individually created “User Default Controller“ for every scene, unless it is the very first time. Alternatively you can set a let variable as @objc let defaults = UserDefaults.standard for example in each ViewController and then bind to this by Bind to: ViewController Controller Key: Model Key Path: defaults.
0
0
38
23h
Enable code coverage in the build settings of a particular target
We got an app that uses DriverKit. So we have the main target of the app and another target for DriverKit. We would like to turn on code coverage for testing. To do so we enable it in the scheme settings. Unfortunately this doesn't work because DriverKit doesn't support code coverage option. This happens because all settings set in the scheme settings get carry out for all the targets. So this the error you get: File cannot be open)ed, errno=2 path=/Applications/code.app/Contents/Developer/Toolchains/XcodeDefault.ctoolchain/usr/lib/clang/15.0.0/ lib/darwin/libclang_rt.profile_driverkit.a in '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/ 15.0.0/lib/darwin/libclang_rt.profile_driverkit.a' After talking with a couple of Apple engineers ( thanks for your help btw :) ) about a similar problem related with Address Sanitiser, they helped me adding a custom setting in build settings for the main target so address sanitiser can be enabled only for the main target. Unfortunately we didn't have enough time to cover the code coverage problem and they suggested to post a question in this forum to find out the KEY to set up code coverage in build settings Thanks
1
0
51
1d
XCode 16 Explicitly Built Modules Not Affecting SPM Package
Hi all, XCode 16 introduced a new build system that seeks to improve build times and reliability. Following the WWDC 24 talk “Demystify Explicitly Built Modules”, I installed XCode 16 Beta 1 and opted in to the new build system for my project by enabling the Explicitly Built Modules build setting for all targets (just to be sure). However, when inspecting the build logs, it seems that the new system is not taking effect as, for example, there are no Scanning Dependency tasks. I have already tried cleaning the build folder and derived data, restarting XCode, and restarting my computer. For reference, my app’s code is wrapped in an SPM package, very similar to the set-up used in the isowords project. I was expecting that the new build system would explicitly build the modules within the package. Could anyone clarify if what I’m observing is the expected behaviour, i.e the new build system does not apply to modules in an SPM package? Otherwise, are there any steps I can take to get the new build system to take effect? Thank you!
0
0
55
1d
Xcode 15.4 - SwiftUI Publishing changes warning is not coming as a purple warning in the file
As I trying to check "Publishing changes from within view updates is not allowed, this will cause undefined behavior." within the app in Xcode 15.4 , but unable to see that in the specific file but is getting logged in the Xcode , even I tried adding debugger for "All runtime issues" , its not working. Console like Opposed to this I am expecting this to be visible in the file as Anyone can pls help me in there!! Thanks!!
1
0
88
1d
Scheme Setting Not Persisting For Associated Target
I have an Xcode 15.4 project with 4 targets (i.e. 2 UI and 2 CLI). Next, I'm looking to set a unique scheme for each target but it keeps changing to one of the previously set schemes. For example, I have the following four targets and I would like to have the associated: Target 1 - > Scheme 1 Target 2 -> Scheme 2 Target 3 -> Scheme 3 Target 4 -> Scheme 4 When the target is selected, shouldn't the corresponding scheme be updated in the Xcode toolbar? Or is there a setting that I'm missing to enable/disable within Xcode that would resolve this issue? Finally, I'm seeing similar behavior in Xcode 16 beta 1.
1
0
67
2d
IDE generated *varname problem
When Xcode IDE inserts IBOutlet or autocompletes method signatures, it places the * char next to the var name: @property (weak) IBOutlet NSButton *aButton; - (NSString *)someMethod:(NSString *)param1 { } But my convention is put the * char right after the type name: @property (weak) IBOutlet NSButton* aButton; - (NSString*)someMethod:(NSString*)param1 { } Is there anyway to tell Xcode to follow my convention?
0
0
65
2d
Mac UI Tests Failing to Detect Out-of-Hierarchy Elements
Overview macOS test application is unable to detect elements beyond a certain length during UI testing after an Xcode(14/15) update. Issue Description We have a test app for both iOS and macOS, sharing the same code except for different UI implementations. During UI tests, the app opens a webpage in WKWebView. This is a long webpage with multiple sections, approximately 200 for the sake of clarity. The app screen can show 4 elements at a time. Our UI tests navigate to each section and perform various tasks. Since upgrading from Xcode 13 to 15, we've encountered an issue specifically on macOS (unsure if it's related to Swift or Xcode). Our Mac UI test i.e. XCUIApplication() is unable to find elements beyond a certain length, which appear to be out of the view hierarchy. When we use app.debugDescription, it only returns 180 sections, missing the last 20. The HTML code of the webpage is consistent, with all sections structured similarly. Troubleshooting Steps Accessibility Inspector: Using Xcode’s Accessibility Inspector yields the same result, detecting only 180 sections. Manual Scrolling: We tried manually scrolling to the missing sections. Although we can see these sections on the screen, app.debugDescription still only reports 180 sections, causing the UI test to fail in recognizing the last 20 sections. Deleting Sections: If we delete the top 20 sections of the webpage, it can then find the 200th element. This suggests we might be hitting some limit or restriction we are not aware of. However, on iOS, the same webpage returns all 200 sections without issue. Additional Information This issue is causing a problem only on the Mac app. In our Cocoa Mac application, we are using NSTabView, if that information helps with the investigation. We are wondering if there are any settings or flags we might have missed? Request for Assistance Any help would be greatly appreciated, as this issue is currently blocking us and it was working fine in the previous version. Question Is there any way we can bring those 20 elements into the hierarchy?
1
0
72
2d
command line tools for Monterey 12.7.5
I am working on a MacBook Pro running Monterey 12.7.5 in the past I installed command line tools and developed fine. since then I had a problem with the MacBook re installed the whole OS and basically I want to start developing again. I am trying to instal command line tools without installing all of Xcode. but when I downloaded some version of it, it said my OS was too old. then I tried all of the versions that start with "12" and it wouldn't install because it said my OS was to new. what should I do? thanks yoav
1
1
59
2d
dyld: Symbol not found: ScrollView scrollDisabled
With 16.0b1, I am seeing a runtime error of: Symbol not found: _$s7SwiftUI10ScrollViewV14scrollDisabledyACyxGSbF This happens in both our app and test host apps. We are using Simulator 17.0.1. Has anyone else seen this issue? I'm still looking for anything that might be amiss, but it looks fine and runs on 15.4 fine. Edit: I have confirmed that this only happens when running 17.x simulators.
3
2
83
3d