I am facing a strange error when writing the simplest of swift programs in Xcode 12.0.1.
It says that it can't find T1 in scope when it is very much in scope. I feel that it must be trivial to solve this problem, and I tried ⌘ + ⇧ + K and closed Xcode and reopened, but the problem persists. Anyone knows how this can be solved?
Sometimes there are ghost errors that seem to not go away, even when Xcode is closed and reopened, but are fixed by either changing the code then changing it back, or clicking build anyway and the build succeeds.
Otherwise, the color highlighting of T1 in the return doesn't match in the variable declaration. That suggests name clashing. Are there any types or global variables called T1, even if there's nothing else in your code maybe it's a built-in type or similar? Try naming the variable differently.
I got the same error and was searching around, but couldn't find an answer to it so I'll share it here for others to find as well. For my part, I was creating a view in a package and was referencing that view from an app.
I got the Cannot find [Type] in scope and turns out I forgot to put the public attribute on the view struct.
Related
This question already has answers here:
How can I call a function from a method of the same name?
(3 answers)
Closed 12 months ago.
The simple actual question is
How to access GLOBAL scope in Dart?
Below is just the answer why I'm looking for it.
I have a problem which requires me to learn about Dart's scope resolution from here but unfortunately I can't find the solution for my problem, not even from Google or here, which was surprising me to have to open this question.
Dart allows user to exclude the this. on member variable access within class's scope so if two potentially conflicted variables need to share the same name, they need to be differentiated with scope operator and reference.
I need to define a class with member variable print where there is also global function print being called somewhere within the class. Of course print() => print(...) will returns error so I'm expecting something as simple as print() => global.print(..) but neither that is working.
I know there's workaround to solve it but please I need a straightforward one if any. Thank you.
you could add this line at the top of your file:
import 'dart:core' as core;
Then you would be able to refer to print as core.print(...);
The problem is that now you would have to use core. for every primitives like int, example:
core.int variable = 1;
I think this is not worth it and it's better to use another name for your print method.
I'm new to MPS, so this may be a stupid question, but I can't find a solution anywhere.
I'm defining two DSLs, where the first one is going to depend on the second.
I've defined a portion of the first language and so far so good.
I have a bunch of Concepts going, some Editors, Constraints etc.
I've created a model with an example node where I view what I've made.
Now I'm working on the second language and I went about exactly the same way as with the first.
I created a Concept that can be root. It's called 'Module'.
Then I defined an Interface Concept, called 'IModuleContent' and gave it to 'Module' as a child, calling it 'content' and setting the cardinality to [0..n].
Then I defined another Concept called 'Interface' that inherits from 'IModuleContent'.
I gave the two Concepts Editors, which are basically just curly brackets for now.
In my example model I create a new node from my new language. It gives me my root, a 'Module'. Because it's a named concept I give it a name. Then, inside the module's curly brackets I declare a new 'Interface'.
Together, it looks like this:
Module printeri {
Interface printer {
}
}
This all pretty much works, except that after giving 'Module' an instance of 'Interface' (so 'printer') as a variable, it gets underlined in red and the error reads:
"Child in the role Module.content does not belong to the concept Module"
However, I'm pretty sure that it does. All the concepts are in the structure of the new language and I believe everything is inherited the right way. I did practically the same thing in my first language and that works fine.
What's going on here?
EDIT: should have specified that I'm on version 2020.3
you can goto "File -> Invalidate Caches and Restart" if you think MPS behaves strange.
For me it looks like you did some changes, e.g. creating the "Module" node in youre examples and then change the structure like removing "content"-child and re-adding it. The problem here is that MPS does not resolves id-based and not name-based. By removing and re-adding a member definition you change the id. MPS is able to handle such changes in to a certain degree, e.g. by just pressing "F5" to refresh the editor. You can also click on the node and open the intentions menu via "ALT+ENTER" investigate the options suggested there.
Hope this background knowledge helps you a little bit with future problems :)
Best regards
Heiko
there seems to be a bug in the comment feature here, hi removes the "Hi Noah"
Okay, so it seems that the error has magically disappeared overnight.
Yesterday I closed MPS for the day and opened it again this morning.
Code completion wasn't working. Very annoying. So I restarted MPS.
On the second try code completion was working and the error from before was gone.
It seems like MPS may be a little unstable.
So yeah, for anyone running into the same issue:
Try the good old 'turn it off and on again' method.
As I'm not allowed to add an answer to several duplicated questions, I will ask this question and give also one answer ;-)
The undefined symbol was a call to a self written swift function. This function sits in an swift file with only "global" functions (no class in that file). The function is called from several classes and all was good until this morning.
Suddenly I got this link-error message when producing the release product. The funny think was, it was only for ONE function call. All other calls got no errors, and when I commented out this particular function call, all was good. And this function is a very easy one. There is only one function parameter (Int64) and it returns a CLocationCoordinate2D.
I checked all possible solutions found here and at other places in the web. I even copied the function 1:1 as a local function inside the class.. nothing worked.
The final solution was the compiler flag for optimization. For release builds the flag in "Swift Compiler - Code Generation" is set to "Fast, Whole Module Optimization".
After changing that to "Fast, Single Module Optimization", everything worked ...
I think it is simply a bug in the optimization engine.
.. maybe that will help others in similar situations.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am building a example project with sections using a TableView with this video:
https://www.youtube.com/watch?v=zFMSovtqqUc
When this boy explain exactly at 2 minutes and 55 seconds a list of the variables created in the struct should appear in the list, but it does not.
Can someone help me to understand what I am doing wrong?
Attached a print screen of my Xcode displaying the values where the list of value explained in the video should appear.
I am just a beginner following some video to learn to code.
Thank you very much for your time, I really appreciate it!
The same it's happening to me, look
If for you it's a big problem you can put 2 parenthesis around the value you are creating
This seems to fix the problem.
Conventions
Sorry but I could not avoid this
Objects is a wrong name for a struct (intact struct values are NOT objects)
Implicit unwrapped optionals (like the property of the struct into the example) are dangerous
Variable names should begin with a lowercase char
In Swift we don't put the name of the type of the variable inside the name of the variable.
The variables aren't recognised when there is a ] automatically provided when you type in [ like this:
If you delete the ] as soon as it appears when you type in [, the error is fixed, like so:
I just installed the cocos2d templates in Xcode 4. When I create a new project from the template and run it, it shows around 30 compiler errors. Even without making any changes to the template. Do you have any idea what is wrong?
Please add some more information about errors, but it looks like you forgot to add to your project OpenGLES and QuartzCore frameworks. I could be wrong...
I just spent 10 or 15 minutes plus fixing a bunch of errors in this situation, so i will guess: moving to Xcode 4.X caused many problems for cocos2d projects (including Kobold2D) and most of them require putting "(unsigned int)" in front of an argument in a list of arguments to a 'string with format' type operation creating mostly debug type output. usually the argument in question is "self", but sometimes just other "types" that resolve to (or can) unsigned ints. in a few cases I had no arguments but a reference to the error string to %#; these required adding a ", self" between the end of string and the close paren. in about 5 to 10% of cases, "fixits" were provided to automate the correction (usually changing the format character to match the argument). Hope this helps! Happy to provide examples if this actually helps anyone.