I am developing a macOS non-interactive macOS application which does not show any ui.
i want to block main thread and do all the work on worker thread . Once done with work in worker thread, want to unblock main thread by exiting event loop to terminate application.
Because i dont want to show any UI or use any Foundation/Cocoa functionality, i am thinking of using CFRunLoop to block main thread from exiting until i finish my work in worker thread.
When i tried this in a project, I am able to finish work in worker thread after block main thread using CFRunLoop.
I also want this application to be a bundled application, which can be launched by double clicking on application bundle . But when i tried it in my xcode project by launching it using double clicking on application bundle, application keeps on toggling/bouncing in the dock menu with a status "Not responding". Although i am able to complete my work in worker thread.
import Foundation
let runLoop = CFRunLoopGetCurrent()
func workerTask() {
DispatchQueue.global().async {
print("do its work")
sleep(5) // do some work
print("calling exit event loop")
CFRunLoopStop(runLoop)
print ("unblocking main thread")
}
}
workerTask ()
// blocking main thread
print ("blocked main thread")
CFRunLoopRun()
print ("exit")
Why i am getting this application bouncing in doc menu behavior ? I tried by using NSApplicationMain instead of CFRunLoop in my project, in that case i didnt get this behavior .
Does NSApplicationMain does some extra work before starting NSRunLoop which i am not doing while using CFRunLoop, which is showing this toggling/Bouncing application icon in Dock menu ?
or Is this bouncing app icon issue is related to run loop i am using which is CFRunLoop ?
Note : If i dont use a bundled application and use a commandline application then i am able to do all steps in worker thread and exit main thread as i wanted after finishing my work . But i need to do all this in application which can be launched using double clicking (bundled applcation).
If not by using CFRunLoop, then how can i achive this ? - Create a application which shows no UI and do all work in worker thread while main thread is blocked. Once work is done unblock main thread and exit. And user should be able to launch application using double click the application icon.
Create elegant and intuitive apps that integrate seamlessly with Apple platforms.
Post
Replies
Boosts
Views
Activity
Hi,
I am trying to use a flag image inside a picker like this:
Picker("Title: ", selection: $selection){
ForEach(datas, id: \.self){ data in
HStack{
Text(data.name)
if condition {
Image(systemName: "globe")
}else {
Image(img)
}
}
.tag(data.name)
.padding()
}
}
All images are loading successfully but only system images are resized correctly.
Images loaded from Assets are appearing in their default size.
I have tried to size the images with frames, etc but with no luck.
Any idea, help will be much appreciated.
Thanks in advance!
How to create a beautiful fire animation using Swift?
Which API is better to use?
Hi, Since last week, I’ve been trying to publish the new version of my Voxel game, which aims to fix many bugs and significantly optimize the game. This update is very important for improving the overall quality of the game.
Unfortunately, this version is not being accepted on the App Store due to a Design - Copycats issue related to guideline 4.1. I’ve tried everything to resolve the problem by changing the screenshots, app preview, description, game name, icons, and even all metadata that could cause issues in the build. But nothing seems to work.
I keep receiving the same rejection just a few minutes after submitting my build for review.
Here is the full warning message:
—————— “Guideline 4.1 - Design - Copycats
This app or its metadata appears to be misrepresenting itself as another popular app or game already available on the App Store, from a developer's website or distribution source, or from a third-party platform.
Apps should be unique and should not attempt to deceive users into thinking they are downloading something they are not.”
Next Steps
Learn more about requirements to prevent apps from impersonating other apps or services in guideline 4.1.
Revise the app to comply with these requirements.
Once the app is fully compliant, resubmit the app for review.
——————
Also I've already tried contaction the Apple Developer team but I got no answer. I don't know what to do.
Thanks
I want to add a tool bar (setting search )to my app just like the apple file app using pure swiftUI, is it possible, if not, can i using a UIKit to implement it.
struct MainView: View {
var body: some View {
TabView {
Tab("View 1", systemImage: "square.grid.3x2") {
View1()
}
Tab("View 2", systemImage: "square.grid.2x2") {
View2()
}
}
.tabViewStyle(.sidebarAdaptable)
}
ReferenceError: ReadableStream is not defined
at Object. (/Users/anaadmin/Documents/AnaNewApp/node_modules/@expo/cli/node_modules/undici/lib/web/fetch/response.js:528:3)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Module.require (node:internal/modules/cjs/loader:1100:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object. (/Users/anaadmin/Documents/AnaNewApp/node_modules/@expo/cli/node_modules/undici/lib/web/fetch/index.js:11:5)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
After trying out all suggestions and different versions of tools such as XCode, nvm, yarn, node, etc., nothing works for me
i added :
<PROJECT_PATH>/node_modules/@langchain/core/dist/utils/stream.cjs - add const { ReadableStream } = require("web-streams-polyfill");
npm install web-streams-polyfill
Tried downgrading to Node 18 as well as various polyfills but haven't been able to get it to work
Following does not work in xcode
Delete your Podfile.lock (I like to use the command '-rm -rf Podfile.lock' on the terminal for this)
Delete your Pods folder (I like to use the command '-rm -rf Pods' in the terminal for this)
Delete your .xcworkspace
Pod install
Clear your project into XCode> Product> Clean Build Folder
i have tried
cd ios
pod install
Continuously i am getting same error.
Any one know, how to resolve this error
In macOS application, we are using SwiftUI as an entry point to our application and attaching appdelegate using NSApplicationDelegateAdaptor.
We are using NSViewControllerRepresentable to add a View Controller to the hiracrchy so that we can store intance of viewcontroller and add content to it programatically .
@main
struct TWMainApp: App {
@NSApplicationDelegateAdaptor private var appDelegate: TWAppDelegate
internal var body : some Scene {
TWInitialScene ()
}
}
TWInitialScene :
public struct TWInitialScene : Scene {
public var body : some Scene {
WindowGroup {
TWInitialView ()
}
}
}
TWInitialView :
struct TWInitialView : View {
@Environment(\.scenePhase) private var scenePhase
var body : some View {
TWAppKitToSwiftUIBridge ()
}
}
TWAppKitToSwiftUIBridge :
struct TWNSKitToSwiftUIBridge : NSViewControllerRepresentable {
func makeNSViewController(context: Context) -> TWNSViewController {
let view_hierarchy : TWNSViewController
view_hierarchy = TWStaticContext.sViewController
return view_hierarchy
}
func updateNSViewController(_ nsViewController: TWNSViewController, context: Context) {
}
}
@objc
public class TWStaticContext : NSObject
{
public static let sViewController = TWNSViewController ()
public override init () {}
@objc
public static func GetViewController () -> TWNSViewController
{
return TWStaticContext.sViewController
}
}
public class TWNSViewController : NSViewController {
override public func viewDidLoad ()
{
super.viewDidLoad ()
}
}
To add content to the hirarchy we are accessing viewcontroller's intance and adding content to it like this :
public func PaintInitialScreen () {
let label = NSTextField(labelWithString: "TW window")
label.frame = NSRect(x: 100, y: 200, width: 200, height: 200)
// Adding content to viewcontroller
TWStaticContext.sViewController.view.addSubview(label)
}
We are using this approach because we have a contraint in our application that we have to update UI programatically and on compile time we dont know what we want to show . We will be adding content on runtime based on how many button we want, what label we want , where to place it etc.
When we were using purely appKit application, doing things programatically was simple but since SwiftUI is a declarative application we have to use above approach.
Rational for shifting to SwiftUI entry point is that we want our application to be future safe and since apple is more inclined to SwiffUI, we want to design our entry flow to use SwiftUI entry point . And SwiftUI being declarative, we are using appKit to add content to hiracrchy programtically.
We have used similar apprach in iOS also , where are using UIApplicationDelegateAdaptor inplace of NSApplicationAdaptor . And UIViewControllerReprestable in place of NSViewControllerRepresentable.
Is this right approach to use ?
Hi,
I have created a line graph using LineMark in Charts, which by default includes grid lines and axes lines. My requirement is to remove the grid lines but retain the axes lines and the values.
I have tried the following code:
.chartXAxis {
AxisMarks(preset: .extended, values: .stride(by: 2), stroke: StrokeStyle(lineWidth: 0))
}
This is removing grid lines as well as axes lines.
How to retain axes lines while removing grid lines ?
I already have an opinion ( I should never release to a platform without testing on a physical platform device ) on this but wanted to learn from experience and expertise and see if there were any viable options.
My hybrid casual puzzle game is released on the App Store for iOS. (Whew!) Apparently it is compatible to both Mac OS and VisionOS
I would love to make it available everywhere however, I am not sure it is best to do so without testing on these physical devices. Which could also mean making the design adjustments for those devices, having test devices ready etc. and I would have to update my Laptop to silicon.
Has anyone tried this without testing on physical devices? What are your thoughts/best suggestions? Thanks in advance!
We are trying to write an iOS app that supports regular and constrained widths using a TabView with .tabViewStyle(.sidebarAdaptable). On the surface this seems like a great way to write an app that supports all the different widths that your app may run in. Especially since Stage Manager and Apple Vision have made it easy for users to resize your apps window while it is running.
We are facing many challenges though. I will give a brief one liner of each below, but to truly experience them you need to run the sample app, or watch the sample videos included.
Issues
Basic TabView Issues
Double Navigation Bar: When tabs are collapsed into a "More" tab, there's an unwanted double navigation bar
Selection Sync: Tab selection gets out of sync when switching between narrow/wide layouts through the "More" tab
TabView Crash
Fatal crash occurs when resizing window to narrow width while Tab 5 is selected
Error: SwiftUI/SidebarAdaptableTabViewStyle_iOS.swift:482: Fatal error: Tried to update with invalid selection value
Section Handling Issues
Section Display Bug: Bottom tabs incorrectly show section names instead of tab names in narrow width
Tab Selection Mismatch: Tab identifiers don't match selected tabs in narrow width mode
Customization Issues
Inconsistent "Edit" button behavior in More tab
Unable to properly disable tab customization
Sample app and video
https://github.com/copia-wealth-studios/swiftui-tabview-sample
AppStore download link:https://apps.apple.com/cn/app/%E7%9B%BC%E4%B9%8B%E4%BB%A3%E5%94%AE-%E4%B8%93%E4%B8%9A%E7%9A%84%E6%B8%B8%E6%88%8F%E6%9C%8D%E5%8A%A1%E5%B9%B3%E5%8F%B0/id6737429967. Why can this app be listed on the AppStore when it involves game account transactions? I have recorded and reported many times, but it has no effect. Is it possible to launch the app for game account trading in Chinese Mainland now? Seeking answers.
right now it looks like the app type must follow the guidelines like Messenger app, Navigate app, and Music app only. What about the Automotive app itself, What is the flexibility of it?
We have an app for service cars for one brand (officially)(car users around 1m+). but we looking to merge the experience between outside the car and inside the car. Can we top up some features on the app to share some information that is a part of the car like trip calculation or car info display on the screen? or services time to notice them?
And following that question can we know about the exact spot or brief from Apple car play for now and next-gen?
Or can we work with your team closely as a partner? to make things happen and develop it to be a flagship product, we can share some data and talk about it with real insight.
AppStore download link:https://www.qimai.cn/app/rank/appid/6737429967/country/cn. Why can this app be listed on the AppStore when it involves game account transactions? I have recorded and reported many times, but it has no effect. Is it possible to launch the app for game account trading in Chinese Mainland now? Seeking answers.
I am developing an app that requires calling the iPhone's Face ID module to scan users' facial data. Where can I find Apple's design resources and guidelines for Face ID? The Face ID resources available in Figma are incomplete, and I need more support.
For example, in the iPhone settings, the scenario: the UI interface for scanning the user's face to collect data, specifically the circular design in the "How to Set Up Face ID" screen.
The most recent update included coloured icons for grouping of emails
anybody previously needing to group emails we’re able to achieve this alphabetically by simply searching for what you were looking for.
These icons clutter the page with totally unnecessary screen pollution.
if you want to persist with this folly can you please provide a classic display option for those of us who have happily survived using email for 30 years without this fluff.
I tried to create a Text View using attributedString. I want to set the line height using paragraphStyle and return the Text, but paragraphStyle is not being applied. Why is that?
extension Text {
init?(_ content: String, font: StyleType, color: Color = .ppBlack) {
var attributedString = AttributedString(content)
attributedString.font = Font.custom(font.fontWeight, fixedSize: font.fontSize)
attributedString.foregroundColor = color
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = 16
paragraphStyle.maximumLineHeight = 16
paragraphStyle.lineSpacing = 0
attributedString.mergeAttributes(.init([.paragraphStyle: paragraphStyle]))
self = Text(attributedString)
}
}
In Apple's Maps app, an annotation is made up of a circle shape or rounded rectangles with a glyph-image.
When selecting an annotation, the annotation animates into a balloon marker (see attached GIF).
How does Apple Maps solve this - from custom annotation to balloon marker with spring animation?
I switched my Maps implementation from SwiftUI to UIKit with a UIViewRepresentable to support annotation clustering - and it works beautifully.
But how to subclass an MKAnnotationView (or MKMarkerAnnotationView <- the balloon) to enable selection and animation as in Apple Maps?
MKMarkerAnnotationView only show balloon markers and I tried everything inside MKAnnotationView (CALayer, etc.)
Hello everyone. I'm building a simple Form in a Multiplatform App with SwiftUI. Originally I had something like this.
import SwiftUI
struct OnboardingForm: View {
@State var firstName: String = ""
@State var lastName: String = ""
@State var email: String = ""
@State var job: String = ""
@State var role: String = ""
var body: some View {
Form {
TextField("First Name", text: $firstName, prompt: Text("Required"))
TextField("Last Name", text: $lastName, prompt: Text("Required"))
TextField("Email", text: $email, prompt: Text("Required"))
TextField("Job", text: $job, prompt: Text("Required"))
TextField("Role", text: $role, prompt: Text("Required"))
}
}
}
#Preview {
OnboardingForm()
}
In macOS it looks ok but then in iOS it looks like this:
and it's impossible to know what each field is for if all the prompts are the same. I tried adding LabeledContent around each text field and that solves it for iOS but then on macOS it looks like this:
The labels are shown twice and the columns are out of alignment. I think I could get around it by doing something like this:
#if os(iOS)
LabeledContent {
TextField("First Name", text: $firstName, prompt: Text("Required"))
} label: {
Text("First Name")
}
#else
TextField("First Name", text: $firstName, prompt: Text("Required"))
#endif
but it seems to me like reinventing the wheel. Is there a "correct" way to declare TextFields with labels that works for both iOS and macOS?
I'm trying to use Image Events instead of Photoshop to manipulate a bunch of images.
I need to extend the canvas and have the padding be white. I've tried
pad theImage to dimensions {545, 545} with pad color {65535, 65535, 65535}
But that does nothing. If I remove the 'with pad colour...' part, it works but the pad defaults to black. I've looked everywhere, but there doesn't seem to be a solution.
Is there one?
Hello.
I've been struggling to get through the app review. It's been 3 months of constantly improving and adding new features to the app and getting rejected.
A week ago i got a call from apple review team, and they said that my app shares the similar binary with other apps. They don't tell the specififcs or details.
My app is a vpn app that is written by me in flutter. The only native code i have is a library that i use to work with vpn. I changed the entirity of the library, but still can't get pass. Although, the only think left is the xray-core (https://github.com/XTLS/Xray-core) framework that implemented as .xcframework to use vless protocol.
Does apple check .xcramework for similarity? i can't rewrite the framework, because it written in a go language.