just curious about it
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I tried to implement ExpressibleByIntegerLiteral to my code and it has been terrible.
At last, it asked me to implement this init
// Cannot find type 'Builtin' in scope
init(_builtinIntegerLiteral value: Builtin.IntLiteral) {
}
I have a M2, 13" MacBook Pro
import Cocoa
import IOKit
import Foundation
var blob = IOPSCopyPowerSourcesInfo() // cannot find 'IOPSCopyPowerSourcesInfo' in scope
SwiftUI's Refreshing mechanism is driving me crazy.
Say that I have this view:
NavigationView {
List($datasource) { $item in
NavigationLink {
SubView(item: $item)
} label: {
Text(item.someAttribute)
}
}
}
SubView:
TextField("Placeholder", text: $item.someAttribute)
And each time I edit the value in the SubView, the SwiftUI's navigation controller retreats the view to the home page(the initial view). Why?
I wrote an app that users can create utilities using terminal commands
I'm experiencing a bug that's driving me crazy:
I have an array of utilities, and by extension, I made Array<Utility> and Utility RawRepresantable:
Part of the declaration for Utility
public init?(rawValue: String) {
guard let data = rawValue.data(using: .utf8),
let result = try? JSONDecoder().decode(Utility.self, from: data)
else { return nil }
self = result
}
public var rawValue: String {
var encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
guard let data = try? encoder.encode(self),
let result = String(data: data, encoding: .utf8)
else {
return ""
}
return result
}
extension for Array<Utility>
extension Array: RawRepresentable where Element: Codable {
public init?(rawValue: String) {
guard let data = rawValue.data(using: .utf8),
let result = try? JSONDecoder().decode([Element].self, from: data)
else { return nil }
self = result
}
public var rawValue: String {
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
guard let data = try? encoder.encode(self),
let result = String(data: data, encoding: .utf8)
else {
return "[]"
}
return result
}
}
And now, because of some strange SwiftUI bug (FB11401294) When I pass a binding down a view hierarchy such as List or ForEach they update weirdly. I implement an "edit" feature for my utilities so I will not directly use binding but to call a function that takes an inout of Array<Utility>, the original item, and the item after being edited:
func replace(_ sequence: inout [Utility], item: Utility, with replace: Utility) {
var raw = sequence.rawValue
print(raw)
let rawReplaced = raw.replacingOccurrences(of: item.rawValue, with: replace.rawValue)
print(item.rawValue, replace.rawValue)
print(rawReplaced)
sequence = [Utility].init(rawValue: sequence.rawValue.replacingOccurrences(of: item.rawValue, with: replace.rawValue))!
print(sequence)
}
And the problem is it works
and after implementing another completely different feature it stopped working
from my debugging, the input of the function is correct and the problem is inside the function. But, as the error seems to be on this line:
sequence = [Utility].init(rawValue: sequence.rawValue.replacingOccurrences(of: item.rawValue, with: replace.rawValue))!
Now i have completely no idea why this works last time and won't now
This line of code works completely well in playgrounds and is now freaking me out
Help anyone?
Without dependencies on other third-party frameworks
Just a function that receives a string, outputs a string and throws
I have a swiftUI app
after I decided to add a document type
After I opened the infos tab I clicked on "documents" and Xcode crashed. I've filed a bug (FB10465644).
Any way so I added the imported & exported document and now its won't work.
I ran the executive in my app and it gave me this:
.....frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug/UtilityScript.app/Contents/MacOS/UtilityScript ; exit;
SwiftUI/AppWindowsController.swift:1103: Fatal error
[1] 30982 illegal hardware instruction
Saving session...completed.
[Process completed]
in Xcode:
SwiftUI/AppWindowsController.swift:1103: Fatal error
2022-06-26 13:26:19.042228+0800 UtilityScript[31108:471855] SwiftUI/AppWindowsController.swift:1103: Fatal error
(lldb)
HELP I'VE NEVER THIS BEFORE I JUST WANT TO KNOW IF It"S MY BUG OR SWIFTUI'S
AND I JUST WANT MY APP DONE🫠
info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>22A5286j</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict/>
</array>
<key>CFBundleExecutable</key>
<string>UtilityScript</string>
<key>CFBundleIdentifier</key>
<string>-----</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>UtilityScript</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>14A5228q</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>13.0</string>
<key>DTSDKBuild</key>
<string>22A5266o</string>
<key>DTSDKName</key>
<string>macosx13.0</string>
<key>DTXcode</key>
<string>1400</string>
<key>DTXcodeBuild</key>
<string>14A5228q</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>NSHumanReadableCopyright</key>
<string>-----</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeIcons</key>
<dict/>
<key>UTTypeIdentifier</key>
<string>-----</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>.utlscript</string>
</array>
</dict>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeIcons</key>
<dict>
<key>UTTypeIconText</key>
<string>utilityscript</string>
</dict>
<key>UTTypeIdentifier</key>
<string>-----</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>.utlscript</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>
I know there should be a easy solution to this mess but I JUST CAN'T FIND IT AHHHHHHHHHH
cd ......
error: Build input file cannot be found: '/Users/xxx/Library/Developer/Xcode/DerivedData/ColorLibrary-hakdntgphjogwuawcvuxomfrjzex/Build/Products/Debug-iphonesimulator/ColorKit iOS.app/ColorKit iOS' (in target 'ColorKit iOS' from project 'ColorLibrary')
2022-06-09 08:51:30.793789+0800 MyAppName[4651:447798] [aqme] MEMixerChannel.cpp:1629 client <AudioQueueObject@0x7fc09a04f400; [0]; play> got error 2003332927 while sending format information
I use .mp3
Can I export a SwiftUI Color / UIKitUIColor / AppKit NSColor to a .clr file? How?
Bonus: Can I transfer them to each other?
I add searchable to my SwiftUI List
But the search TextField isn't showing
Here's my code
NavigationView {
List(searchResults, id: \.self) { item in
NavigationLink {
LegendDetailView(item: item)
} label: {
HStack {
Text(item.name).padding(1)
Spacer()
Image(systemName: "chevron.right").imageScale(.small)
}
}
}
}.searchable(text: $searchText)
My code:
struct PopoverMessage: View {
var body: some View {
VStack(alignment: .leading) {
Text("You need to launch this game at Teminal.")
.font(.title)
.fontWeight(.light)
Divider()
HStack {
Text("Help me generate launch command ")
.fontWeight(.thin)
Image(systemName: "rectangle.portrait.and.arrow.right.fill")
.resizable()
.foregroundColor(.gray)
.frame(width: 10, height: 10)
}.padding(10)
}
}
}
works while
struct PopoverMessage: View {
var body: some View {
VStack(alignment: .leading) {
Text("You need to launch this game at Teminal.")
.font(.title)
.fontWeight(.light)
Divider()
HStack {
Text("Help me generate launch command ")
.fontWeight(.thin)
Image(systemName: "rectangle.portrait.and.arrow.right.fill")
.weigh
.resizable()
.foregroundColor(.gray)
.frame(width: 10, height: 10)
}.padding(10)
}
}
}
don't and displays a error message Trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure
Here's the text in the diagnostics sheet:
trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure
----------------------------------------
CompileDylibError: Failed to build ContentView.swift
Compiling failed: trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure
/Users/wangkeshijian/Documents/.myFolder/.system/TerminalAdventure/TerminalAdventure/ContentView.swift:12:37: error: trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure
VStack(alignment: .leading) {
^
SwiftUI.VStack:4:12: note: 'init(alignment:spacing:)' declared here
public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil)
^
// my comment here: it seems that SwiftUI, under some sort of strange bug, did notrecognize my initializer
==================================
| BuildInvocationError
|
| /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -F /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/SharedFrameworks -enforce-exclusivity=checked -DDEBUG -sdk /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk -target x86_64-apple-macos12.4 -module-cache-path /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -swift-version 5 -enable-bare-slash-regex -I /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug -F /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug -emit-localized-strings -emit-localized-strings-path /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64 -c -j4 -serialize-diagnostics -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-generated-files.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-own-target-headers.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-all-target-headers.hmap -Xcc -iquote -Xcc /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-project-headers.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug/include -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources-normal/x86_64 -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources/x86_64 -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources -Xcc -DDEBUG=1 -working-directory /Users/wangkeshijian/Documents/.myFolder/.system/TerminalAdventure /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64/ContentView.1.preview-thunk.swift -o /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64/ContentView.1.preview-thunk.o -module-name TerminalAdventure_PreviewReplacement_ContentView_1 -Onone -Xfrontend -disable-modules-validate-system-headers -gline-tables-only
For SwiftUI/UIKit