I am trying to use a framework that requires me to add a 'Copy Files build phase' to my target. Does anyone know what this means and how to do it?
In Xcode 5, you have to click on your target, then on Editor (menu bar) --> Add build phase --> Add Copy Files Build Phase:
Right-Click on your target in XCode, select add "new build phase" and then "new copy files build phase".
A "DIY" answer: Go to Xcode --> Help --> type your query, e.g., "add copy". And Xcode helpfully points you in the right direction.
In Xcode 4, the option is in Editor->Add Build Phase.
The Copy Files build phase then appears in the Project Navigator and you can add things to it by clicking the plus.
Related
I have a custom build rule for a file type, which I setup according to this blog post. The build rule is working fine and my file is compiled.
But if I add a new file of this type to the project and I select the targets, the file is currently added to the "Copy Bundle Resources" phase. Instead, I'd like to have it added to the "Compile Sources" phase automatically (if I don't do this, the build rule won't kick in).
Is there a flag or something I can set so Xcode recognizes my files as "source files"?
I have a project embed another project, and the xcode GUI build was successful, but in command line xcodebuild failed as such.
fatal error: 'OHAttributedLabel/OHAttributedLabel.h' file not found
#import <OHAttributedLabel/OHAttributedLabel.h>
^
1 error generated.
but I had this in the project HEADER SEARCH PATH (where the h is located)
${PROJECT_DIR}/MyProject/Vendor/OHAttributedLabel/Source
the problem is the header is located in the "OHAttributedLabel/Source" folder, while the import statement is looking for header under OHAttributedLabel folder, I don't want to touch the embedded project directory structure, what can I do in this case?
The best way is to modify the embedded project to publish the header files:
Select the embedded project in xCode
Select the applicable target.
Click on the build phases
Expand "Copy Headers" section and add OHAttributedLabel.h file.
Select your main project
Select the applicable target.
Click on build phases.
Click on Target dependencies.
Make sure that the embedded project is added as a dependency.
Try to run the app
If the above doesn't work double-check the order of the build phases. E.g. make sure that the "Target Dependencies" build phase is before "Compile sources".
I have a project "blackjack" containing a project (as a child) called "GameLib", which in turn contains many projects such as "Core-iOS". I have libCore-iOS.a added to "Link Binary With Libraries," but changing a .cpp/.mm file in the static libraries doesn't cause the executable to be linked against the new .a file. The .a file is being compiled with the changes. Why is the build system broken, and how do I fix it?
You need to configure all of your targets' dependencies.
blackjack
libCore-iOS.a << dependency
If Xcode's automatic dependency detection fails, then configure libCore-iOS target as a dependency explicitly. That then solves it.
If you have found automatic dependency detection in error, please consider submitting a bug report with projects attached. I have found errors in it, but was unable (erm.. unwilling) to submit projects for them to debug the issue.
To define an Explicit Dependency:
Open the "blackjack" Project in Xcode
Select the "blackjack" Project in the Project Navigator (Top-Level)
Select the "blackjack" Target
Choose "Build Phases" tab
Click '+' in "Target Dependencies" phase, and add libGameLib target as a dependency
Click '+' in "Link Binary With Libraries" phase, and add libGameLib
Now disable "Find Implicit Dependencies" in all schemes
Restart Xcode
Clean and Build Project
That should be all that's needed to create an explicit dependency, unless you have made some atypical mods to your build settings.
using Xcode 3.2.5 on 10.6.6 (10J521) and now 10J537.
I have an Xcode project containing 1 Target: "MyApp". It builds and runs successfully.
As well as source and resource files, the Target contains a "Copy Files" build phase which copies "Sparkle.framework" in. The framework is in the same directory as the project.
I want to duplicate this Target. Steps taken:
Did "Clean all Targets".
Right-clicked on the "MyApp" Target within Xcode, and then chose "Duplicate".
Renamed the duplicated target to "MyAppTarget2".
Selected "MyAppTarget2" as the Active Target from the popup menu in the top-left.
Did "Build".
The problem:
error: Sparkle/Sparkle.h: No such file or directory
At the line:
#import <Sparkle/Sparkle.h> // In MyAppDelegate.mm
This is puzzling! Further info:
Each Build step appears to have been replicated in the duplicated Target, including the "Copy Files" phase.
The Sparkle.framework itself exists in the project's folder.
In the "Link Binaries with Library" phase of both "MyApp" and "MyAppTarget2", I am linking to the Sparkle.framework at the above location. A "Get Info" on the linked binary reports that it is a member of both Targets.
If I right-click on the Sparkle.framework file within the "Copy Files" build phase of the duplicated Target, and select "Reveal in Finder", then the correct Sparkle.framework file is shown. The required file exists at Sparkle.framework/Headers/Sparkle.h
If I switch back to the original "MyApp" target, it builds and runs successfully.
Am I doing something obviously wrong here? Thanks.
[EDIT - SOLVED]
I had a look at the Build settings for each supposedly-identical Target.
Under "Framework Search Paths", the first Target had this:
$(inherited) "$(SRCROOT)"
But the duplicated Target had this path:
$(inherited) \"$(SRCROOT)\"
It appears that Xcode incorrectly escaped the path during the duplication process. Ouch.
I know you have already solved this issue yourself, but I thought I'd share my fix for this issue (as it has happened to me several times). I've always been able to get rid of this error by deleting the file in question and just recreating it. I have no idea why this works... but, as is often the case with XCode, there seems to be some Voodoo at work.
Build Phase copy is still broken in 12.5! It does only copy a few of the source targets build phases. What a crap IDE.
I am developing an application which uses .js files stored in the Resources/javascript folder of my application bundle. In my Xcode 2.5 project I have created a folder reference (not a group) to my javascript folder, which automatically added the folder to the Copy Bundle Resources build phase.
The problem I have is when I modify my .js files, I need to clean my project then re-build it for the modified .js files to get copied into my application bundle when building. This is very time consuming since I re-build the whole project just to get an updated .js file in my app bundle.
Could someone tell me how to get Xcode to always copy specific files in the build phase?
Thanks in advance!
You could right- or control-click the file (in the project file list) and click "Touch" before building (manual) or add a script build phase to the target that calls "touch myfile.js" and place it before your Copy Files build phase (automatic).
Add a new Copy Files Build Task to your target.
Right Click (Control Click) on the target, Add -> New Build Phase -> New Copy Files Build Phase.
In the Dialog select the destination that you want the files to be copied.
This will create the phase under the target. Drag the files you wish to copy to the phase.
There's an excellent walkthrough here of a build phase script which automates the 'touch' and saves the manual step of specifying each file you want included.