(Posting for reference purpose only. So I will answer right away)
I used Cocos2d 2.0 on Xcode 4.6.3.
I faced a 'Lexical or Preprocessor issue' about kazmath/SomeFile.h file not found.
Looked around but could find only outdated questions.
I added Cocos2d to iPhone project and will discuss the steps i have taken so that it can help people looking for doing this and facing issues...
I will point out the steps that I have taken , so someone can take a look
Step 1.
Create a test project in Cocos2d and find the “libs” folder in finder, and then just copy it into your project’s folder in finder. Then from finder, drag-and-drop the “libs” folder into Xcode’s “Project Navigator” sidebar and check the “add files to destination”.
Step 2.
In Project > Targets > Build Phases > Link Binaries with libraries > Hit the + and Check if following frameworks are there if not add them:
AVFoundation.framework
GameKit.framework
CoreText.framework
AudioToolbox.framework
OpenAL.framework
QuartzCore.framework
CoreGraphics.framework
UIKit.framework
Foundation.framework
OpenGLES.framework
Step 3.
In Project > Targets > Build Settings > Search Paths > Header Search Paths
Add (quotes included) this
“(your Project's folder name in finder)/libs/kazmath/include”
Step 4.
In Project > Targets > Build Phases > Link Binaries with libraries > Compile Sources
Select all files except classes that are your project already and hit enter and add the Compiler Flag -fno-objc-arc.
By doing that, hopefully all the Cocos2D files are now ARC-disabled.
Try to Build at this moment….
If there are issues then continue
Step 5.
Go to Project > Targets > Build Settings > Linking > “Other linker flags”
Add -lz and -ObjC .
Build again to check any issue still exists…
Step 6.
Go to Project > Targets > Build Settings >Search Paths > User Header Search Paths
Add this
./(your Project's folder name in finder)/libs/kazmath/include
Now try to build.. The issues might have gone by now.
I got help from the Coco2d forum and would like to thank the forum members..
Cocos2d Forum Thread
I am a newbie in programming, so please don't be rough on me if there is any mistake.
Related
please take a look at the picture:
It's my project structure:
1 app(top one)
3 frameworks (create by myself)
1 cocoa pods static library(bottom one)
When I cmd+b, all the sub projects would be build start from the bottom one to the top one, here is no problem, everything are fine.
To refer/link the frameworks, I drop the framework product to every sub project's /Build Phases/Link Binary With Libraries and /Build Phases/Copy Files.
The problem is:
When I copy/move the project folder to another place (like ~/oldFolder/app to ~/newFolder/app) the sub project cannot finds the frameworks, it report Not Found Error, I need re-build and drop the framework product to link to fix the error.
It's too stupid and hard to work with other people, anyone can help?
p.s.: sorry for my poor english.
Add error pic:
You can use $(SRCROOT) if you want to refer paths relative to your source directory . $(SRCROOT) will point where your project files are . apple doc
An example :
if you have a directory x in your MyApp folder which contains your project file then the folder x can be reffered as $(SRCROOT)/x. Enter this in frameworks path section in Build settings to refer to your library .
This all boils down to you not being able to change the location of the already imported frameworks right? This is an example with the FBSDKCoreKit.framework. If I were to change the folder location I would need to change the relative path. Click on the folder Icon right next to the name and choose the new location
I post the detail of how to fix this issue on my side here:
In Framework:
set "$(SRCROOT)/../build" at item "Per-configuration Build Products Path" in Build Setting page;
shift+cmd+k to clean up the framework build, then cmd+b rebuild the framework;
In MyApp
add "$(SRCROOT)/../build" at item "Framework Search Path" in Build Setting page;
Drag the framework from the product of framework project to "Link Binary With Libraries" in Build Phases page;
Drag the framework from the product of framework project to "Copy Files" in Build Phases page(you can add the "Copy Files" item by
click the top left of Build Phases page);
Please note if you use one more framework in the same project, and the framework also links to another one like the sample I sent in my question, you also need to do all the steps as above I posted(Steps of Framework and App).
Another problem you will meet if you also use cocoapods in your project like my sample: After you done all the steps above, XCode will response error in your framework project like:
ld: framework not found Pods_xxx.framework
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The "xxx" should be your framework project name. To fix it, you just need remove the Pods_xxx.framework in your project/General/Linked Frameworks and Libraries. The error will be disappeared after you rebuild the project. Here you can find the detail of this problem.
p.s.: the Pods_xxx.framework will appear in General/Linked Frameworks and Libraries after you install pod, so you need remove it again if you run command "pod install"
This question seems to be a very basic one but I cannot find a solution on Stack Overflow or anywhere else that works for me so I am posting it here.
I have a .h file that is part of a framework - AWSCore/framework that the compiler states it cannot find.
In the past I have tried using Cocoapods unsuccessfully and do not wish to suffer that pain again - I must use frameworks for this implementation.
I have added the framework to the project and you can see the framework toolbox icon in the Project Navigator:
Opening the AWSCore Framework I can find the AWSCore.h:
With AWSCore.h highlighted, Xcode shows the correct location of the framework and .h file when clicking the arrow in the File Inspector:
If I select the target, go to Build Phases > Link Binaries With Libraries, I can see the framework file there as well:
Here is what I've tried:
1) Quit Xcode, start Xcode and clean project.
2) Quit Xcode, reboot.
3) Delete intermediate directories.
4) Select Target> Build Settings > Framework Search Paths > Debug > a non-recursive directory correctly points to where the framework resides.
5) Removed references to Framework and re-add Framework to project.
Additional information:
This project compiled and ran successfully yesterday.
I can archive it successfully with a distribution provisioning profile.
What have I missed?
Please do not recommend CocoaPods as a solution.
I am using Xcode 6 and following an Xcode version 4 tutorial so things are different here and there.
There doesn't seem to be a Frameworks folder in my project navigator and so when I downloaded some .framework files and added them manually in the build phase of my project editor, I had no Frameworks folder to save them in and just let them fall into the top of my project navigator. So they are there, just not in a special folder, and it doesn't look good.
So should Xcode 6 have a frameworks folder automatically, or do I need to create one myself? And if so, how can I do that? (I've only added new files so far).
In Xcode 6, the Frameworks folder is not added by default. You can drag and drop your .framework files into the project navigator (tick 'Copy items if needed'), then select them all > right click > "New Group from Selection" and name the folder 'Frameworks'.
Also, make sure the frameworks are added into the Project > Build Phases > Link Binary With Libraries. If not, drag them there from your newly created 'Frameworks' folder.
In short, no, you shouldn't need to create a Frameworks group yourself as Xcode is doing stuff automatically for you...
Apple are slowly, gently pushing developers in the direction of newer Clang features with the goal of making native iOS development more approachable for newbies who don't have previous experience of compiling and linking with C-based languages.
You'll find that Objective-C projects created with Xcode 6 have new build settings enabled by default including Link Frameworks Automatically (CLANG_MODULES_AUTOLINK) and Enable Modules (C and Objective-C) (CLANG_ENABLE_MODULES).
Suggested reading:
Modules (Clang documentation)
#import vs #import - iOS 7 (excellent Stack Overflow answer)
I found the other answers too confusing (where am I supposed to get .framework files?)
It's way simpler in Xcode 6. Just go to Capabilities and turn Maps on. That's it... really.
I would recommend using drag and drop feature to move files into Xcode. Xcode show you the Choose options for adding these files window [Copy items if needed] [Added folders]
For example Xcode can automatically add relative path ($(PROJECT_DIR)/) to:
Build Settings -> Library Search Paths if you drag and drop a library
Build Settings -> Framework Search Paths if you drag and drop a framework
I'm using the instructions here to integrate Core Plot into my iOS Xcode 5 project and am having no end of issues.
I tried using the Static Library Install but it seems this refers to 1.4 as there is no directory called CorePlotHeaders though if I try to use 1.4 I run into runtime issues.
I've then tried to drag the CorePlot-CocoaTouch.xcodeproj as described in the Dependent Project Install but this only copies it as if its a file and not the whole project.
Is there more current instructions for using it as a static library or how am I copying the project incorrectly into my project?
Here are some current steps to follow to add the static Core Plot library to your project:
download the latest version of CorePlot here
navigate to the CorePlot framework folder and run CorePlot-CocoaTouch.xcodeproj
build (not run) the CorePlot-CocoaTouch.xcodeproj project
navigate back to your CorePlot download folder > build > Debug-iphoneos and verify libCorePlot-CocoaTouch.a has been created. If not, unzip the download and repeat steps 1-4
back in Xcode highlight the CorePlot-CocoaTouch project
click Product > Scheme > select Universal Library (selects which target to build)
build project again (not run)
go BACK to your CorePlot download folder > build > Release-universal and you will see the CorePlotHeaders folder and libCorePlot-CocoaTouch.a are both available
open the Xcode project you would like to add static CorePlot to
add the CorePlot > build > Release-universal > CorePlotHeaders folder and libCorePlot-CocoaTouch.a files to your project (selecting 'copy items into destination group's folder)
select your Project and in the 'Linking' section find 'Other Linker Flags' and add -ObjC
from your Target > Build Phases > Link Binary With Libraries add the QuartzCore framework to your project
if libCorePlot-CocoaTouch.a is not in your Link Binary With Libraries list drag it from where you copied it to your project to the Library list to add it.
You should now be able to
#import "CorePlot-CocoaTouch.h"
(autocomplete) to the viewController that you will be using to manage your CorePlot.
If you are following old documentation on how to use CorePlot be aware that the new prefix is CPT (not CP, adjust accordingly)
Happy coding!
If you want to use the static library, build it using the "Universal Library" target. This will put the static library and the CorePlotHeaders folder in the build folder inside your Core Plot directory.
To use the dependent project, drag the project file from the Finder into Xcode under your app project in the browser pane at the left side of the Xcode window. Remember to set the "Header Search Paths" in your app build settings or it won't be able to find the Core Plot headers.
Use Cocoapod to install the necessary libraries instead of this manual step if you want to solve this problem in 1 minute ... (follow this link and go to the last thread: iOS CorePlot how to install)
As well as the steps above, you need to include -all_load in linker options, otherwise it won't work on Xcode 7.1.1
I am working with the AR Drone to develop new application.
I want to establish a dependency between two projects. So when I compile one, I hope Xcode will help compile the another one automatically. I had searched with Google for this question. The solutions found are quite old and not applicable for Xcode 4.
Right now, I have two project, namely, ARDroneEngine.xcodeproj and FreeFlight.xcodeproj.
ARDroneEngine is a library for FreeFlight. Here comes the screenshot.
If I compile FreeFlight with iPhone / iPad simulator, it is fine since the ARDroneEngine is last compiled with the same setting. This is where the question lies. To test my application, I want to compile and run FreeFlight in my iPhone. So when I change the setting to "FreeFlight > xxx's iPhone" and compile, the error occurs: "Apple Mach-O Linker Error".
I think the problem is rooted from the Target Dependencies between two projects.
A quick workaround will be: Compile the ARDroneEngine again with the new Scheme "ARDroneEngine > xxx's iPhone" and launch FreeFlight in Xcode for my iPhone.
But I want a more complete solution with the dependencies between projects. If more information is required to solve the problem, I can always provide new info.
Thanks,
Steven
Xcode's solution to cases like this is to use a Workspace that encompasses both projects: then, when one project has a target that references the build product of another, it automagically works out the dependencies and builds them in order.
Create a new Workspace (File > New > Workspace); name it and save it anywhere you like (though putting it in a parent folder to both project directories might be a good idea).
Add both projects (drag the xcodeproj files from the Finder into the navigator pane, or use File > Add Files).
Expand the Products group of your library project so you can see the (placeholder for the) built library (libARDroneEngine.a).
Select the app project (FreeFlight) in the navigator and its app target in the editor -- you should be looking at the Summary pane for the target (the one with bundle identifier, deployment info, entitlements, and most importantly, the "Linked Frameworks & Libraries" list).
Drag the library (libARDroneEngine.a) from the navigator (where you made it visible in step 3) into the Linked Frameworks & Libraries list.
That's it! Now you can choose the FreeFlight > xxx scheme and it'll automatically build the library project before building the app.
You can probably get a more complete summary of these instructions (with screenshots and all) in the Xcode help for Workspaces.