I have a Storyboard lifecycle application which has a UIViewController as window root view controller.
When I am trying to add the UIHostingController(SwiftUI view wrapped inside) to this root view controller as child view controller, the buttons and text fields in swiftUI view do not respond.
But when I am adding this UIHostingController as window root view controller or Navigation view controller's top view controller, then the swiftUI views respond in this case.
Please help me if I am missing anything
Below is the code that is used for adding the UIHostingController as child view controller which doesn't work
[self addChildViewController:hostingController];
[self.view addSubview:hostingController.view];
[hostingController didMoveToParentViewController:self];
This is the code that works (in delegate)
[window setRootViewController:hostingController];
OR this code
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:hostingController];
[window setRootViewController:navController];
Post
Replies
Boosts
Views
Activity
My app is an authenticated application. So I only show widget views only when user logs in.
In earlier beta versions of Xcode, prior to Xcode 12 GA, on passing nil timeline entires with reload policy of never, the system used to show placeholder view. But now I don’t see that.
When we are passing nil entires in timeline method the widget view is completely black.
Need help to show placeholder view until the app is authenticated. Any answer from anyone would be very helpful.
Currently using Xcode 12.1
Hi. I wanted to know how the placeholder UI was achieved in the demo applications shown in the videos. The app with train trip reservations and round trip travel reservations show app with placeholder labels.
Can I know how it was achieved?
Is it by using SwiftUI - redacted placeholders or was it by drawing using core graphics
Hi
Our application is a session based application. So until the user has not been authenticated on the main app, depending on the group container UserDefaults, we are passing zero timelines and the reload policy as .never.
But once user authenticates on the main application, we are setting session enabled in group container user defaults and issuing a reloadTimelines call. As our application is related to banking and wallets, so we are passing transactions related data to these timeline entries. But if user decides to logout, our due to some reason if a re-authentication is required, then how do we remove the already passed timelines.
Currently WidgetCenter doesn't have any API's regarding this. Can we get any information on this issue of removing the timeline entries. Any future plans on this? Maybe something line removing entries of a kind.
Hi. I have a widget designed which basically has to authenticate the user. As a result, during the creation of widget, I am passing empty entries to the widget and passing a reload polity of never. This scenario now just shows redacted views.
I have seen the WWDC video Meet WidgetKit explaining that widget can awaken from the main app when. Guessing this to be providing timelines entries from main app, how do I do this?
There is no documentation explaining the scenario of communication between main app and widgets and neither are there any videos relating to this.
Also the video hints at scheduling updates at a certain time from extension, does this mean initial Widget extension or Intents Extension?
Any info on these queries would be very helpful as developers would love to have their app driving the widget and not the other way around.
I am having issues developing and validating for WidgetKit.
I am trying to validate for IntentConfiguration and when I try to create a new custom Intent in the already Xcode generated intentdefinition's file, the class generation is failing behind the scenes I guess. CustomIntent.swift file, when I am using this dependency, Xcode build is not able to find this class.
MyCustomIntent.swift class file is not getting generated and I am not able to create my own intents, leading to modifying the existing ConfigurationIntent.swift by creating a new project and thereby using generated intentdefinitions file for development.
Also when developing for Dynamic Intents, we cannot proceed further as, even though I am able to modify the Xcode generated new project Intentdefinition file, but when I make this Intent type to use dynamic types, there is another issue with code generation. Dynamic types Intent variables protocol methods code is not getting generated in the DynamicIntent swift class file, due to which there is zero scope to proceed in this direction.
Overall, Static configuration can help developers for a mere UI check majorly. Most of the work all depends on background fetch using dynamic type. Please help on at least the code generation part for dynamic type protocol methods : provide<Type>CollectionForDynamicConfiguration in the intent handlers protocols.
I am creating Intent definition file and accessing the class in the widget class, but due to the above behaviour of file not getting created, getting build errors in the TimeLine provider class.
This issue is seen in Xcode 12 Beta 2
I have a view in swift(UIKit). I have converted this view to UIViewRepresentable and this I have used in swiftUI and my UIKIt view is visible in it.
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, world!").padding()
Text("This is root content view")
MyViewRepresentable()
}
}
}
This above swiftUI contentView is working fine while showing in the application form. But when I try the same in Widgets, the application is getting crashed.
I am getting the following error :
Fatal error: PlatformViewRepresentableAdaptor<MyViewRepresentable>: file /Library/Caches/com.apple.xbs/Sources/ChronoSim/Chrono-63.5/WidgetKit/SPI/WidgetViewArchive.swift, line 254
2020-07-08 12:45:31.402597+0530 TestSwiftWidgetExtension[24779:632349] Fatal error: PlatformViewRepresentableAdaptor<MyViewRepresentable>: file /Library/Caches/com.apple.xbs/Sources/ChronoSim/Chrono-63.5/WidgetKit/SPI/WidgetViewArchive.swift, line 254
We have an application where we have a worker thread working in parallel with the main thread. The application flow is in this way. First, the main thread calls JavascriptCore API JSObjectMake. While this is happening the worker thread also makes the JSValueUnprotect call to JavascriptCore framework. By observing the call stack we have found that main thread JSObjectMake call uses the JavaScriptCore API and locks certain block of the API and later when worker thread makes JSValueUnprotect API call it is locking JSC::JSLock::lock(long) the JavascriptCore thread. As a result, main thread waits for JS thread, but the JS thread is locked by closure thread and the closure thread is waiting for some other resource locked by main thread JSObject make call. Due to this deadlock, the application is freezing and later crashed by the watchdog.Please find the call stack below. What to do in this case. Are we doing anything wrong? Any small insight would be very helpful.* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x00000001bfcfad1c libsystem_kernel.dylib`__psynch_mutexwait + 8
frame #1: 0x00000001bfc1e868 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 92
frame #2: 0x00000001bfc1e7d8 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 260
frame #3: 0x00000001bfe8a594 CoreFoundation`CFRunLoopTimerSetNextFireDate + 344
frame #4: 0x00000001cfab3ccc JavaScriptCore`JSC::JSRunLoopTimer::Manager::scheduleTimer(JSC::JSRunLoopTimer&, ***::Seconds) + 564
frame #5: 0x00000001cfab45c4 JavaScriptCore`JSC::JSRunLoopTimer::setTimeUntilFire(***::Seconds) + 144
frame #6: 0x00000001cf6e4e28 JavaScriptCore`JSC::GCActivityCallback::didAllocate(JSC::Heap&, unsigned long) + 188
frame #7: 0x00000001cf6e71e4 JavaScriptCore`JSC::Heap::didAllocate(unsigned long) + 48
frame #8: 0x00000001cf702e88 JavaScriptCore`JSC::LocalAllocator::allocateSlowCase(JSC::GCDeferralContext*, JSC::AllocationFailureMode) + 216
frame #9: 0x00000001cf26985c JavaScriptCore`JSObjectMake + 608
*************PRIVATE CODE************* (Call to JavaScriptCore::JSObjectMake)
frame #36: 0x00000001bfe8c05c CoreFoundation`__CFRunLoopDoSource0 + 84
frame #37: 0x00000001bfe8b7c8 CoreFoundation`__CFRunLoopDoSources0 + 184
frame #38: 0x00000001bfe86694 CoreFoundation`__CFRunLoopRun + 1068
frame #39: 0x00000001bfe85f40 CoreFoundation`CFRunLoopRunSpecific + 480
frame #40: 0x00000001ca102534 GraphicsServices`GSEventRunModal + 108
frame #41: 0x00000001c3ffea60 UIKitCore`UIApplicationMain + 1940
frame #42: 0x0000000100ad5c54 main(argc=1, argv=0x000000016f3678b8) at main.m:94:9
frame #43: 0x00000001bfd04e18 libdyld.dylib`start + 4
thread #2
frame #0: 0x00000001bfcfbab4 libsystem_kernel.dylib`__workq_kernreturn + 8
thread #6, name = 'com.apple.uikit.eventfetch-thread'
frame #0: 0x00000001bfcd8c04 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001bfcd8020 libsystem_kernel.dylib`mach_msg + 76
frame #2: 0x00000001bfe8b964 CoreFoundation`__CFRunLoopServiceMachPort + 220
frame #3: 0x00000001bfe867fc CoreFoundation`__CFRunLoopRun + 1428
frame #4: 0x00000001bfe85f40 CoreFoundation`CFRunLoopRunSpecific + 480
frame #5: 0x00000001c01cb3b0 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
frame #6: 0x00000001c01cb288 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 92
frame #7: 0x00000001c409a23c UIKitCore`-[UIEventFetcher threadMain] + 156
frame #8: 0x00000001c01ca014 Foundation`-[NSThread main] + 40
frame #9: 0x00000001c0305a7c Foundation`__NSThread__start__ + 852
frame #10: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #7, name = 'Worker Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c24 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 84
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001ceff8f48 JavaScriptCore`***::LockAlgorithm<unsigned char, (unsigned char)1, (unsigned char)2, ***::EmptyLockHooks<unsigned char> >::lockSlow(***::Atomic<unsigned char>&) + 244
frame #5: 0x00000001cfa854c4 JavaScriptCore`JSC::JSLock::lock(long) + 256
frame #6: 0x00000001cfa85024 JavaScriptCore`JSC::JSLockHolder::JSLockHolder(JSC::ExecState*) + 60
frame #7: 0x00000001cf2714cc JavaScriptCore`JSValueUnprotect + 36
*************PRIVATE CODE************* (Call to JavaScriptCore::JSValueUnprotect)
frame #17: 0x00000001bfde7ab4 CoreFoundation`-[__NSDictionaryI dealloc] + 156
frame #18: 0x00000001bfc433f8 libobjc.A.dylib`objc_release + 136
frame #19: 0x00000001bfc449c8 libobjc.A.dylib`AutoreleasePoolPage::releaseUntil(objc_object**) + 184
frame #20: 0x00000001bfc448b4 libobjc.A.dylib`objc_autoreleasePoolPop + 232
frame #21: 0x00000001bff1d958 CoreFoundation`_CFAutoreleasePoolPop + 32
frame #22: 0x00000001bfe8bb7c CoreFoundation`__CFRunLoopDoTimers + 364
frame #23: 0x00000001bfe869d0 CoreFoundation`__CFRunLoopRun + 1896
frame #24: 0x00000001bfe85f40 CoreFoundation`CFRunLoopRunSpecific + 480
frame #25: 0x00000001c01cb3b0 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
frame #26: *************PRIVATE CODE*************
frame #27: 0x00000001c0305a7c Foundation`__NSThread__start__ + 852
frame #28: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #8, name = 'Network Thread'
frame #0: 0x00000001bfcd8c04 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001bfcd8020 libsystem_kernel.dylib`mach_msg + 76
frame #2: 0x00000001bfe8b964 CoreFoundation`__CFRunLoopServiceMachPort + 220
frame #3: 0x00000001bfe867fc CoreFoundation`__CFRunLoopRun + 1428
frame #4: 0x00000001bfe85f40 CoreFoundation`CFRunLoopRunSpecific + 480
frame #5: 0x00000001c01cb3b0 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
frame #6: *************PRIVATE CODE*************
frame #7: 0x00000001c0305a7c Foundation`__NSThread__start__ + 852
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #9, name = 'JavaScriptCore bmalloc scavenger'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001bfd4fd04 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
frame #3: 0x00000001cf05e21c JavaScriptCore`void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 104
frame #4: 0x00000001cf061c80 JavaScriptCore`bmalloc::Scavenger::threadRunLoop() + 196
frame #5: 0x00000001cf061978 JavaScriptCore`bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 16
frame #6: 0x00000001cf062cbc JavaScriptCore`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(bmalloc::Scavenger*), bmalloc::Scavenger*> >(void*) + 44
frame #7: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #15
frame #0: 0x00000001bfc219e0 libsystem_pthread.dylib`start_wqthread
thread #16
frame #0: 0x00000001bfcfbab4 libsystem_kernel.dylib`__workq_kernreturn + 8
thread #17
frame #0: 0x00000001bfcfbab4 libsystem_kernel.dylib`__workq_kernreturn + 8
thread #18
frame #0: 0x00000001bfcfbab4 libsystem_kernel.dylib`__workq_kernreturn + 8
thread #19, name = 'JSC Heap Collector Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #20, name = 'Heap Helper Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #21, name = 'Heap Helper Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #22, name = 'Heap Helper Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #23, name = 'Heap Helper Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
thread #24, name = 'Heap Helper Thread'
frame #0: 0x00000001bfcfaccc libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001bfc1d21c libsystem_pthread.dylib`_pthread_cond_wait + 676
frame #2: 0x00000001cf021c64 JavaScriptCore`***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) + 148
frame #3: 0x00000001cf00723c JavaScriptCore`***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1928
frame #4: 0x00000001cefddfc4 JavaScriptCore`bool ***::Condition::waitUntil<***::Lock>(***::Lock&, ***::TimeWithDynamicClockType const&) + 192
frame #5: 0x00000001cefde334 JavaScriptCore`***::Detail::CallableWrapper<***::AutomaticThread::start(***::AbstractLocker const&)::$_0, void>::call() + 208
frame #6: 0x00000001cf01f8f8 JavaScriptCore`***::Thread::entryPoint(***::Thread::NewThreadContext*) + 260
frame #7: 0x00000001cf021444 JavaScriptCore`***::wtfThreadEntryPoint(void*) + 16
frame #8: 0x00000001bfc19840 libsystem_pthread.dylib`_pthread_start + 168
Apple has made it mandatory to use launch screen storyboards by April 2020. If not done so, the app store submissions would get rejected.This is not a big deal. We can create a storyboard and use the same as the launch screen storyboard. But what I wanted to know is that I wanted to use a full-screen image view on this storyboard, and use the launch screen images as a source for image view.The problem with this is that these launch images are different for different resolutions. For example, iPhone 8/7/6 uses a 667-height/scale-2 resolution image and iPhone SE uses a 568-height/scale-2 image. The appropriate image can be set for the running device target and get the desired launch screen image for the launch storyboard image view and get the splash screen running. But while generating an IPA, the launch screen image does not act dynamically and the image view could not use the appropriate launch screen.The above issue can be solved by using a custom class for the UI element, but the launch storyboard doesn’t support the concept of custom classes for these elements.What can be done to use the old generated splash launch images to be used on a launch screen storyboard? Any suggestions would be helpful.