Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to select BarChartView from storyboard (OS X) #1197

Closed
breathe opened this issue Jun 29, 2016 · 13 comments
Closed

Unable to select BarChartView from storyboard (OS X) #1197

breathe opened this issue Jun 29, 2016 · 13 comments
Assignees

Comments

@breathe
Copy link

breathe commented Jun 29, 2016

I'm not sure entirely what's going on -- but I'm encountering an issue where the views exported from the Charts module are not useable from storyboard files. I can reproduce easily with the ChartsDemo-OSX Xcode project included in the source repo.

Steps to see the issue:

  1. clone Charts repo
  2. open ChartsDemo-OSX.xcodeproj
  3. build and run (verify everything works as expected)
  4. Edit main.storyboard, change class of the BarChartView to NSView (and click away to make sure selection was saved)
  5. Attempt to change the class of that view back to BarChartView -- IB won't see any views within the Charts module.

I'm wondering if maybe something about the conditional compilation for UIKit/AppKit is confusing the way that IB discovers NSView subclasses? Can anyone else reproduce the issue or have a workaround?

This is with Xcode 7.3.1 on OS 10.11.5

@liuxuan30
Copy link
Member

liuxuan30 commented Jun 30, 2016

would StackOverflow experts help on this?

@breathe
Copy link
Author

breathe commented Jun 30, 2016

Are you saying that following the above procedure does not reproduce the result for you?

I reproduced this behavior on two machines using the instructions above and the repository source.

I do not believe this is user error - but I would gladly take a pointer to a relevant stack overflow post to resolve this. I've not seen this behavior before of Interface Builder failing to see modules from embedded frameworks which otherwise work fine.

@wpccolorblind
Copy link

I see the same issue as well.. it also repros in the out of box sample as in the above steps as well as for new views.

  1. Clean clone
  2. Open ChartsDemo-OSX.xcodeproj
  3. Open Main.storyboard
  4. Delete any of the Chart Views in any of the View Controllers, let's say the Line Graph View
  5. Place new NSView onto the View Controller you just deleted from
  6. Attempt to set the class name or module name in the Identity Inspector

Expected - You can set Module to "Charts" and class to "LineChartView"

Actual - No code completion on this. When you set the value and press enter the value goes away. There is no way to set the class or module on a newly placed view. Attached screenshot for reference.

screen shot 2016-06-29 at 8 24 56 pm

@liuxuan30
Copy link
Member

liuxuan30 commented Jul 1, 2016

@breathe I am saying we might not be the experts for your issue, so help wanted.

@thierryH91200
Copy link
Contributor

sorry but English was not my native language

I see the same issue as well.
I solved the problem this way
I created a new project
I will insert "charts" without being a frameworks
I compiled and or there were mistakes I have added
"Import Cocoa"

and it works
capture d ecran 2016-07-01 a 18 21 34
capture d ecran 2016-07-01 a 18 26 34

@thierryH91200
Copy link
Contributor

you can follow this link : https://github.com/thierryH91200/Charts-Mac

@liuxuan30
Copy link
Member

@breathe does @thierryH91200 's advice work for you?

@breathe
Copy link
Author

breathe commented Jul 4, 2016

Hi Thierry -- thanks for the trick! I haven't had a chance to try it out yet but I'll give it a try next week and let you know if it works for me.

I'm also gonna take a stab at tweaking the code a bit to explore the theory that there's about the conditional compilation that is confusing in and see if I can find a workaround pattern.

Thanks for the help!

@kettch
Copy link

kettch commented Jul 31, 2016

Ran into the exact same problem. The only thing I could do to make it work was open the XIB as source code, and edit it manually to add the class and module for the view. Once it's set, it will stay there and work properly.

@SpaceDuster
Copy link

I do have the exact same problem. Unfortunately @thierryH91200 's solution doesn't work for me.
Kettch: can you please show or explain how the XIB file has to be edited?

@kettch
Copy link

kettch commented Aug 24, 2016

Here's what you need to do:

  • In your XIB, put an easily identifiable identity label to the view that has to be a chart, for later
  • Find your XIB/Storyboard in the project navigator
  • Right click it, then choose 'Open As' > 'Source Code'. You'll see your file as a XML file
  • Search for the label you used for your view earlier, this would be in a tag, with a few attributes. Something like this:
    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Oqd-Ej-1xl">
  • Add the 'customClass' and 'customModule' attributes to it, like this (change the class to whatever kind of chart you need there):
    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Oqd-Ej-1xl" customClass="BarChartView" customModule="Charts">

Then you can build or reopen your XIB/Storyboard normally through 'Open As' > 'Interface Builder Document', and you will see the custom class & module on your view.
If you want to see examples, open any XIB from the Demo project as source code.

@pmairoldi
Copy link
Collaborator

I just tried this and it works as expected if you set the class of the view to be BarChartView and the module to be Charts. I am using Xcode 8.

@tschmitz
Copy link

tschmitz commented Dec 12, 2017

@petester42 This works properly for me in iOS projects, but I still have the issue with a MacOS project running Xcode 9.2. When I attempt to set the view class to BarChartView, it's immediately reverted back to NSView. I'm unable to edit the Module field. However, the method mentioned above of editing the customClass and customModule values manually in the storyboard source did work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants