swift | The Swift Programming Language | iOS library
kandi X-RAY | swift Summary
kandi X-RAY | swift Summary
The Swift Programming Language
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of swift
swift Key Features
swift Examples and Code Snippets
Community Discussions
Trending Discussions on swift
QUESTION
I'm pretty new to Swift, currently writing an AR game. Seems like my issue is very basic, but I can't figure it out.
I added a button to an AR Scene through the storyboard and linked it to an IBAction function (which works correctly when the button is clicked). I gave the button an image and deleted the Title. See how the button shows up in the storyboard: button in Xcode storyboard without Title
But when I run the app, the button image shows up with a default label (saying "Button") as shown in this image: button in iPhone screenshot WITH label next to the button image
I can't figure out why this label is there and how to remove it. Should I add the button programmatically instead of adding it through the storyboard? Should the button be treated differently because it's an AR app?
I was able to remove the label by adding the same UIButton as an IBOutlet and adding the following line in viewWillAppear:
...ANSWER
Answered 2021-Nov-23 at 21:07When Interface Builder isn't playing nice, I often open the Storyboard file in a text editor (I use Sublime Text) and edit it manually.
I had a similar issue - I had a button with an image, I had deleted the default "Button" title text in IB, which looked fine in Xcode, but when I ran it, the word "Button" was still there. So I found this line using Sublime Text and deleted it there:
QUESTION
Xcode 13.2 Beta release notes features a promise for Swift Concurrency support for iOS 13.
You can now use Swift Concurrency in applications that deploy to macOS 10.15, iOS 13, tvOS 13, and watchOS 6 or newer. This support includes async/await, actors, global actors, structured concurrency, and the task APIs. (70738378)
However, back in Summer 2021 when it first appeared at WWDC it was hard constrained to be run on iOS 15+ only.
My question is: what changed? How did they achieve backwards compatibility? Does it run in any way that is drastically different from the way it would run in iOS 15?
...ANSWER
Answered 2021-Oct-28 at 14:06Back-deploying concurrency to older OS versions bundles a concurrency runtime library along with your app with the support required for this feature, much like Swift used to do with the standard library prior to ABI stability in Swift 5, when Swift could be shipped with the OS.
This bundles parts of the Concurrency portions of the standard library (stable link) along with some additional support and stubs for functionality (stable link).
This bundling isn't necessary when deploying to OS versions new enough to contain these runtime features as part of the OS.
Since the feature on iOS 15+ (and associated OS releases) was stated to require kernel changes (for the new cooperative threading model) which themselves cannot be backported, the implementation of certain features includes shims based on existing functionality which does exist on those OSes, but which might perform a little bit differently, or less efficiently.
You can see this in a few places in Doug Gregor's PR for backporting concurrency — in a few places, checks for SWIFT_CONCURRENCY_BACK_DEPLOYMENT
change the implementation where some assumptions no longer hold, or functionality isn't present. For example, the GlobalExecutor
can't make assumptions about dispatch_get_global_queue
being cooperative (because that threading model doesn't exist on older OSes), so when backporting, it has to create its own queue for use as the global cooperative queue. @objc
-based actors also need to have their superclass swizzled, which doesn't need to happen on non-backdeployed runtimes. (Symbols also have to be injected in some places into the backdeploy libs, and certain behaviors have to be stubbed out, but that's a bit less interesting.)
Overall, there isn't comprehensive documentation on the exact differences between backdeploying and not (short of reading all of the code), but it should be safe to assume that the effective behavior of the backdeployed lib will be the same, though potentially at the cost of performance.
QUESTION
I can't run any Xcode Swift Playground project without getting the error:
Failed to launch process. Failed to attach to stub for playground execution: error: attach failed ((os/kern) invalid argument)
Does anyone know how to solve this?
...ANSWER
Answered 2021-Nov-11 at 09:56I've the same issue. If I launch Xcode using rosetta, it doesn't show anything. You must switch off rosetta and it works perfect.
QUESTION
Before iOS 15, I used UIImagePickerController to capture images and video, and I got mediaType from [UIImagePickerController.InfoKey : Any]
, then I used kUTTypeImage
(in the MobileCoreServices
library) to identify the mediaType.
However, When it comes to iOS 15, Xcode complains that kUTTypeImage was deprecated in iOS 15.0. Use UTTypeImage instead.
So, I replaced kUTTypeImage
with UTTypeImage
, but Xcode didn't know it.
Tried searching for some information, but didn't get any clue. I guess I should import the right library, but what is it?
Here is part of the code:
...ANSWER
Answered 2021-Sep-26 at 06:40It's a bit confusing. First, you'll need to import UniformTypeIdentifiers
. Then, replace kUTTypeImage
with UTType.image
(the Swift version of UTTypeImage
).
QUESTION
I recently upgraded to xcode13, before which react native app was working fine for long time. However, after switching when I run in iOS, I am getting error "instruments is not a developer tool or in PATH" on command "xcrun instruments". I tried following commands (all with Xcode in quit status)
...ANSWER
Answered 2021-Sep-29 at 15:24I've been getting the same error no matter what I've tried. I think there might be an error on setting the command line tools path with the Xcode version 13. So deleting XCode 13 (How to uninstall XCode) and reinstalling 12.5.1.(XCode12.5.1) solved the problem for me temporarily.
QUESTION
In WWDC 2021 video, Protect mutable state with Swift actors, they provide the following code snippet:
...ANSWER
Answered 2022-Jan-05 at 00:30The key is to keep a reference to the Task
, and if found, await
its value
.
Perhaps:
QUESTION
I have a networking layer that currently uses completion handlers to deliver a result on the operation is complete.
As I support a number of iOS versions, I instead extend the network layer within the app to provide support for Combine. I'd like to extend this to now also a support Async/Await but I am struggling to understand how I can achieve this in a way that allows me to cancel requests.
The basic implementation looks like;
...ANSWER
Answered 2021-Oct-10 at 13:42async/await might not be the proper paradigm if you want cancellation. The reason is that the new structured concurrency support in Swift allows you to write code that looks single-threaded/synchronous, but it fact it's multi-threaded.
Take for example a naive synchronous code:
QUESTION
We can build and run Swift code/projects from the command line via multiple commands without using Xcode. I have heard of xcodebuild
, xcrun
and swift
used for Xcode development. I do use fastlane
but I don't really understand the tools powering it under the hood.
I am an iOS developer who uses a Mac. I develop using Xcode so I haven't used these command-line tools before.
What are the differences between each command? Are there any cases where I'd be better off using one over the other?
...ANSWER
Answered 2021-Sep-13 at 17:36xcodebuild
and xcrun
help build Xcode projects in a headless context, for example in CI setups. swift
is the Swift REPL and is largely used for Swift on Server apps. As such, we can build apps without knowing about or using the tools regularly in mobile app development. We use xcodebuild
and xcrun
under the hood interacting with Xcode even though we don't realise it because they're bundled in Xcode's Command Line tools (documentation archive, but still relevant).
fastlane
is an example CI tool that automates the build process, certificate signing, and interfacing with App Store Connect, using these tools.
xcodebuild
is part of Xcode's bundled command-line tools package. From the manpages:
build Xcode projects and workspaces
xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode project.
xcodebuild
has lots of options and use cases. The options are equivalent to certain user actions within the Xcode IDE. Example usage:
QUESTION
I have recently updated to Xcode 13.2 from the Mac App Store. While trying to fix an issue with a Swift package, I uninstalled it and now I cannot reinstall the package.
When I try to add a package from GitHub the process hangs immediately on "Preparing to validate".
I already attempted to restart Xcode, restart my mac, clean derived data, reset Swift package caches and update package versions to no avail.
...ANSWER
Answered 2021-Dec-14 at 04:14Check https://developer.apple.com/forums/thread/696504 and re-download Xcode 13.2 directly from the releases section of the Apple Developer website: https://developer.apple.com/download/release/
QUESTION
Just updated Xcode to 13.2 via Mac App Store.
I installed the additional components, and my project won't compile anymore : Xcode just tells me Internal error: missingPackageDescriptionModule - Resolving Package Graph Failed
when attempting to build. None of the Swift packages used within my app seems to build, because "Package resolution errors must be fixed before building".
Already attempted to restart Xcode, update macOS, clean derived data, reset Swift package caches and update package versions to no avail.
Guess I'll try re-installing Xcode but... does anyone else have the same issue?
...ANSWER
Answered 2021-Dec-20 at 03:33EDIT: Xcode 13.2.1 version fixes this issue and can be downloaded from the Mac App Store.
Old Answer:
Apple has responded:
We're currently investigating this issue — thank you to those who have filed bug reports so far. To workaround this issue, please re-download Xcode 13.2 RC directly from the More Downloads page.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install swift
Contributing fixes and features to the compiler: See our How to Submit Your First Pull Request guide.
Building the compiler as a one-off: See our Getting Started guide.
Building a toolchain as a one-off: Follow the Getting Started guide up until the "Building the project" section. After that, follow the instructions in the Swift Toolchains section below.
Try the suggestions in Troubleshooting build issues. Make sure you are using the correct release of Xcode. If you have changed Xcode versions but still encounter errors that appear to be related to the Xcode version, try passing --clean to build-script. When a new version of Xcode is released, you can update your build without recompiling the entire project by passing --reconfigure to build-script.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page