HOWTO Export/Import custom code snippets in XCode 6 - xcode6

Is there a way how to export the custom code snippets from XCode 6 and then import it to the XCode 6 of another user?
The snippets are now in one XML file: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
Thanks

In Xcode 7.3.1, my snippets have been created in ~/Library/Developer/Xcode/UserData/CodeSnippets. It looks like you may be in the wrong directory. Put your codes snippets in this directory instead.
On a side note, you can find my code snippets here: XcodeSnippets GitHub

Related

How do I use Objective-C code from Github in my Swift program?

Summary of problem
I'm building a calendar app in Swift, and I'd like to start with the UI in this repo: https://github.com/erichoracek/MSCollectionViewCalendarLayout
This repo is written in Objective-C.
However, I'm not sure how to build on top of this Github repo using Swift.
Example of the UI I'd like to use in my calendar:
What I've tried
I successfully installed this library with CocoaPods.
I ran $pod install.
I successfully ran import MSCollectionViewCalendarLayout.
I added a new CollectionViewController on my Storyboard, and assigned it to my custom CalendarViewController class
I tried (dumbly) with the code below in class CalendarViewController,but I get this error message:
"Cannot assign value of type 'MSCollectionViewCalendarLayout.Type' to type 'UICollectionViewLayout'"
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.collectionViewLayout = MSCollectionViewCalendarLayout
}
I understand I probably have to use self.collectionView.register(cellClass:forCellWithReuseIdentifier:)...but how?
There's some documentation titled "Usage" in the Github, but unfortunately I'm still lost as to how to use it:
There's also an Example.xcworkspace included, written in Objective-C. I've gone through most of it. They include header (.h) and implementation (.m) files for each of the elements that they use.
There's a good answer to a tangential problem here: https://stackoverflow.com/a/45540130/3979651, but this doesn't directly solve my problem. I'd like to import this Cocoapods library, instead of writing on top of Objective-C files. But I'm also not entirely sure if this is the right / best way to do it.
Summary of questions
How do I link my CollectionViewController to MSCollectionViewCalendarLayout so that it has the same UI?
How do I use self.collectionView.register(cellClass:forCellWithReuseIdentifier:) in this case?
Do I have to write a new file for each element, like in the Example? (Event cell, Day Column Header, etc.)
Or, would it be easier to just copy and paste the Example element files (.h and .m) into my app? If so, how do I build on top of those files?
What I'd like to accomplish
I would like to import MSCollectionViewLayout like a library, attach it to my own CollectionViewControllers, and build my own functionality on top of this, all using Swift.
Thank you all in advance! Hopefully I can commit the correct answers here to the repo's README.md file.
You can better use one of the below repos which are purely written in Swift and has the same UI as of MSCollectionViewLayout
1) CalendarKit
2) Calendar
Note: I personally used these libraries and these are easy to
integrate with your existing application.

Adding own Objective-C framework to Swift project

I am trying to build my own framework in Objective-C named "NEFramework". There is a class named "Helper" inside that framework. It was inherited from the NSObject. There is a function name "print" inside that class to print out the text.
And then I have created a new Swift project and imported that framework in it.I've tried to create BridgingHeader file to access that framework from my Swift project. Then I added this code in my BridgingHeader file.
#import <NEFramework/Helper.h>
After adding that line of code, I got this error in that BridgingHeader file.
'NEFramework/Helper.h' file not found
Please refer to the following image for more clarification.
Can anyone help me on this and I am stuck in this place. Thanks.
Update
I've tried to add #import <NEFramework/Helper.h> in the "NEFramework.h" file. That was ok and can build the project with no error. Please refer to the following image for that.
But after adding #import <NEFramework/NEFramework.h> and #import <NEFramework/Helper.h> in my BridgingHeader file. I got the error again.
After struggling the whole the, I found the reason why I cannot build my header file in "NEFramework.h" file.
I need to go to the Build Phases of my framework and find Headers. And then I moved some header files under the "Project" tab that I need to use in my swift project to under "Public" tab.
Please refer to the image for more clarification. Just sharing for other people like me to build a custom framework. Thanks everyone who answered my questions.

WhirlyMaply missing MaplyBridge.h

I am trying to use WhirlyMaply for a personal project.
Am trying to follow their tutorial and they mention I have to have a bridge file since the code is written in Objective-C and I am writing my project in Swift.
However there is no MaplyBridge.h file found as per their instructions ...
The following is the link http://mousebird.github.io/WhirlyGlobe/tutorial/building_from_source.html
The description on page http://mousebird.github.io/WhirlyGlobe/tutorial/building_from_source.html is bad.
You need to create MaplyBridge.h yourself. You may decide to not create it in the "BinaryDirectory/WhirlyGlobeMaplyComponent.framework/Headers/" folder but instead create it somewhere in your project. As described in the tutorial, you still need to go to Build Settings and look for “Objective-C Bridging Header” then correctly set the path to your new MaplyBridge.h".
In a later path of the tutorial, such as in http://mousebird.github.io/WhirlyGlobe/tutorial/ios/your_first_globe.html, you will add code to MaplyBridge.h. For example, to get the tutorial's swift code to compile you'll add the line "#import " to MaplyBridge.h.
See http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/ for some more background information

Make custom types appear in Xcode's documentation popup

I want to achieve the similar result for my own code:
What you are referring to is XCode's documentation viewer and Document Sets.
Check out this tutorial on working with Doxygen, a popular docgen that works well with XCode: http://developer.apple.com/library/mac/#featuredarticles/DoxygenXcode/_index.html (not for XCode 4)
If you are using XCode 4, check out these articles:
Using the Doxygen Helper in Xcode 4
Easy Doxygen code snippets for Xcode 4
DOXYGEN SHORTCUTS IN XCODE4
AppleDoc achieves the result you're looking for.

Xcode 4 'QuartzCore/CIColor.h' file not found

I'm running Xcode 4 and trying to follow the steps in Apple's Image Kit Programming Guide (which is written for Xcode 3) on how to work with an Image View and the IKImageView class. I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, but when I try to Run my application I get this error:
Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
Does anyone know what could be a reason?
Peter Hosey replied:
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
I didn't import any specific headers directly, I just choose File>Add Files to... then choose /system/Frameworks and choose two folders which contain those frameworks, after that they appeared in my project navigator view as they should, but the code wouldn't compile any more. It shows me NSColor.h file which is found in the AppKit framework, points at this line: #import and says Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found. I have no clue why it wouldn't compile. CI stands for Core Image. I'm now reading a guide on Core Image, maybe this will help. I'd like to post a screenshot but I can't (not enough rights yet).
I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, …
That's not importing; that's just adding it to the project (and hopefully the target). Importing is what you do with the #import directive.
… but when I try to Run my application I get this error: Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
The problem was that the Guide I used was written for Xcode 3 so when I tried to import/add some frameworks to my project using "File>Add files" menu as described, it did add those frameworks and I could see them in the project navigator, but something went wrong. In Xcode 4 you should use a different way to add/import Frameworks by using the Project Editor> Summary tab> Linked Frameworks and Libraries> Click "+" and then choose the Frameworks you need. That fixed the issue.