Use of undeclared identifier assert Xcode - macros

I'm using Xcode 4.5 and LLVM 4.1 to compile some code I'm working on.
The error I am getting repeatedly is:
"error: use of undeclared identifier 'assert';
The right includes are in the header (#include cassert (I have also tried #include assert.h) but no luck.
Someone else has taken my exact code and compiled it on another computer running the same setup (Mac OSX 10.8, Xcode 4.5, LLVM 4.1).

I had exactly the same errors as yours. For my case, it turns out that there was another assert.h on the include path (CMake introduced erroneous include path for gmplib. I spotted the wrong include path when make VERBOSE=1). Not sure whether it is the same case here. LLVM itself should not have any problem with such an old header file.

Are these errors happening in boost code? If so, you can turn off assertions (and get rid of your error) by including the following preprocessor definition in your build settings.
BOOST_DISABLE_ASSERTS

Ran into this today, I had Always Search User Paths turned on.

Related

Command swiftc crashes on Xcode10

I need to do some non-trivial refactoring in a mixed objc & swift project.
But after some code editing, the new Xcode10 compiler crashes every time.
I'm sure there are some errors in my refactored code, but the compiler is not able to show where. It just says :
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
So frustrating! Impossible to debug!
Of course, I updated the whole project to Swift 4.2, so I cannot roll back to Xcode 9.4 :(
Is this a bug? Is there some compilation parameters to make swiftc giving better errors?
Thanks
EDIT: just tried with Xcode 10.1 (beta), and the same problem persists.
EDIT2: after investigations, it seems the problem occurs when I import the objc generated interface header file (the one generally finishing with *-Swift.h). Still no solution.

<<error type>> Strange Error

I have encountered a situation where xcode stops auto-completing and if you try to write a variable that already been defined xcode says << error type>>.
Here is my error:
I have started to see same errors after Xcode 6.1 and iOS 8.1 update. I have found that if you delete ModuleCache file at /Users/username/Library/Developer/Xcode/DerivedData/ModuleCache path, it fixes the error temporarily. And you don't have to close Xcode or the project while doing that. After deleting the file, just wait for Xcode a little to index the project files again. After that, the problem mostly resolves for some time.
As it doesn't solve the problem permanently, you should avoid writing codes causing this according to other answers till Apple solves this.
Often this indicates that your code doesn't currently compile. Swift often has trouble computing types on code that itself isn't correct. In some cases it's a bug in the compiler. Use of AnyObject can be particularly confusing to the compiler, and should be avoided as much as possible. In this case, AnyObject is required, but you should try to get it converted to a specific type quickly. Don't return [AnyType] for instance if you can possibly help it.
But the short answer is that the Swift compiler is still evolving, and it can't always work out types in complex situations, particularly on partial or (currently) incorrect code.
Note that you're using var for a lot of things that should be let. Unless you actually need to modify the variable, you should prefer let. It helps you prevent many kinds of bugs, and can be easier on the compiler to deal with (since the variable has fewer ways it can change).
<<error type>> can result from the Swift compiler not finding the header file.
Same module:
Do you have some sort of folder structure that your source code is in? If so, try setting Scan All Source Files for Includes to YES.
This will make Xcode look through all of those folders when trying to find the Header file.
Embedded Projects, multiple modules etc:
1. Check the Search Paths
Have a look where the file in which your type is defined is stored.
In your Build Settings make sure that this location is included in the Search Paths.
If it is part of the User Header Search Paths, make sure, that Always Search User Paths is turned on.
2. Check dependencies
Have a look at superclasses etc of your type. Are they included in the Search Path as well?
Found out that the error goes away and autocomplete works again if i initialised the variable like this:
var name: String = "my name"
instead of :
var name = "my name" as String
Firstly, try CMD-SHIFT-K followed CMD-R to clean and then run the build.
If that doesn't work, close XCode, delete derived data, and reopen XCode.
I faced the same issue recently. I tried running the whole project on an emulator, it resolved all the <<error type>>
I switched my build destination from Any iOS Device (arm64) to one of the available iOS Simulators, and that fixed the issue for me.
For me, simply restarting my computer resolved this issue.

ARC conversion error after generating preview

I'm trying to convert my application to Automatic Reference Counting but when Xcode generates the preview I get this error:
/Users/alessandro/Library/Developer/Xcode/DerivedData/CroMAR-gwraklradkfapbguekcdgjignatm/Build/PrecompiledHeaders/CroMAR-Prefix-dlennltvfqdqsxbbvypkwlbqyvtn/CroMAR-Prefix.pch' file not found
I tried to clean the project, close Xcode, delete the derived data, add the .pch file to that directory but the error is still there and I cannot migrate to ARC.
Any ideas?
Thanks
Ale
Is your .pch file in the correct place as specified in your build settings?
I think you have left any reference in code might be any variable which is pointing to the file and he is not getting it. just check it.
Hi solved the problem in that way. I noticed that the aforementioned problem was linked to the kind of problem reported in this discussion Convert to ARC - LLVM compiler 3.0 Error thereby to solve the problem is to select the iOS simulator as target during the migration to ARC.

'__strong' only applies to objective-c object or block pointer types; type here is XXX" warning

i get many warnings of type:
'__strong' only applies to objective-c object or block pointer types; type here is...
the warnings are pointing to framework headers. e.g NSNotification, NSURL, NSIndexset etc..
what are they and how can i repair it?
note 1: i use ARC
note 2: the app seems to work
edit 1: the warnings seems to originate from my pch file. which is:
//
// Prefix header for all source files of the 'myapp' target in the 'myapp' project
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
edit 2:
example of warning:
warning in NSString.h point to:
/* Methods to convert NSString to a NULL-terminated cString using the specified encoding. Note, these are the "new" cString methods, and are not deprecated like the older cString methods which do not take encoding arguments.
*/
- (__strong const char *)cStringUsingEncoding:(NSStringEncoding)encoding; //"Autoreleased"; NULL return if encoding conversion not possible; for performance reasons, lifetime of this should not be considered longer than the lifetime of the receiving string (if the receiver string is freed, this might go invalid then, before the end of the autorelease scope)
Amir's answer did not work for me, but it led me to a similar solution: make sure you also don't have a Frameworks path in your FRAMEWORK_SEARCH_PATHS in project settings or target settings. Mine had an entry that looked like this:
$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
The symptom was that if I command-clicked Foundation/Foundation.h in my prefix.ch and then right clicked in the page->Show in Finder, it was in iPhoneOS.platform. But doing the same with Availability.h took me to iPhoneSimulator.platform.
So having some files including from each platform seems to have caused the __strong warnings and also some link errors where it said missing architecture i386, so I lost the ability to run inside iOS Simulator.
This bug took me 2 days to solve because that path had been in my target settings for months, but wasn't causing problems. Something about going to Xcode 6 revealed it, but not immediately, it just occurred spontaneously early this week when I was upgrading Google AdMob SDK and perhaps triggered a cache rebuild.
The particularly insidious thing about it was that trying to compile backups of my project also failed with the same error.
Let that sink in for a moment, and imagine the sense of impending doom.
I began to suspect hardware failures or a virus at that point, but luckily..
The bug was at the Xcode level, not the project level. Which leads me to believe it has something to do with SHARED_PRECOMPS_DIR, CACHE_ROOT or possibly /var/folders but by then I had upgraded to Yosemite out of sheer desperation and could not diff my hard drive against my Time Machine backup, which had Mavericks. In hindsight, that's where I blew it. That meant that I had to try a dozen other potential solutions involving PCH and other caches, none of which worked. Neither did deleting the project's derived data directories in:
~/Library/Developer/Xcode/DerivedData
(Which I had done based on this answer)
See also:
Can't Build in Xcode 6 - ARC Issues in Apple Frameworks
and:
Build Error - missing required architecture i386 in file
Specifically:
Sean Roehnelt's answer
it seems i've solved it.
for some reason i had a "Framework" folder with headers in my project local folder. removing that folder and the warnings are gone. i don't know how and why that folder was created. (i did not created it).
This is a wild guess : is your project using gcc ? If it is, try switching to clang

SQlite 3 error when compiling in iOS 5

I am experiencing the following error while compiling my code with iOS5.With previous version it seems fine
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/include/sqlite3.h:230:24: error: redefinition of 'sqlite3' as different kind of symbol [3]
any suggestions
I have the same problem. I discovered that when I change the "Compiler for C/C++/Objective-C" from "Apple LLVM compiler 3.0" back to "LLVM GCC 4.2" the error disappears. (but that's not the preferred iOS 5 setting)
Also it seems that sqlite3 is now included by default in iOS 5.0, which might cause the redefinition error when you included the sqlite3 as a framework in your project. But even when I removed the framework from my project, the error kept appearing (but only 2 instead of 4 this time).
I just had the same problem. My issue was that I had used a forward declaration in my header file. This conflicted with a line of code in sqlite3.h:
typedef struct sqlite3 sqlite3;
Rather than using forward declaration, simply use #import <sqlite3> in the header file to avoid this issue.
(I realize that this may not have been the problem in your case, Qamar, but I'm posting it for those future coders who encounter this bug)