I have been at this for over an hour. I am desperate.
I am trying to implement this here https://github.com/enisgayretli/EGFloatingTextField and this is my previous question Best way to achieve UILabel animation effect in Swift?
For the text field to work I need to import Purelayout. I'm working in swift and this is where things don't work- I've tried all the methods on the purelayout github but can't for the life of me import purelayout.
No matter what I do I get no such module purelayout. I am trying to do the manual installation and I have 1. Dragged and copied the purelayout source files into my project 2. Written the import Purelayout.h line in my bridging header
Where am I going wrong here? Am I configuring my header wrong? When I drag the files in it wants to configure a new Bridger and creates a blank file.. Could this be the problem?
My project will not compile. I can't understand this.
Related
I have just installed Xcode 11 and when I try to create new fresh project with the SwiftUI check mark selected it returns an error.
Not able to build and run successfully.
File 'ContentView.swift' is part of module 'SwiftUI'; ignoring import
ContentView.swift
Use of undeclared type 'View'
SceneDelegate.swift
Use of unresolved identifier 'UIHostingController'
I have tried removing all derived data and also set command-line tools to 11
Your project is named SwiftUI - please try using a different name.
Detailed Answer
Each project you create has a module with the same name as the project. So there are two SwifUI modules here:
The actual SwiftUI
The project itself
Xcode always takes the nearest definition as the default. So your SwiftUI is closer than the system's SwiftUI. But you are in the project's module already! So Xcode ignores the import.
A very common mistake is to name the project same as one of the using frameworks! (e.g. CoreData, SwiftUI, SceneKit, Metal)
Solution
As Matteo mentioned in his answer, Don't name your project same with another module. Change it to anything else.
Note that It could appear as an error too. For example, if you name your project CoreData and using SwiftUI, the error appears as Circular dependency error:
Circular dependency between modules 'CoreData' and 'SwiftUI'
Because Xcode gets confused about modules and can not detect what the real issue is.
How can we access our module's classes instead of the system's module?
Imagine you have a class named Section in a custom framework called MyProject and you imported it alongside the SwiftUI.
import SwiftUI
import MyProject
Section // <- This could be either SwiftUI's section or MyProject's Section
To make it clear for the compiler (and anyone else), you should call the module before the class name:
SwiftUI.Section // <- This returns the SwiftUI's Section
MyProject.Section // <- This returns the MyProject's Section
Try with different project name. With SwiftUI, it will always show compilation error. Just change the name and enjoy coding with SwiftUI
You can't write to self.state in the subclass unless you import UIGestureRecognizerSubclass.h as indicated here.
In a Swift environment, I'm confused how I'd go about importing this. I tried import UIGestureRecognizerSubclass.h, and without the .h, but I still can't write to self.state.
How would I accomplish this?
The Swift equivalent is simply:
import UIKit.UIGestureRecognizerSubclass
That imports the appropriate header.
You need to have or create a -Bridging-Header.h file to import objc headers such as the one you want. The import line looks like this:
#import <UIKit/UIGestureRecognizerSubclass.h>
If you don't already have a bridge header file in your app, the easiest way to get one is to add an objc class to your project, and xcode will ask if you want one, then creates the file and ties it into the settings for you. You can then delete the objc class.
Everything in that header file is automatically made available to your Swift code, no need to add any import lines in your swift files.
Can anyone tell me how can I use swift file into my objective-C project?
I have a swift file which inherits from UIViewController instead of NSObject. I am trying to use the swift file but I am not able to figure out how.
When I add my swift file into objective-C project, it usually asks to create a bridging header.
In that header file I am importing my swift file as -
#import "SlideController.swift"
and my bridging file name is objcToSwift-Bridging-Header.h
I read many answers which asks to import file
#import "MyProductModuleName-Swift.h"
into the .m file, but I can't find any such file in my project.
I also changed the defines module = YES as shown in another answer.
But still I am not able to access swift file.
What am I missing? Please tell me the right steps to figure it out.
After you created Bridging header.
Go to Build Setting =>Search for "Objective-C Bridging Header"
Just below you will find ""Objective-C Generated Interface Header Name" file
and import That file in your view controller.
ex.In my case: "Dauble-Swift.h"
So I'm pretty new to programming, so I downloaded Xcode 4.2 and got to work. I watched many online tutorials and the main problem I was having was that all the tutorials were for Xcode 4 and not 4.2, meaning when you chose empty application setting, it was missing the .xib file. So I found a tutorial on how to create a .xib file. I got through it all except for one step, and that was to drag the from the window outlet of the xAppdelegate to the window. I've tried this over and over, but it doesn't work.
Here is the tutorial if anyone needs to see it http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
Please someone help me!
You need to hold Ctrl while dragging, else it will not work.
Guide.
As you Control-drag from an object to your source code, Interface Builder indicates where a new binding is valid. After you’ve made the connection, Xcode displays a dialog you use to configure the binding. You can use the dialog to configure all aspects of the binding.
Interface Builder uses the Xcode index to determine which key paths are valid, and can also discover what controller it should connect through—you can therefore connect from a user interface element such as a table column to a property in a model class header.
Check out the video here.
You should choose a SingleViewBased Application instead of Empty Application then study all files that how they connect with each other. You can choose Master Application also. They will help you.
see this Hello world Tutorial click me.
And Youtube is the best way to learning for beginners. Search tutorial video because action teach more than the text.
excuse me to create again this question, but I have another problem. I'm trying to integrate the aurioTouch Apple sample in my app. I have put all the code that was in aurioTouchAppDelegate in my app delegate file. The code runs, but some methods, like methods in EAGView file doesn't run, I don't know whym they are not called.
Some help or hints are welcome...
Have you integrate all the setting from Project's Build Settings. Actually I had the same issue but then I compare all the settings from Build Settings and found that some of the Linker flags were creating the problem and then was able to solve the problem. So whenever you have such problems try to go to Project's Build setting and compare all the keys. Mostly the Linker flags creates the problem in such cases.... hope this help to others also...
EDIT
After referring to your project. Notice that you have overloaded the property view of ViewController with your custom View EAGLView. You have not separated customView and ViewController's view.
Also, one major thing is you have to Initialize your EAGLView and add it to your ViewController's view. and rest of the things will go on in EAGLView.