This question already has an answer here:
What is other option available in swift instead of refactoring and renaming class or attribute name?
(1 answer)
Closed 6 years ago.
I am working on swift project.After 1 month I need to refactor the code as we have done in objective c. I need to change some class names, properties and method names. But problem is that when I go to refactor the code but It showing me an error.
Error is "Xcode can only refactor C and Objective-C code."
Is there any way to refactor the code because there are 50+files to change the code.
Thanks in advance
Unfortunately, no. We're stuck with "Find>Find & Replace in Project".
Related
This question already has answers here:
How do I call Objective-C code from Swift?
(17 answers)
Closed 4 years ago.
I am working on an application which is built in objective C.
I have to implement UIActivityController which is easy to implement using swift in any application but since I am not familiar with Objective- C even by a %, can I use swift code to implement the UIActivityController in a button?
If so, how?
Yes you can create Swift file, with your Swift implementation in the Objective-C project.
You just have to add
#import "YourProjectName-Swift.h"
into the objc file where you wanna call the swift code and execute it.
More info in article here for example https://medium.com/ios-os-x-development/swift-and-objective-c-interoperability-2add8e6d6887
This question already has answers here:
Xcode 8 Objective-C category warning
(8 answers)
Closed 3 years ago.
After migrating to Swift 3 compiler gives me a warning:
Some object files have incompatible Objective-C category definitions.
Some category metadata may be lost. All files containing Objective-C
categories should be built using the same compiler.
Does anyone know how can I find objects or files defined as some object files from the warning?
I have zillions of extensions and going through all of them would be a madness. Is there an easier way?
I know there are similar questions but no one asks how to find the files/objects responsible for the warning.
If you click on the warning, you will see the area in the build log where probably some library will be named.
This question already has answers here:
How to use Namespaces in Swift?
(9 answers)
Closed 5 years ago.
Hy guys,
Do you know how can I create a module(namespace) in swift ? For example in C# we have namespace keyword, but in Objective-C there is no such thing, there we named our classes with the prefix of the folder they were located in. Shall I use the same approach in swift or do you know some other way to achieve namespacing in swift.
Thank you!
You can achieve it by using Frameworks which is newly introduced in iOS 8 for namespace-ing, if I am not mistaken.
I think I will either rename my classes to have a prefix of two capital letters like NSString, UIView and other classes from Objective-C do or I will wrap them in structs.
Thank you for your comments.
This question already has answers here:
Xcode 6 Bug: Unknown class in Interface Builder file
(52 answers)
Closed 5 years ago.
I am programming the ToDoList Objective-C Tutorial from Apple, but try to do it in Swift.
(Tutorial)
Now that I am ready, when I run the Application, I get the error:
Unknown class AddToDoItemViewController in Interface Builder file in Swift.
In this thread, somebody solved a, as I think similar Problem with [MyClass class] in Objective-C. Is there a similar way to do this in Swift?
I found that on a lot of my Swift Controllers there's a new Module Option which was set to None
So to fix it just set the Class to a different one and then set it back. That gave me this
A similar line in swift would be AddToDoItemViewController.self. All that really matters is you call your view controller from swift code so the linker knows to include that file.
I ran into this situation when I made a mistake and used a different name in the #OBJC statement than my declared class name.
This question already has answers here:
How to build a framework or library for other developers, the secure way? [closed]
(3 answers)
Closed 8 years ago.
I have a developed a generic class and I want to give it to one of my friend.
How can I hide the code so that he should not view the logic in that. Can I do something like apple does by giving us only the .h files.
Please help me in achieving this. Thanks.
you need to create your own static library i.e. .a file in xcode. And it is not very tough, you can do this in just in few mins.
Read this tutorial and try in out:
How to make Universal Static library (.a file) in iOs using xCode
You will have to make your own library (framework) for this.
You can search about it there are many tutorials about that. One of them is How to build a framework or library for other developers, the secure way?
Edit: Great Tutorial
Creating Static Libraries For iOS