how can i remove the source code from my static library with XCode 4?
When i have Xcode 3 in target there is the list of source and i can delete them, but with XCode 4 the target is not expandable...
Can i do olso with some libtool?
Thansk!
Not sure to understand what you mean, but if you want to remove symbols from a binary/library, you should use the strip command.
A static library is not source code, it's machine code.
You can't have access to the source files, if you only have a static library.
Otherwise, if you meant "target" instead of library, meaning you are actually building a library with Xcode, and you want that specific source files don't compile into the library, use the "Target membership" section on the Xcode right panel (utilities).
When you select the file, you can set the target for the source file:
I'm assuming that you have the library sources added to the project and you want to remove them from a specific target. Select the project (the top level item on the left side), select the target under "Targets", click "Build Phases" and remove the respective items from "Compile Sources".
Under build settings for the static library target, select NO for 'deployment postprocessing' and 'strip debug symbols during copy'. It is compiled code so it doesn't need symbols stripped.
Related
I am having a single project file. Then I created another target for a "Lite" version. I changed the bundle ID and product name for each target and am able to continue working this way.
But when I added a new custom class to the project, I try to use the class in existing VC by #import "NewClass.h" but it only works on one target, on the Lite target, it says:
File not found
Why is this and how to solve it?
While adding any new file and if you are working on multiple targets and you want that file in both the targets then you need to check both the targets while adding file
Check screenshot
You need to add the file to both the Target, so it can be accessed.
Click on the file you have added and then go to the Utilities Area in the right and click on File Inspector. You will have section called 'Target Membership', please select the target from the list of Targets.
Alternatively approach :
Select the Target in which you are getting error then got to Build Phases -> Compile Sources and make sure the file is present there.
If you forgot to add a target when you creating a file, you can add later by selecting the file in project navigator and then check/uncheck the target(s) in the File Inspector (on the right)
I want to add the PLCrashFramework in my app. This frameworks deals with crash reporting for iOS/MAC applications. What I did
Downloaded and unzipped the .zip file from the URL I have already provided.
In Xcode "Build Phases" -> Link Binary With Libraries
From the pop up "Choose frameworks and libraries to add"
Select "Add Other"... and select "CrashReporter.framework" and Open
After those steps I successfully built the project without problems.
I closed the Xcode, opened it again and tried to build. The build failed with
"header file not found", referring to a header file that belongs to the framework.
Why the xcode 6 does not find the header after closing and reopening the project?
Check your Framework Search Paths and Library Search Paths in your project's Build Settings. Check if you have a space in your directory structure. It's probably looking for 2 folders, one with the first part of the folder structure and one with the second. To fix this, simply add quotes around the whole folder structure.
You should add the framework though add file in project navigator by right click and select add file in your project and than browse to framework location and add framework. Remember to check copy file in your project it is must do. In this way Xcode will manage library header search path. You can see the framework will be added in Xcode "Build Phases" -> Link Binary With Libraries. If it is somehow not there you can add it by dragging framework from project navigator. The error will be gone.
Alternative titles to aid search:
Adding Embedded Binaries fails in Xcode
Xcode won't link framework from separate project
App crashes on device because of missing framework, works in simulator
Overview
After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).
Or, Xcode hits a linker error because it cannot find a framework that if previously could.
Other symptoms
Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.
When you add the framework to the Embedded Binaries, there will be a reference added to your project for it. If you select that reference after your steps above, you will probably find that it has an Absolute Path reference to the framework rather than a relative one, which we'd like. Change the location to Relative to Build Products and the reference should always be discoverable if do a "hard" clean or use another computer etc.
I have made a video which describes how best to add a built framework from one project to an app target in another sibling project.
This it the only way i have discovered to restore the embedded binaries, please leave comments if you find some steps are not required.
Prerequisites: Read Daniel Tull's answer.
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
Just to add to #Daniel's answer, if your Location dropdown is greyed out you may have selected the wrong file. Make sure to select the framework that's in your app project (not framework project).
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 including a 3rd party library (sources) with my static library. It it intended for device only (since it includes some ARM assembly routines) and I do not wish to build it for the simulator (I just want my app to compile there so I can test the GUI).
Creating another target for simulator only is not an option since my projects reference my library as a dependency and it would be a nightmare to maintain.
Adding #if (TARGET_OS_IPHONE) for those files is not an option as well since these are not my original sources and I would like to update them easily for updates (there are more than 200 files there and I do not with to modify all of them)
I'm looking for a way (similar to #if (TARGET_OS_IPHONE) in source files) which will work from the IDE itself (so I can exclude a file from the actual build process based on my target architecture). The only thing I found is an option to exclude/include a file from a target - but not for a specific architecture.
Is there a way to set architecture conditions per specific files?
Your best bet would be to separate the third party library into a new target that builds it as a static framework. Set it as a dependency for your project, and then set the static framework to be conditionally linked as described by Apple here: http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/ios_development_workflow/115-Configuring_Applications/configuring_applications.html#//apple_ref/doc/uid/TP40007959-CH19-SW7
You can add a new target by selecting the Project in the project navigator and then hitting the Add Target button at the bottom of the Editor pane. You can setup a cocoa touch static library and then assign the relevant .m or .c files to belong only to that target. Then select your app's target and add the static framework in the "Target Dependencies" section of the Build Phases tab.
You can conditionally include/exclude files in Xcode using EXCLUDED_SOURCE_FILE_NAMES based on sdk. For example:
EXCLUDED_SOURCE_FILE_NAMES[sdk=*simulator*] = something.cpp something_else.cpp
See Conditional Compilation article for more details