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

Xcode Documentation

Posts under Xcode subtopic

Post

Replies

Boosts

Views

Activity

Checking for NIL
I have a program where the user enters 2 fields with numerics. If they accidently enter a letter the program crashes. How can I check for NIL without making the variable optional. If I make it optional I get an error in the Textfield. How can I test a Textfield for NIL? Please help.
4
0
363
Dec ’24
Xcode 16 destroys Objective-C Developer Documentation
In Xcode 16, even if Objective-C is selected, the Navigator in the documentation viewer displays Swift information. I don't know when this bug was introduced, but it's there in the last Xcode 16 betas at least. I hope as many developers as possible submit this bug to Apple to get their attention. P.S. Yes, I know there's Dash. For many years, Dash was a much better option than Xcode's built-in viewer. However, in version 5, the Dash developer introduced some unfortunate UI changes that made Xcode a better option to view the documentation in certain cases. Unfortunately, the Dash developer doesn't seem to be interested in user feedback anymore. He's been ignoring suggestions and user requests for years by now.
5
0
716
Dec ’24
XCTestPlan configuration environment variables not passed in to XCUIApplication
I have an XCTestPlan with configurations for each country I support on the App Store, so I can generate screenshots without a crazy amount of work. Until Xcode 15, this worked fine. Now, it appears that while environment variables associated with the XCTestPlan itself are passed in to Xcode, those associated with each configuration are not. I did prefix the environment variables with "TEST_RUNNER_" as recommended elsewhere with no luck. Any suggestions?
1
0
285
Dec ’24
Collecting effective permissions for ScreenCaptureKit in xCode
I am a complete newbie when it comes to Swift and MacOS development. So apologies, I don't even know what is the right thing to search for. I have an app which uses ScreenCaptureKit. I had a preview working which showed the different windows available, it initially required me to give my app permissions for screen and system audio recording which I did. However now whenever I rebuild the app it asks for permission again and fails - despite the permission already being given.
2
0
562
Dec ’24
Screen Time API
Hi everyone, I've been going through the forums and documentation, but I'm still unsure about how the Screen Time API works or whether it can achieve what I have in mind. Specifically, I want to display the current screen time value on a widget. Additionally, I’d like to use that screen time value for some calculations and represent the results in a different way within the widget. I’d really appreciate any guidance or insights. Thanks in advance! 😊
1
0
638
Dec ’24
Issues with iOS Simulators and Debugging after Xcode 16 Upgrade
Hi everyone, I recently upgraded my Xcode to version 16, and since then, I’ve encountered some issues with Visual Studio 2022 for Mac. The iOS simulators have disappeared, except for the generic simulator. When I connect my iPhone via USB, Visual Studio recognizes it, but when I attempt to run my project in debug mode, I receive a status message saying "waiting for debugger to connect to iPhone on port 10000 via USB." After a few minutes, this process fails. Additionally, when I try to run the project in release mode, I encounter the following error: dlopen(/Applications/Xcode.app/Contents/SharedFrameworks/IDEDistribution.framework/Versions/A/IDEDistribution, 0x0001): Library not loaded: @rpath/AppThinning.framework/Versions/A/AppThinning Referenced from: <33FF2F3B-A96F-37B4-BA4E-887BD882BF9D> /Applications/Xcode.app/Contents/SharedFrameworks/IDEDistribution.framework/Versions/A/IDEDistribution Reason: tried: '/Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.23/lib/mlaunch/mlaunch.app/Contents/Frameworks/AppThinning.framework/Versions/A/AppThinning' (no such file), '/Applications/Xcode.app/Contents/SharedFrameworks/IDEDistribution.framework/Versions/A/Frameworks/AppThinning.framework/Versions/A/AppThinning' (no such file), '/Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.23/lib/mlaunch/mlaunch.app/Contents/Frameworks/AppThinning.framework/Versions/A/AppThinning' (no such file), '/Applications/Xcode.app/Contents/SharedFrameworks/IDEDistribution.framework/Versions/A/Frameworks/AppThinning.framework/Versions/A/AppThinning' (no such file), '/Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.23/lib/mlaunch/mlaunch.app/Contents/MonoBundle/AppThinning.framework/Versions/A/AppThinning' (no such file) I suspect that the new version of Xcode may not be fully compatible with Visual Studio 2022. Unfortunately, I cannot roll back to an older version of Xcode because I have updated my macOS to Sequoia (15.0.1), which appears to be incompatible with previous Xcode versions. It is quite frustrating as I can't debug my projects and my works are stalled. Does anyone have any suggestions or solutions to this problem? Thank you in advance for your assistance!
2
2
1.4k
Dec ’24
Is is possible to have environment variables in iOS, watchOS and tvOS? How does it work?
Hi, so a little context, by environment variables I mean like $HOME in linux. I know that there are some standard and some app specific environment variables in the above mentioned platforms. Is is possible for the user to set environment variables? If so, what are the ways in which users can set environment variables in the platforms mentioned across the system or for the app as they would in macOS/linux/windows? And is it possible for developers of the app do the same? If so how? What I have found so far is that it cannot be done by users, and there is one place in xcode where I, as a developer can set environment variables for my app from the scheme. This isn't available when I ship just the installation binary to the end user, but rather is available only when the app is run using xcode. I just need validation that what I understand is correct and that there aren't other ways to do this by the user/developer without jailbreaking.
1
0
453
Dec ’24
Mergeable Library in XCTest with iOS on Mac Target: 3588 Error
I have an XCTest unit test that's running in an iOS host but with the My Mac (Designed For iPad) Target. Enabling mergeable libraries causes two errors: Symbol not found: _$s10Foundation3URLV9RVAPIPackE8isGCSURLSbvg And "loading failed because of an error Error Domain=NSCocoaErrorDomain Code=3588" for the Test bundle because one of the frameworks that's supposed to be merged couldn't be loaded. Disabling mergeable libraries fixes it. It also works with mergeable libraries enabled but with a regular simulator target. So not sure if I'm missing something or if I need to disable mergeable libraries now:/
2
0
337
Dec ’24
TipKit #Rule donation work unexpectedly
My feature has rule: var rules: [Rule] { #Rule(Self.didOpenProductDetails) { event in event.donations.count == 0 } } Actual: After first donation is done it suppose to be performed - but after I back to screen the Tip is showing again. Only after second donation the Tip dismisses. Expected: After first donation, even donations count == 1 and Tip won't be presented again. Tested on iOS 18.1
1
0
400
Dec ’24
Download Old version of Xcode
How can I save an Xcode project in Sequoia writen in Xcode Sequoia - Version 15.1 so that it can be opened in Ventura - Version 14.3.1 (14E300c) or in Big Sur Version 13.1 The error I get says Project.xcodeproj cannot be opened because it is in a future Xcode project file format. Adjust the project format using a compatible version of Xcode to allow it to be opened by this version of Xcode
1
0
555
Dec ’24
Crash report from user unexpectedly looks like beta app
According to this page: https://developer.apple.com/documentation/xcode/interpreting-the-json-format-of-a-crash-report the storeInfo element of a JSON crash log may contain a deviceIdentifierForVendor element, but quote "This field is only present for TestFlight builds of an app". A user has just sent me a crash report which contains this key, but this isn't a testflight build. The suspicion is of course that the app is "cracked" in some way, but having interacted with the user for some time I think this is unlikely. He has had various issues with the app, affecting multiple devices; I have been wondering if there is something wrong with his Apple account. The docs also say that this "replaces the CrashReporter Key field", yet this crash report contains both. So my question for other developers: if you have any .ips crash logs, obtained from non-testflight users of your apps, please could you grep them for deviceIdentifierForVendor and let me know what you find. If any Apple people have any clues about how this could innocently end up in a crash report, please let me know. Maybe it's a documentation bug?
0
0
389
Dec ’24
I would like to know how to switch the code view between Release and Debug modes.
You can see: in the first image, the default project have DEBUG macro. So in perview, release code segment is grey. But!!! In edit scheme, I change all of item to release mode! (See second image) At this point, the DEBUG code block is still highlighted. If I compile and run it, the output is actually from the Release code block. In other words, I have changed all the modes in the scheme, but the preview mode is still in DEBUG.
0
0
234
Dec ’24
format percentages
I'm using XCODE with Swiftui. I want to know how I can format percentages in the program to whole numbers with a % sign without any decimal places to the screen. For instance if the program figures 33.3333 I want to print 33% to the screen. If I have 67.85762 in the program I want to print 67% (or 68% if it can be rounded) to the screen. Please help. Thanks
3
0
280
Dec ’24
XCode 16 clang++ compiler generates unexpected results for conditional checks at -O2 and -O3 optimization levels
Around a month back, developers of the OpenJDK project, when using XCode 16 to build the JDK started noticing odd failures when executing code which was compiled using the clang++ compiler shipped in that XCode 16 release (details in https://bugs.openjdk.org/browse/JDK-8340341). Specifically, a trivial for loop in a c++ code of the form: int limit = ... // method local variable for (i=0; i<limit; i++) { ... } ends up iterating more times than the specified limit. The "i<limit" returns true even when it should have returned false. In fact, debug log messages within the for loop of the form: fprintf(stderr, "parsing %d of %d, %d < % d == %s", i, limit, i, limit, (i<limit) ? "true" : "false"); would show output of the form: parsing 0 of 2, 0 < 2 == true parsing 1 of 2, 1 < 2 == true parsing 2 of 2, 2 < 2 == true Notice, how it entered the for loop even when 2 < 2 should have prevented it from entering it. Furthermore, notice the message says 2 < 2 == true (which clearly isn't right). This happens when that code is compiled with optimization level -O2 or -O3. The issue doesn't happen with -O1. I had reported this as an issue to Apple through feedback assistance, more than a month back. The feedback id is FB15162411. There hasn't been any response to it nor any indication that the issue has been noticed and can be reproduced (the steps to reproduce have been provided in that issue). In the meantime, more and more users are now running into this failure in JDK when using XCode 16. We haven't put any workaround in place (the only workaround we know of is using -O1 for the compilation of this file) because it isn't clear what exactly is causing this issue (other than the fact that it shows up with specific optimization levels). It's also unknown if this bug has wider impact. Would it be possible to check if FB15162411 is being looked into and any technical details on what's causing this? That would help us decide if it's OK to put in place a temporary workaround in the OpenJDK build and how long to maintain that workaround. For reference, this was reproduced on: clang++ --version Apple clang version 16.0.0 (clang-1600.0.26.3) Target: arm64-apple-darwin23.6.0 Thread model: posix InstalledDir: /xcode-16/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
13
1
2k
Dec ’24
Xcode 16's clang generates incorrect inlined optimized code
I'm encountering a bug with Xcode 16's clang's code generation. It seems to be generating incorrect optimized code (-O2 setting) when functions are inlined and then optimized. This is a behavior that didn't exist in Xcode 15, and also doesn't happen in open source clang (I tested open source clang 17/18/19 on my M1 Max MacBook Pro). The entire code snippet is slightly too long to post here so I'm including a link to the godbolt compiler explorer instead: https://godbolt.org/z/KhG3x7E1d . This piece of code attempts to find a sequence of illegal UTF-8 characters and report the index of the character in a string. Not that in godbolt, the program works fine and finishes correctly. When I test it in Xcode 16 though (with -O2), it doesn't, and utf_find_illegal returns 4 instead of 3, which is incorrect. Digging through the disassembly it seems to be doing some complicated optimizations by inlining both utf_ptr2len and utf_ptr2char together but it doesn't perform correctly and jumped to the wrong place when the illegal character was found. I did try to see if there are some undefined behaviors or something which caused the optimizer to go to town with the code. Funnily when I use UBSAN (by compiling the code with -O2 -fsanitize=undefined) the code works just fine and the bug doesn't happen. Wonder if other people have seen similar issues? Code generation bugs seem really dangerous considering that people rely on the compiler to… work. I tried to scrub the code to see if there are anything that could suggest the compiler to behave incorrectly but not having any luck as well. I have also tested Xcode 16.1 beta and it doesn't seem to help. Note: Yes, I know I'm supposed to use the Feedback Assistant but I have never received any responses on it even when filing legit bugs and their statuses are still open, with their bugs unfixed. Pardon me for not trusting it too much.
3
1
1k
Dec ’24
Xcode 16 Minimum Deployments value Not Saving
Dear Apple Developer Support, I’m reporting an issue in Xcode 16 where the iOS minimum Deployments value in the Targets General tab resets to blank when set below iOS 15.6. This issue does not occur when setting the target through Build Settings, where it’s retained correctly. Steps to Reproduce: Set the minimum Deployments value to below 15.6 in General > minimum Deployments. Save and close the project. Reopen the project and check the target in General — it’s blank. Workarounds Tried: Tested on Xcode 16, 16.1, and 16.2. Manually set the target every time. Set the target via Build Settings (works but is inconvenient). System Info: Xcode: 16.2 macOS: 14.5 This impacts my workflow as my project targets iOS 13. Please investigate and advise. Please check the attached screenshots Thanks and Regards, Pavan
2
2
1k
Dec ’24
iOS App crash on launch built with Xcode 16.2
iOS 13.6 App built with Xcode 16.2 on macOS 15.1.1 Thread 1 Queue : com.apple.main-thread (serial) #0 0x0000000183a90b9c in _platform_strcmp () #1 0x0000000183b8db48 in objc_opt::objc_stringhash_t::getIndex () #2 0x0000000183b8d8a8 in _dyld_get_objc_selector () #3 0x0000000183abf618 in __sel_registerName () #4 0x0000000183ac1bd8 in map_images_nolock () #5 0x0000000183ab2f04 in map_images () #6 0x0000000104f9d19c in dyld::notifyBatchPartial () #7 0x0000000104f9d384 in dyld::registerObjCNotifiers () #8 0x0000000183b8d84c in _dyld_objc_notify_register () #9 0x0000000183ac3418 in _objc_init () #10 0x000000010a746f20 in _os_object_init () #11 0x000000010a755c48 in libdispatch_init () #12 0x00000001b903a880 in libSystem_initializer () #13 0x0000000104faf2c4 in ImageLoaderMachO::doModInitFunctions () #14 0x0000000104faf6b0 in ImageLoaderMachO::doInitialization () #15 0x0000000104faa0f0 in ImageLoader::recursiveInitialization () #16 0x0000000104faa05c in ImageLoader::recursiveInitialization () #17 0x0000000104fa8520 in ImageLoader::processInitializers () #18 0x0000000104fa85e8 in ImageLoader::runInitializers () #19 0x0000000104f9a608 in dyld::initializeMainExecutable () #20 0x0000000104f9eeb0 in dyld::_main () #21 0x0000000104f99208 in dyldbootstrap::start () #22 0x0000000104f99038 in _dyld_start ()
1
0
302
Dec ’24
xcode crash when launch
Xcode crashes over and over again, and I can't use it anymore. I tried uninstall and re-install xcode from the app store, and upgrade macOS to the newest version, but still not working, please help me to fix it. Reproduce Steps: Launch Xcode from the Launchpad or Dock Wait a few seconds(within 10 seconds), Xcode crash <- Issue And here is the crash report: xcode_crash_report.log I also summited a feedback, and here is the feedback id: 16047663
3
1
632
Dec ’24