Announcement: Join the Conversation
Find discussions by searching for keywords or tags.

View all tags >
Learn more about the forums >

Xcode

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

Xcode Documentation

Posts under Xcode tag

1,433 results found
Post marked as solved
25 Views

SwiftUI Preview "Timed out waiting for a thunk to build"

I absolutely cannot get my project to generate a SwiftUI preview, even for the simple "hello world" default. It builds successfully, spins for thirty seconds, then throws an error: TimeoutError: Timed out waiting for a thunk to build after 30.0 seconds. I've tried the usual stuff: Cleaning the build folder, erasing the derived data folder, rebooting, only running Xcode (in case it's a memory issue). No change. I don't see anything obvious in the diagnostic, but happy to post if someone wants to see it. It only seems to happen with this project. A different one (a SwiftUI app I wrote months ago) continues to work fine. This project is older, however, and has no existing SwiftUI code. It happens in both Xcode 11.5 and 12.0b2. My machine is a 2016 13" MacBook Pro (four-port Touch Bar) with 16GB RAM and a dual-core i5. Any ideas on what else to try? This a major impedance for my iOS 14 updates...
Asked
by kona404.
Last updated .
Post marked as unsolved
9 Views

For iOS13, when you try to launch the camera from the app, it crashes

On iOS13, a crash occurred when launching the camera and camera roll. Regarding the camera roll, it was solved by the correspondence described in [Camera Roll], but regarding the camera, it corresponded like [Camera] but it did not move. Please tell me the measures? (Sorry for my poor English.)
Asked
by ytk.
Last updated .
Post marked as unsolved
114 Views

Xcode 12 Beta "Cannot preview in this file"

Hi there! I've been messing around in Xcode 12 Beta with SwiftUI and a Core Data Model, and for some reason my ContentView preview in Xcode is failing to load. Here's the error: "Cannot preview in this file — Connection interrupted: send message to agent" I've made sure all my target memberships are synchronized, given Xcode 12 Command Line Tools in Preferences>Locations, and tried every other solution I can find out there. Any ideas?
Asked
by nlweeks.
Last updated .
Post marked as unsolved
4 Views

Build a command line app with ArgumentParser from existing xcode project

I have a command line app written in Swift. It does not use the Swift package manager, and instead has a rather complex xcode project. I want to use ArgumentParser. The documented way to do this is to import the Swift package, which Xcode 11 can do in the GUI. The problem is that the built executable depends on the ArgumentParser framework's dylib. I need a standalone executable that doesn't depend on dynamic libraries besides those that come with Catalina. When I use the Swift package manager to build a project that depends on ArgumentParser, it is able to do so without a dynamic library dependency. It seems to link in the swiftmodule file. I can't find a way to persuade Xcode to build one of those. Is it possible to build a command line app using Xcode that uses ArgumentParser without requiring me to distribute the ArgumentParser dylib along with my main app binary? My ideal solution would be to add the github ArgumentParser repo as a submodule, add its xcode project to my workspace, and depend on one of the build targets. But I'm open to other approaches.
Asked
by gln.
Last updated .
Post marked as unsolved
31 Views

Can an Objective-C implementation be defined in a header file and also be imported by multiple source files?

I have a header file that defines the interface and implementation of an Objective-C class. Person.h #ifndef Person_h #define Person_h @interface Person : NSObject(void)speak; @end @implementation Person(void)speak { 		// Say something } @end #endif /* Person_h */ I also have two source files that both include the header file. Main.mm @import Foundation; #import "Person.h" int main(int argc, const char * argv[]) { 		// Do nothing } Test.mm @import Foundation; #import "Person.h" When the project is built, I get duplicate symbol errors. duplicate symbol '_OBJC_CLASS_$_Person' in: 		/Debug/TestBox.build/Objects-normal/x86_64/main.o 		/Debug/TestBox.build/Objects-normal/x86_64/test.o duplicate symbol '_OBJC_METACLASS_$_Person' in: 		/Debug/TestBox.build/Objects-normal/x86_64/main.o 		/Debug/TestBox.build/Objects-normal/x86_64/test.o ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) I want to be able to include the same header file in multiple source files. In C++, I can inline the implementation into the header file like this: #ifndef Person_h #define Person_h class Person { public: 		void speak() { // Say something } }; #endif /* Person_h */ However, I haven't been able to find a way to do that with Objective-C. I'm using Objective-C so I can subclass events from NSWindowDelegate and NSResponder. I tried searching for solutions. Most of them said to separate the implementation into a source file, but that would break the single-header architecture. One suggestion is to use the Objective-C runtime library - https://developer.apple.com/documentation/objectivec/objective-c_runtime and create my classes at runtime. This appears to give me the results I'm looking for, but I'm wondering if there is a simpler way. Is there some way to implement an Objective-C class in a header file so that can be included by multiple source files? Or is dynamically creating the classes at runtime my best option?
Asked
by ahzeee.
Last updated .
Post marked as unsolved
3 Views

Unable to receive output/logging while debugging watchOS 7 app

Hello! I am attempting to run & debug a watchOS app on a device running watchOS 7b2 with Xcode 12b2 on macOS 10.15.5. Running the app (usually) works fine — I'm getting live CPU/Mem/etc. stats, breakpoints work, I can set environment overrides from the debug toolbar and they are reflected in the app, but I simply never get any output in the box on the right. "All Output" is selected, there is no filtering active. This has persisted across multiple restarts of all involved devices. I've even ensured that the watchOS debug logging profile is installed (though that was just a Hail Mary since it has never been required for this before). This exact same app produced logging output just fine in Xcode 11/watchOS 6. Does anyone have any other ideas or things I can try? It's making it very tough to debug things. Thanks!
Asked
by bbatsell.
Last updated .
Post marked as unsolved
4 Views

Unit tests don't run

I updated to Xcode 11.5 from Xcode 11.3.1 and the unit tests for my project will not run anymore. However, I can run the app just fine on the simulator. I get the following error when trying to run the tests: <MyApp>.app (<app number>) encountered an error (Canceling tests due to timeout in Waiting for test process to check in...) Since then I've tried everything I can think of: Uninstalled and reinstalled 11.3.1, 11.4.1, and 11.5 Reseting the simulators using "fastlane snapshot reset_simulators". Restart computer, restart Xcode, clear derived data folder, clean project - all the usual stuff with Xcode but no luck The part that really stumps me is that I uninstalled and returned to 11.3.1 and I'm still seeing issues. Any ideas what could cause the error that I'm seeing?
Asked
Last updated .
Post marked as unsolved
9 Views

Homekit API is reachable always returns true

I have a number of devices being read in through an app I am developing. I would like to display the number of devices that are not responding or return isreachable = false. However, all devices including devices that I know for certain cannot be reachable are returning true. Is there a solution for this issue?
Asked
Last updated .
Post marked as unsolved
34 Views

iOS 14 SDK Changes

I cannot find a document that describes all of the iOS 14 SDK changes like deprecated and new methods or behavior changes. For example, the Android 11 preview page (developer.android.com/preview/features) has some code samples in it to show how to use those new features. Also, I can easily navigate between documents to see other Android 11 changes. I just wonder if there is any document like this for iOS 14 or not? If yes, how can I see it?
Asked
by rkotan.
Last updated .
Post marked as unsolved
6 Views

How a path bar like Xcode implemented?

I'm trying to add a path bar in my Cocoa desktop app. so How a path bar like Xcode implemented? !ScreenShot on Github - https://github.com/joelcho/www/blob/master/2020-07-14/a.png?raw=true I found the related: NSPathControl - https://developer.apple.com/documentation/appkit/nspathcontrol DMPathBar - https://github.com/malcommac/DMPathBar Is there have a system view(control) that can implement this?
Asked
by Joelina.
Last updated .
Post marked as unsolved
7 Views

"Jump to Definition" not working consistently with target/action pattern

I've inherited a large project. Digging around the codebase has been tough because "Jump To Definition" isn't working consistently. The codebase is almost entirely in Objective-C, and I'm seeing usage of the target-action pattern like: // ViewController1.m (void)viewDidLoad { 	[super viewDidLoad]; 	UIButton *button = [UIButton new]; 	[button addTarget: self action:@selector(selected) forControlEvents: UIControlEventTouchUpInside]; } (void)selected { 		NSLog(@"selected in View Controller 1"); } When I command + control + click on the "selected" method name inside of the @selector attribute, it will jump to the definition of the wrong method. The incorrect method has the same signature: it is named "selected" and takes no arguments. But that implementation is in an unrelated class in a different source file. My first instinct was that this is a bug when using @selector, but I was not able to duplicate in a simple sample project - two source files that have a selector with the same name will behave as expected when trying to Jump to Definition. I thus believe this to be an issue due to the nature of the inherited project - it's very large, and there are over 200 existing warnings. It takes a very long time to index. I wonder if that has anything to do with it? Are there any tips for dealing with "Jump to Definition" not working in a legacy project? I plan on fixing the warnings at some point, but if there's another thing I can do in the meantime it would be helpful as I familiarize myself with the code.
Asked
by bpapa.
Last updated .