onekiloparsec / KPCTabsControl

A macOS control for tabs with enhanced capabilities, and styles: Safari, Chrome and custom ones.
MIT License
170 stars 26 forks source link

Unknown class TabsControl #38

Closed hk05 closed 5 years ago

hk05 commented 5 years ago

I downloaded KPCTabsControl and build the framework with carthage. Then I added the framework, as intended. Everything builds (without adding IB elements yet).

Next I add a a ViewController, set class "ViewController" in its Identity Inspector (ViewController.swift contains code identical to the code in the KPCTabsControlDemo).

Finally I add a NSView to this ViewControllers view and set its class to "TabsControl" in the Identity Inspector. I also bind the interface items, as in the demo.

When I run this, I get an error: "Unknown class TabsControl in Interface Builder file". The view with the tabs (obviously) does not show.

I checked the framework, which seems to embed correctly in the project. I also played with the Module name in Identity Inspector, to no avail. I rebuild and attempted several times.

I must be overlooking something here, but cannot figure it out. Do you have any idea? Any helpful pointers are highly appreciated!

Thanks

onekiloparsec commented 5 years ago

Hm, strange. Two things I think right now:

hk05 commented 5 years ago

Hi Cedric,

Thanks for replying.

When I set the custom class in the Identity Inspector. the module field does not change (remains empty). I have tried to set this (also on my own project name), to no avail.

The framework has been added in de embedded binaries. I followed Carthage instructions as careful as possible.

I am banging my head, because I cannot figure this out. As a temporary solution I enclosed the KPCTabsControl project file and compiled everything in-project (excluding any framework). That is working, but a dirty workaround for the time being (I prefer to include the frameworks).


And to make my headache even worse, I ran into another weird problem. I should file another issue for this, but I am currently still investigating (hoping to find a solution myself). Just for you to know in advance:

Wwhen using KPCTabsControl, running the exact same project in succession, no visible window appears. It is running, but nothing can be seen, not even when clicking on the running app. Restarting Xcode won’t help either. One thing helps: full reboot. Very weird. Have you ever encountered something like this? Possibly a bug in xcode 10.1 or Mojave, because killing xcode won’t even help.

Today is a very bad coding day, I am banging my head against the wall, trying to figure out what could be wrong in both of these cases.

If I figure out either of the two problems, I will let you know. Might you be able to point me in the right direction, then thank you in advance for any tip.

Thanks,

Hans

On 8 Nov 2018, at 12:34, Cédric Foellmi notifications@github.com wrote:

Hm, strange. Two things I think right now:

When setting the Custom Class in the Identity Inspector, does the Module field update automatically to KPCTabsControl (yes this time with KPC prefix)? Have you added the .framework also in the "General -> Embedded Binaries" settings ? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-436964779, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPvwHtuiIKAD9RyxL1jVjAAZlkIptks5utBa9gaJpZM4YUYAq.

hk05 commented 5 years ago

Hm, strange. Two things I think right now:

  • When setting the Custom Class in the Identity Inspector, does the Module field update automatically to KPCTabsControl (yes this time with KPC prefix)?

No, xcode 'recognizes' the TabsControl, the module field remains unchanged (empty). I tried changing this field in several ways, to no avail.

  • Have you added the .framework also in the "General -> Embedded Binaries" settings ?

Yes, the framework has been added 'the carthage way': add framework to embedded binaries.

hk05 commented 5 years ago

Hi Cedric,

Something very weird just happened. The problem seems to have vanished as oddly as it appeared(??!!)

After I rebooted for about the fifth time, all of a sudden the second problem disappeared. Or at least: I could not reproduce the problem any more. Next I decided to also take another look at the first problem. So I removed the workaround (dragged in files) and re-embedded the framework. I also disconnected/reconnected the ViewController from its parents. To my surprise: the issue disappeared. I am not quite sure what caused the issue to disappear. And I am not quite confident yet that it has disappeared forever. But it did.

I am quite flabbergasted right now. I think I will take a walk to let this sink in. When back I will try again. If it stays away, then I will add the ’solution’ on GitHub as well. I am wondering about the root cause. I suspect a bug in the storyboard compilation, but I am most definitely not sure (and hope I will not run into this again, as it is very hard to explain).

For now: thanks a lot. And might you have an inkling about what could be the root cause of these issues. please let me know.

Thanks again, both for replying and for sharing your project!

Hans

On 8 Nov 2018, at 13:01, github@ziezo.com wrote:

Hi Cedric,

Thanks for replying.

When I set the custom class in the Identity Inspector. the module field does not change (remains empty). I have tried to set this (also on my own project name), to no avail.

The framework has been added in de embedded binaries. I followed Carthage instructions as careful as possible.

I am banging my head, because I cannot figure this out. As a temporary solution I enclosed the KPCTabsControl project file and compiled everything in-project (excluding any framework). That is working, but a dirty workaround for the time being (I prefer to include the frameworks).


And to make my headache even worse, I ran into another weird problem. I should file another issue for this, but I am currently still investigating (hoping to find a solution myself). Just for you to know in advance:

Wwhen using KPCTabsControl, running the exact same project in succession, no visible window appears. It is running, but nothing can be seen, not even when clicking on the running app. Restarting Xcode won’t help either. One thing helps: full reboot. Very weird. Have you ever encountered something like this? Possibly a bug in xcode 10.1 or Mojave, because killing xcode won’t even help.

Today is a very bad coding day, I am banging my head against the wall, trying to figure out what could be wrong in both of these cases.

If I figure out either of the two problems, I will let you know. Might you be able to point me in the right direction, then thank you in advance for any tip.

Thanks,

Hans

On 8 Nov 2018, at 12:34, Cédric Foellmi <notifications@github.com mailto:notifications@github.com> wrote:

Hm, strange. Two things I think right now:

When setting the Custom Class in the Identity Inspector, does the Module field update automatically to KPCTabsControl (yes this time with KPC prefix)? Have you added the .framework also in the "General -> Embedded Binaries" settings ? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-436964779, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPvwHtuiIKAD9RyxL1jVjAAZlkIptks5utBa9gaJpZM4YUYAq.

onekiloparsec commented 5 years ago

Hi Hans. Indeed, suprising to see it solved my magic! At least, I'm glad you can now keep going. I'll close the issue for now, but don't hesitate to reopen if needed.

hk05 commented 5 years ago

Hi Cedric,

Indeed happy and indeed weird. I took a walk and concluded it must have been the storyboard messing up. It could explain both issues, but… it remains a bit weird.

If this issue does not come back it might be meaningful to update the issue on GitHub with an advise to disconnect the viewController and -to be sure- also reboot.

Thanks again & have a nice day

Hans

On 8 Nov 2018, at 14:04, Cédric Foellmi notifications@github.com wrote:

Hi Hans. Indeed, suprising to see it solved my magic! At least, I'm glad you can now keep going. I'll cose the issue for now, but don't hesitate to reopen if needed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-436986839, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPstzbQ88Kl3D7I2mZ9dKv4tVZzn4ks5utCvNgaJpZM4YUYAq.

hk05 commented 5 years ago

Hi Cedric,

Sorry to interrupt you again. Problem not quite solved after all. I did figure out some interesting new stuff though.

Firstly, the problem also occurs on your KPCTabsControlDemo, just as downloaded. I tested in xcode 10.1 and on xcode 10.0 beta 4, on different machine. Both appear to show more or less the same issue.

Running the app (demo), after a while the app does not show on screen. I cannot (yet) reproduce this 100% accurate. At some random moment the app seems to ‘decide’ it is not viewable any more. The app is running though. Clicking the app does nothing.

I seem to be able to consistently fix this as follows: open the storyboard in xcode. Disconnect the segue. Run the app ( an empty window appears). Close again. Reconnect the ViewController to the Window Controller. Problem fixed. Note that it is required to run the app with a disconnected ViewController before reconnecting.

After a while the same issue appears, same solution applies.

To figure out what could be going on here, I tried running my app in Instruments.When the app is misbehaving (not showing on screen), I found that clicking the ‘record’ button in Instruments makes the window appear. Until I stop the recording: gone again. Etc.

All this makes me wondering. Seemingly some part of the code is causing a side effect that makes the window invisible. But what part in the code could be the trouble maker, that’s the big question. Maybe it is in the code, maybe it is in the storyboard. What is consistent: it always appears when using KPCTabs. It only appears when using KPCTabs. Disconnecting and reconnecting the ViewController will solve the issue, but only for a little while.

I have also been checking my memory, but that seems of no relevance.

Can you reproduce the same problem on xcode 10? (I am using the latest software on Mojave).

Thanks.

Hans

On 8 Nov 2018, at 14:26, github@ziezo.com wrote:

Hi Cedric,

Indeed happy and indeed weird. I took a walk and concluded it must have been the storyboard messing up. It could explain both issues, but… it remains a bit weird.

If this issue does not come back it might be meaningful to update the issue on GitHub with an advise to disconnect the viewController and -to be sure- also reboot.

Thanks again & have a nice day

Hans

On 8 Nov 2018, at 14:04, Cédric Foellmi <notifications@github.com mailto:notifications@github.com> wrote:

Hi Hans. Indeed, suprising to see it solved my magic! At least, I'm glad you can now keep going. I'll cose the issue for now, but don't hesitate to reopen if needed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-436986839, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPstzbQ88Kl3D7I2mZ9dKv4tVZzn4ks5utCvNgaJpZM4YUYAq.

hk05 commented 5 years ago

Hi Cedric,

I intend to contrib a bit to your project (coding a + and/or close tabs), but the instability is driving me nuts. I cannot keep window with KPCTabsControl connected in my project without things turning haywire. After a number of runs the app does not show any more. I have to reset everything to get things working again. An unworkable situation.

I have been trying to figure out the issue, but cannot get my finger behind it. I have tried many thing, and found that if i disconnect the appcontroller with KPCTabs, everything works fine. Until I reconnect KPCTabsController. I draw the conclusion that something in KPCTabsControl is causing the havoc. My knowledge of KPCTabsControl is insufficient to completely understand thought. I also investigated xcode 10.1 to read about known issues. The only thing that keeps me boggling is the message in https://developer.apple.com/documentation/xcode_release_notes/xcode_10_1_release_notes: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_1_release_notes:

If you indirectly modify a property using a nonmutating setter that's defined in a protocol or extension on a class instance, the Swift compiler might miscompile it by releasing the instance after the getter is invoked. This might cause the program to crash or have unpredictable behavior at runtime. (45274900)

I looked at your code but cannot find any specifics, but… I do not fully comprehend everything you coded. Hence I turn to you with a question: do you think this known issue might be somehow related with the problems occurring, or are you pretty convinced this has nothing to do with it?

I’ll keep digging because I like KPCTabsControl, but am at the brink of giving up as I am quickly running out of ideas (and patience dealing with the problem)…

Thanks and have a nice weekend!

Hans

On 8 Nov 2018, at 15:59, github@ziezo.com wrote:

Hi Cedric,

Sorry to interrupt you again. Problem not quite solved after all. I did figure out some interesting new stuff though.

Firstly, the problem also occurs on your KPCTabsControlDemo, just as downloaded. I tested in xcode 10.1 and on xcode 10.0 beta 4, on different machine. Both appear to show more or less the same issue.

Running the app (demo), after a while the app does not show on screen. I cannot (yet) reproduce this 100% accurate. At some random moment the app seems to ‘decide’ it is not viewable any more. The app is running though. Clicking the app does nothing.

I seem to be able to consistently fix this as follows: open the storyboard in xcode. Disconnect the segue. Run the app ( an empty window appears). Close again. Reconnect the ViewController to the Window Controller. Problem fixed. Note that it is required to run the app with a disconnected ViewController before reconnecting.

After a while the same issue appears, same solution applies.

To figure out what could be going on here, I tried running my app in Instruments.When the app is misbehaving (not showing on screen), I found that clicking the ‘record’ button in Instruments makes the window appear. Until I stop the recording: gone again. Etc.

All this makes me wondering. Seemingly some part of the code is causing a side effect that makes the window invisible. But what part in the code could be the trouble maker, that’s the big question. Maybe it is in the code, maybe it is in the storyboard. What is consistent: it always appears when using KPCTabs. It only appears when using KPCTabs. Disconnecting and reconnecting the ViewController will solve the issue, but only for a little while.

I have also been checking my memory, but that seems of no relevance.

Can you reproduce the same problem on xcode 10? (I am using the latest software on Mojave).

Thanks.

Hans

On 8 Nov 2018, at 14:26, github@ziezo.com mailto:github@ziezo.com wrote:

Hi Cedric,

Indeed happy and indeed weird. I took a walk and concluded it must have been the storyboard messing up. It could explain both issues, but… it remains a bit weird.

If this issue does not come back it might be meaningful to update the issue on GitHub with an advise to disconnect the viewController and -to be sure- also reboot.

Thanks again & have a nice day

Hans

On 8 Nov 2018, at 14:04, Cédric Foellmi <notifications@github.com mailto:notifications@github.com> wrote:

Hi Hans. Indeed, suprising to see it solved my magic! At least, I'm glad you can now keep going. I'll cose the issue for now, but don't hesitate to reopen if needed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-436986839, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPstzbQ88Kl3D7I2mZ9dKv4tVZzn4ks5utCvNgaJpZM4YUYAq.

onekiloparsec commented 5 years ago

Hi Hans. The custom setters used in KPCTabsControl are all normally and implicitely 'mutating' (this is the normal behavior). I don't see anything special in the Protocols.swoft file either. Maybe you should post here piece of your code for let us/me check.

hk05 commented 5 years ago

Hi Cedric,

Thanks for your reply.

The code is simply your demo (which is having the exact same problem). I tried on different machines in xcode 10.1 and xcode 10.0 beta 4. You should be able to try it yourself by running your own demo app (hoping the same applies on your machine if you run it in xcode 10/swift 4.2). Note though that the problem occurs add a random moment in time. Then runs well for a smaal number of runs, then causes problems again. Etc.

It could be xcode related, or something different. No matter what I try, I cannot figure out what could be wrong… I’ll keep trying a little more if I get some ideas…

Thanks

Hans

On 10 Nov 2018, at 17:11, Cédric Foellmi notifications@github.com wrote:

Hi Hans. The custom setters used in KPCTabsControl are all normally and implicitely 'mutating' (this is the normal behavior). I don't see anything special in the Protocols.swoft file either. Maybe you should post here piece of your code for let us/me check.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-437594757, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPi1W7w3GfF3V5VKi5409370I9mEPks5utvq4gaJpZM4YUYAq.

onekiloparsec commented 5 years ago

Sorry, but my demo works fine on my computer... Xcode10.1 (10B61). I noticed the demo was with swift4 and not swift4.2. I changed the project to have swift4.2 everywhere. But anyway, with both versions, the demo was working fine...

hk05 commented 5 years ago

Have you tried start/stopping the app many times (mine usually stalls after 10 - 20 times), after which nothing appears any more… Very weird.

The thing is this only happend when I connect KPCTabsControl, without it: no problems whatsoever. This weird side effect is causing me a headache.

Thanks for trying.

If I cannot find the root cause and get things stable/reliable, I feel forced to throw everything away to avoid any more waste of time and invent my own tab project (which I hope won’t be necessary, I’d rather avoid reinventing the wheel).

Best regards and happy weekend,

Hans

On 10 Nov 2018, at 18:04, Cédric Foellmi notifications@github.com wrote:

Sorry, but my demo works fine on my computer... Xcode10.1 (10B61). I noticed the demo was with swift4 and not swift4.2. I changed the project to have swift4.2 everywhere. But anyway, with both versions, the demo was working fine...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-437598770, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPlUIGPV2Yf7rUlZ59CSVX-HkAnleks5utwcWgaJpZM4YUYAq.

hk05 commented 5 years ago

Hi Cedric,

It took me my weekend, but I found the root cause of the problem. I am still looking for a decent solution (I have a quick&dirty workaround that seems stable for the time being).

The problems are being caused by persisting the state. At first I found that enabling the option “Launch application without state restoration” in the app scheme had a positive effect: turning this setting on stopped the problem (of window never appearing), turning it off again would consistently reintroduce the problem.

In your code I found the following implementation in the following functions to be the culprit: open override func encodeRestorableState(with coder: NSCoder) {

open override func restoreState(with coder: NSCoder) {

If I comment out the code in these functions (except calling super) then things are stable even when I keep the “Launch application without state restoration” option off.

So, in conclusion: removing the implementation of the above mentioned functions removes the problems.

I have not (yet) found a solid alternative implementation, as I do not (yet) fully understand what you wanted to achieve with the implementation (exact usage scenarios), as there are no Tests or comments in the code for this.

BR,

Hans

On 10 Nov 2018, at 18:48, github@ziezo.com wrote:

Have you tried start/stopping the app many times (mine usually stalls after 10 - 20 times), after which nothing appears any more… Very weird.

The thing is this only happend when I connect KPCTabsControl, without it: no problems whatsoever. This weird side effect is causing me a headache.

Thanks for trying.

If I cannot find the root cause and get things stable/reliable, I feel forced to throw everything away to avoid any more waste of time and invent my own tab project (which I hope won’t be necessary, I’d rather avoid reinventing the wheel).

Best regards and happy weekend,

Hans

On 10 Nov 2018, at 18:04, Cédric Foellmi <notifications@github.com mailto:notifications@github.com> wrote:

Sorry, but my demo works fine on my computer... Xcode10.1 (10B61). I noticed the demo was with swift4 and not swift4.2. I changed the project to have swift4.2 everywhere. But anyway, with both versions, the demo was working fine...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/KPCTabsControl/issues/38#issuecomment-437598770, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhUPlUIGPV2Yf7rUlZ59CSVX-HkAnleks5utwcWgaJpZM4YUYAq.