I imported the objective c class I wanted to use into my bridging header but once I did, Xcode seemed to recognize the objective c code as swift code. What should I do to tell Xcode that the class is an Objective c class?
You might have gotten the file type wrong in XCode.
Click the folder icon on the left to switch to the project navigator in the left pane
Select the header file UIImageView+PlayGIF.h
Click the file icon on the right to switch to the file inspector in the right pane
Check and possibly fix the type of the file
The correct file types are:
"Default - C Header" for header files with extension .h
"Default - Objective-C Source" for Objective-C files with extension .m
"Default - Swift Source" for Swift files with extension .swift
Related
I know you can create a screen for an iOS app entirely with code. But when you use the interface builder part of Xcode, where is all of that information going? Is it being written to a file you can view?
A Storyboard itself is a file contained in your project folder, so you must create a storyboard file in Xcode in advance before using the Storyboard.
To create a storyboard file:
Press Command + N in Xcode ( or choose on File > New > File)
Then you can create a storyboard file, and you can find the file in Xcode Navigator or Finder.
If you want to check the source code of the storyboard file, just open it with text editors.
I've made changes to my Core Data models. I've selected Editor > Create NSManagedObjectContext Subclass. Clicked next, next, next. Now xcode is prompting for confirmation on "would you like to configure an Objective-C bridging header".
Last time I did this I had no problems (xcode 7, swift 2.3). It created the correct Swift files. I'm now using xcode 8, swift 3.
I have no Objective-C code in my project.
When I click "Dont create", xcode creates .h and .m files with Objective C code in it.
How do I solve this?
Thanks.
Solved.
Select model.xcdatamodeld on the left, then in the File Inspector pane (far right, icon looks like a new document icon). Change Code Generation to Swift, form Objective-C.
I would like to use an UIView subclass from an external framework in my project's Storyboard. I tried with different projects but each time I can't see the class name in the custom class dropdown menu.
Is it possible to make it work?
I guess the frameworks are fine, it should be an import/linking problem.
One thing could be that you are using a mix of swift and objective c like your project is in swift and your framework is in objective c in that case you need to add bridging header and import your .h files in it. It will work if that's the case
I'm starting a project but I have another one very similar as base.
I create my new project with storyboard and CoreData, create a new file of NSObject class, and when I start writing in the .h file:
#property (nonanatomic, retain) ns...
nsstring or any type of variable doesn't appear... for example, I start writing ns and it appears:
NS_DURING
NS_ENDHANDLER
NS_HANDLER
NS_VALUERETURN
NS_VOIDRETURN
and the most of code is in black letter, i mean, nothing is coloured as it shoud be normal like purple, blue, etc... the colour that xcode sets... here you can see it:
http://oi61.tinypic.com/359iws6.jpg
P.S: I'm using Xcode 5 Preview 3 and OsX Mavericks. I've never had this problem I think.
Possibly your dot-m (the implementation) file is not a member of the target.
When adding a new file to the project on the bottom of the save dialog there is a Target Membership window . Did you check that box?
To view the target membership and/or to add an existing file to your target open the implementation file. Then open the File Inspector using ⌥+⌘ 1 or View, Utilities, Show File Inspector.
In the File Inspector window halfway down there is the Target Membership. Check the box next to your target.
Syntax highlighting will begin after a short moment, wait for Xcode to finish its indexing.
Try out this: In XCode open Preferences, click on the Text Editing Tab and make sure "Use Escape key to show completion suggestions" is checked.
I have this class for button which was added to my project workspace. I had
linker error ( Apple Mach-o Linker Error)
Then again i opened a new project and added this class.
In my ViewController.h
#import <UIKit/UIKit.h>
#import <UIView+Glow.h>
#interface ViewController:UIViewController
#property(non atomic,strong) IBOutlet UIView *testView;
end
And in my ViewController.m
Added is the screenshot
#importViewController.h
-(void) viewDidLoad{
[super viewDidLoad];
[testView startGlowing]
}
I had
*unrecognized selector sent to instance error
This is the class
I suggest you use the Glow Category of UIView made by secret lab.
Any suggestion on how to call this class?
attached are the screenshots of the issue
If you have copied UIView+Glow.h into your project, you should use this to import it:
#import "UIView+Glow.h"
You should not use the angle brackets (<UIView+Glow.h>) to import headers that are part of your project.
If you have not copied UIView+Glow.m into your project, you need to do so.
If you have copied UIView+Glow.m into your project, you need to make sure it is included in the “Compile Sources” build phase of your target.
The easiest way to check is to open UIView+Glow.m in the primary editor. Then choose the View > Utilities > Show File Inspector menu item. Look at the File Inspector (on the right side of the Xcode window). Make sure it's showing information for UIView+Game.m. Then look at the “Target Membership” section. Make sure the checkbox next to your target is checked.
Update
The three linker errors in your final screenshot happened because you haven't added the QuartzCore framework to your project. This is the framework that contains the Core Animation classes.
If you don't know how to add a framework to your project, look at How to "add existing frameworks" in Xcode 4?.
Make sure that you use the following line at the top of the implementation file where you want to use the glow methods:
#import "UIView+Glow.h"