xcode error Lexical or Preprocessor issue - xcode

I am trying to follow this tutorial and am encountering this error. If somebody could help me it would be much, much appreciated.
Thanks.

That header is probably not in your project navigator in xcode, You need to find the file in finder and drag it into xcode and place it in your project navigator

A few options I can suggest:
Add the framework part of the path #import <SMTPSend/NSData+Base64Additions> (also if this is a framework, you should probably use these enclosures: <.../file.h> instead of quotes)
Add the frameworks path to your build settings ( Framework Search Paths )
Make sure the framework is in the Link Binary With Libraries section
Remove the framework reference from the project organizer pane (cmd+1), then drag it back in (refreshes the path for the file)
Clean/Clean Build Folder/Rebuild
Hope one of those helps!

Related

Can't get real path for source - Xcode, SFML, C++

I am new to SFML, and followed SFML & Xcode tutorials for SFML 2.5 to try to get a basic program build and run.
After copying the content of Frameworks to /Library/Frameworks and content of extlibs to /Library/Frameworks, and the Xcode templates, I was able to create a sample app via Xcode using the SFML App template.
When I tried to build it, it failed with the following error:
Any idea what I did wrong?
Help is much appreciated!
Seems like a post build script is pointing to incorrect paths. Here's how to fix this.
In Xcode click on your project's name in the root of the project navigator (where you see the source files) so you can see its configuration.
There should be a header called "build phases". Click on that.
Expand the item called "Run Script".
If you followed the tutorials from SFML to setup your environment, edit the area under the comment "Settings" at the top of the script to look like this.
#These 3 are probably pointing to a directory under
#/Users/SFML right now which is not on our machines
SFML_DEPENDENCIES_INSTALL_PREFIX="/Library/Frameworks"
CMAKE_INSTALL_FRAMEWORK_PREFIX="/Library/Frameworks"
CMAKE_INSTALL_LIB_PREFIX="/usr/local/lib"
#This Doesn't Change
FRAMEWORKS_FULL_PATH="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/"

Library Not Found after Restarting Xcode

I am using latest Xcode 5.1.1.
When I make a new project and import chartboost for example or revmob everything works fine. But when I close Xcode and re-open it this is what I get:
As far as I understand there is an issue with the library search paths.
I have tried to delete everything from library search paths -> Not working
Delete the derived data from Organizer -> Not Working
When I delete the libraries and re-import it works great until I restart again Xcode.
I appreciate your help.
Better screenshot:
For those who are interested, it turned out that the error comes when you drag and drop a folder in the project that contains a subfolder with a space in its name. Then XCode Library Search Paths are not correct, because the path to a framework is separated in 2 lines. For example if you have a folder "ParentFolder/Child Folder/Framework1" then the library search path will look like this:
$(SRCROOT)/ParentFolder/Child
Folder/Framework1
instead of this:
$(SRCROOT)/ParentFolder/Child\ Folder/Framework1
It is a very annoying bug in XCode, which cost us several hours to fix it. We hope this solution helps someone who is frustrated with importing a framework.

Include Headers from added frameworks on Xcode

I want to work with some frameworks like glew and cg so i manually added
the needed frameworks to my project by right clicking the project -> Add files to ...
and choosing the correct framework. The problem is, when i try to include the header files,
Xcode cant find any of them. I hope this picture will help to understand:
And:
The error given is for the glew framework, but it also happens on Cg.
As you can see on the left, The needed frameworks were added.
Any idea on how i can include these headers?
After trying to add the header files manually i got an architecture error:
I dont know if this is how it should look like.
Thanks!
Before starting, remove the framework and all files you have added while trying to make it work.
Then, you have to add the frameworks in the Build Phases of your target. Then go into Link Binary With Libraries and select your framework from there.
This should do it. Your headers should be available as auto-completion after each #import directive.
If it does not work (it sometimes happens), there are additional steps I can provide to you.
Additional steps:
Go to your project settings, in the build settings:
Complete the Framework Search Paths with the path of your framework
Do the same with User Header Search Path
Then, it should work. If it does not, you will need to add the full path of your header in the #import directive. Example:
#import "/path/to/my/header.h"
Apple's documentation available here states:
In the project navigator, select
your project
Select your target
Select the 'Build Phases' tab
Open 'Link Binaries With Libraries'
expander
Click the '+' button
Select your framework
(optional) Drag and drop the added
framework to the 'Frameworks' group
In my case I have added Framework Search Paths for Target, but it should be added to Project
Also Always Search Users Path should be yes
For those whose autocomplete fails after adding framework.
I used to add frameworks, by going to Build Phases and taking the Link Binary with Libraries option. Now in XCode 6.1, though project was building fine, autocomplete in XCode was not working.
So what needs to be done is:
Remove the already added framework from Project Navigator and also from Link Binary with Libraries.
Add framework to project by simply File -> Add Files to option in XCode.
And auto complete will start working.
In my case, the external framework had been downloaded with Windows and added to the project. Then it was transferred to OSX, where the Xcode project was built and the external framework didn't load properly. I guess it is because Windows changes the framework folder to be a regular folder, which OSX then has trouble with.
Solution for me was to simply download the framework with OSX and drag it into the framework folder in the XCode project.
In my case I had to update a framework version, so I just replaced the .framework in the filesystem and then I got the error you've mentioned in the question.
Removing the framework and adding it back again, playing with the search paths and all the other suggestions didn't help.
Eventually, cleaning the build folder did the trick:
Select "Product" from the xcode menu, hold the option key and click on: "Clean Build Folder".
After that I built and ran the project successfully.

How to make Xcode find file FacebookSDK.h?

It says "FacebookSDK/FacebookSDK.h file not found"
Yet I can jump-to-definition on the #import and it takes me to the file.
And once I added the #import it now knows what FBFriendPickerDelegate is and it now doesn't have an error on that line.
I have the facebookSDK.framework in my project and in the right folder. It's SDK 3.1.
I tried adding search paths to /FacebookSDK and /FacebookSDK.framework and /FacebookSDK/Versions/A/Headers etc. I also tried #import "FacebookSDK.framework/Versions/A/Headers/FacebookSDK.h" and it still says it can't find it. I also tried clean and restarting. I have the latest version of Xcode.
//
// FacebookView.h
//
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#interface FacebookView : UIViewController <FBFriendPickerDelegate>
{
}
First, you have to remove your FacebookSDK.framework from your Project. Then start over again with these 5 steps. DO NOT re-link the framework.
Go to Build Phases in your Project Target.
In Link Binary With Libraries, click the "+" button.
Click on "Add Other..." button
Browse your FacebookSDK folder. Generally in ~/Documents/FacebookSDK/
Clik on (select) "facebookSDK.framework" and then OPEN.
That's it.
No need to remove anything.
In your project go to: "Build Settings”, then “Search Paths". Look for "Frameworks Search Paths". You probably have something fixed like this:
Frameworks Search Paths: /Users/john/Documents/exampleappxyz
Change it to:
Frameworks search paths: $(PROJECT_DIR)
Voila!.
I tried this but it did not work for me. I had to go into the Build Settings for the project and manually fix the FacebookSDK Framework Search Paths to find the FacebookSDK.
Ok guys, I think i got the answer. Follow the steps given below.
Copy your framework into your project.
Make sure it is under some directory. e.g. $(PROJECT_DIR)/project_name/Resources/Frameworks
Click on the target.
Goto Build Phases→Link binary with Libraries
Add the custom framework by clicking "Add Other"
Verify in the project navigator that the framework exists only once.
Now goto Build Settings→Search Paths→Framework Search Path and make sure that it has the following two things.
(a) $(inherited)
(b) $(PROJECT_DIR)/project_name/Resources/Frameworks.
Not to remind the framework exists inside the Frameworks folder
Make sure that there is nothing in the library search path.
Now click on the project (above target)→Build settings and repeat steps 7 and 8.
Now clean the project and build the project.
Hope it works.
Please remember not to keep any folder names with spaces. If you have kept them, make sure that you provide the correct escape characters.
How to remove facebook sdk links:
For those who like myself improperly added the facebook sdk. to remove the facebook SDK from your project,
check the link inside your frameworks folder, delete any facebook sdk link in there
go into Build Phases -> Link Binary With Libraries and delete any facebook sdk in there
Right click on the frameworks folder and select "show in finder" and delete any facebook sdk in there
Now follow "Fede Cugliandolo"'s steps and re add the facebook sdk
I got this problem today.
It turns out I need to have my Framework search path in all three places:
1) Project Build Settings
2) App Target Build Settings
3) UnitTests Target Build Settings
My search path is:
/Users/myusername/Documents/FacebookSDK
After ensure that, the error disappeared for me.
I use xcode 5 and when add sdk it not correct write self address in "project.pbxproj".
Instead local address for sdk it save global address.
I open "project.pbxproj" and finde the places of it and leave address only for sdk in project.
<project name>/src/external/facebook
<project name>/src/external/testflight
to edit the entry was as follows
/Users/<user Name>/myProjects/.../ios/<project name>/src/external/facebook
You have to change the property "Framework search path" in your build settings, and specify where the file FacebookSDK.framework is located (you can then use the SRCROOT variable to point to the root of your project directory, and thus, avoid using absolute paths ;)) e.g. :
$(SRCROOT)/SampleProject/src/Utils/Facebook/
this is normally done automatically by Xcode when you import a third part framework, but it messes sometimes, (eg: when your modify your project directory tree...)
Hope that helps...
besides adding the search path I also had to set the paths to recursive and remove "*.framework" from the "Sub Directories to Exclude" option for this to work.
This happens if you have imported the facebookSDK twice and after having deleting some files.
For example, I imported the facebookSDK in $project/framework but I deleted it for some reasons. Then I imported it via ~/Documents/FacebookSDK but Xcode kept the old folder and search in it by default.
I have to remove all references and files of the old import to resolve my issue.
I ended up checking my project directory, remove any old references to the framework file. Then, remove it from Build Phases/Search paths. Also remove the linked Framework. Restart Xcode, and do the process over again: drag Framework to Frameworks, don't copy in. Check the Build Phases/Search paths. include "#import ". Finally worked. Whew.
Follow the instruction
At step 4 Configure your Xcode Project
I think you missing something. Delete the Facebook.sdk in your project and try again.
I had the same issue when I updated XCode, but in my case I didn't want to make any manual changes to the project settings as I use CMake to create it. You can find the way I fixed it here: https://stackoverflow.com/a/25564152/525873
it is simple, you have to remove your FacebookSDK.framework from your Project.
Go to Build Phases in your Project Target.
In Link Binary With Libraries, click the "+" button.
Click on "Add Other..." button
Browse your FacebookSDK folder.
Generally in ~/mohit/Documents/FacebookSDK/
Clik on (select) "facebookSDK.framework" and then OPEN.
Now copy this Target settings > framework search path into Project setting > framework search path.
None of all answers above worked for me.
What finally did the trick for me was to change the structure of the plugin folder:
Create folder: com.phonegap.plugins.facebookconnect/FacebookSDK
Copy all content from:
com.phonegap.plugins.facebookconnect/FacebookSDK.framework/Headers
to com.phonegap.plugins.facebookconnect/FacebookSDK
Copy com.phonegap.plugins.facebookconnect/Facebook.framework
to com.phonegap.plugins.facebookconnect/FacebookSDK
And finally, change
#import <FacebookSDK/FacebookSDK.h>
to
#import "FacebookSDK/FacebookSDK.h"
The only solution I found was:
Remove the phonegap plugin: ionic plugin rm phonegap-facebook-plugin
Clone the next plugin git clone: https://github.com/jeduan/cordova-plugin-facebook4.git
Add the plugin manually: cordova -d plugin add PATH/cordova-plugin-facebook4 --variable APP_ID="*****" --variable APP_NAME="*****"
Before this a tried to re add FacebookSDK.framework and installed the phonegap plugin facebook through a locally cloned, but the error continues.
Just follow these steps:
Open Xcode's Build Settings tab in your project.
Add ~/Documents/FacebookSDK to the project's Framework Search Paths setting.

Xcode: code loses syntax coloring

I find that in various situations Objective-C code in Xcode 3.1 (Leopard) can fail to get appropriate syntax coloring after typing or lose coloring that it had.
This isn't just a "refresh" issue with new custom symbols -- but affects Cocoa framework symbols as well.
Sometimes CMD-a to select all text on the code page will make the coloring (re)appear, sometimes double-clicking on a line to select it will work, sometimes I have to add/delete a space in a symbol to get that symbol to (re)color. Rebuilding, or closing/reopening the project may or may not work.
Is this a known issue with Xcode? For something so annoying to me, I'm not finding the plentiful discussions of it on SO and elsewhere I'd expect.
And is there any command to force global syntax recoloring?
1.) Go to Project --> Build Settings --> Header Search Paths
2.) Add "$(SRCROOT)/**"
3.) Close and reload the project
4.) Go to Xcode --> Window --> Organizer --> Projects --> $YourProject --> Delete Derived Data
5.) Wait a moment until XCode rebuild all indicies
To get more information activate verbose logging:
1.) Increase Xcode log level in Terminal app:
defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3
2.) Open Console app. Search for "xcode"
3.) I saw "file not found" errors for header files mentioned in the pch file (therefore the fix above)
I had the same issue with a project that was fine in Xcode 3 and for which the syntax highlighting and code completion has broken in Xcode 4. It took me the better half of the day to figure it out but I found that the following steps will reproduce / fix the issue 100% for me.
After trying all the aforementioned solutions to no avail, I tried creating the project from scratch and reimporting every file and folder painstakingly. Every time I imported a couple of files I checked and syntax highlighting still worked. Even after the last few of them it still did. Then I hit build which failed because I forgot to include a couple of common header files in the project .pch file that were there in the old project. And that was when CodeSense broke again.
After further investigation we found that if you import a header file that in turn imports the same framework header file than the .pch already does, then CodeSense will break. The same setup did not cause any issues in Xcode 3.
Example:
project.pch
#import <Foundation/Foundation.h>
#import "projectConfig.h"
projectConfig.h
#import <Foundation/Foundation.h>
#import "one.h"
#import "two.h"
So by removing the wholly unnecessary
#import <Foundation/Foundation.h>
directive from the 'projectConfig.h' you can fix the highlighting and code completion will come back for you as well. If your issue is the same as mine that is.
Just select the file who lost the syntax coloring , press Editor > Syntax Coloring > ( choose your language (Objective c++ for ex) instead of 'Default'
I have found the best way to regain syntax coloring is just to quit Xcode and re-launch it. I couldn't tell you why, but that works every time.
I find that the following will often do the trick…
"Reselect" both "Base SDK" - and "Architecture" - in "Build Settings".
(CLick on blue project icon in top left, while in "Browser mode", aka ⌘1, then click project settings and mess with the stuff there.
Make sure they all line up / it doesn't hurt to do a little toggly-wogglying up in there, while you're in there… ya know just mix it up a bit. You'll notice xCode has a teensy-tiny mini-stroke - every time you switch between 64 and 32 bit… This is usually when I know if code highlighting is dead for the night, or if I'm good to go.
Often, I will have a project that gets highlighted instantly in 32 bit mode, and just sits there in 64… Who knows.. Ahh, Xcode, you wacky botch.
Select your Project -> Build Settings tab -> Apple LLVM Language 5.0 -> Precompile Prefix Header to YES. NSLog was not highlighting. Currently running Xcode 5.0.1 Hope it helps =) Thanks #rebelzach
I can confirm a 100% fix for this problem, based on a question I had asked (and actually answered), as pictured below. One thing i will add is that sometimes it is "errant whitespace" that can also contribute to the loss of highlighting. Either clean it up yourself, or use the Goggle Toolbox for Mac Xcode 4 plugin, which adds an entry in the XCode Edit menu called Clean Up Whitespace.
This appears to be a similar error from this question
I was able to correct this issue by setting Precompile Prefix Header to No in the build settings.
I recently had a similar issue, all coloring and autocomplete stopped working for built-in frameworks, my own classes still worked. Someone recommended to me that I turn off "Run Static Analyzer" in the build settings. It's weird, but it worked.
For me it was that I renamed my project, and Tests target was still pointing to the old pch location, but my App target was pointing to the new one.
If your app delegate still has code sense, this might be the case for you too. Go into project, select the 'Tests' target search 'prefix' and set it to the equivalent value in the 'app' target.
Open the project settings (Project > Edit Project Settings menu) and then click the Rebuild Code Sense Index button in the General tab. This will recreate the index that Xcode uses for syntax coloring.
This process can take a while for larger projects, so you can check the progress in the Activity window (Window > Activity menu).
Moreover, in XCode4 there is no button to rebuild the code sense index.
I had the same problem and solved this by updating my build settings to use the system default compiler, LLVM GCC 4.2.
It seems there are multiple factors.
I experience this issue as well, and have tried the solutions either "rebuilding the index", "relaunch XCode", "change the compiler setting to LLVM GCC 4.2". Those didn't help me out.
So I tried to add the following code right away along with the fresh creation of header file.
#include "header.h"
using namespace cocos2d
Then, the code added earlier in header file is colorized, and it can recognize classes and stuff.
I've used cocos2d-x, so my syntax is based on c++. I don't test it with Objective-c yet though.
For someone still have don't know why. Let open with XCode 8.2, it should work

Resources