I have two projects that are build on 2 different compilers. I need to combine both into one single app. Found out from a source that it is possible to compile any one of the project into a library and add it into the other to use it.
I fairly new this concept. Has any one done anything like this? How do i convert one of the project into a library and how would i connect the two? Will i still able to call the views in that project(library) in my other project? I am using XCODE 4.2 and iOS 5.
Create a "Cocoa Touch Static Library" to build your "Project"/target, and include the then-built library (with its public headers) into the second one. Note that the details depend quite a bit on what you mean by "project" and by "call the views" (which looks a bit wrong).
If you have two existing projects (with .xcodeproj files), open the "app" project (guessing one is of such kind), and include the lib project inside it (by drag & drop, or by "Add Files..."). Not the opposite.
Then in the "Build Phases" of the app project, you can add your "lib" project as a target dependencies (making your lib to always build when building your app). Finally, add the lib project product (the .a) in the "Link" build phases of the "app" project.
Related
We've are developing our OSX project using cMake as a tool to create the Xcode project.
However, it turns out we now need some localization, for which we need both English and German .xib files (or .strings to generate them, that's not the important bit).
We have the files in the right place and correctly created, but when cMake generates the project, the files are inserted into the Xcode project as two completely separate and independent files, such as:
Foo.xib
Foo.xib
Instead of two "sub-files" under the same name:
Foo.xib
- Foo.xib (English)
- Foo.xib (German)
If i drag and drop the xib's that are in en.lproj and sv.lproj directly to the resources folder in the project explorer:
Xcode automatically detects that this is some different languages of the same UI, hence the languages are added in the project settings automatically.
Also the xibs get a MainMenu.xib group in the project explorer three, consisting of both the languages.
I try to add the localized xib's to the project through cmake. They get added to the resources folder but not as identified localizations, I only get two xibs in the project explorer three no localization no connection between them.
How can I make the localization work through cmake generation?
set(CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS_MACOSX
mac/en.lproj/MainMenu.xib
)
set(CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS_MACOSX
mac/sv.lproj/MainMenu.xib
)
set(CEFCLIENT_RESOURCES_SRCS
${CEFCLIENT_RESOURCES_MAC_SRCS}
${CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS}
${CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS}
${CEFCLIENT_RESOURCES_RES_SRCS}
)
Is there a way to generate the Xcode projects through cmake with the .lproj bundles working?
We just did this ourselves. Unfortunately the solution is not pretty. I ended up writing my own python script using mod_pbxproj to modify the xcode project after cmake generated it. If you can get away with using a regular xcode project instead of a cmake generated one, I think you are better off. What you have to do to make XCode recognize a set of files as localizations is pretty complex.
You can find an example of handling xib files for Xcode project here: https://github.com/open-eid/updater/blob/master/CMakeLists.txt.
Summary: one can use custom command + set MACOSX_PACKAGE_LOCATION property on resulting nib:
add_custom_command( OUTPUT MainMenu.nib
COMMAND ibtool --errors --warnings --notices --output-format human-readable-text
--compile MainMenu.nib ${CMAKE_CURRENT_SOURCE_DIR}/mac/en.lproj/MainMenu.xib
)
set_source_files_properties( MainMenu.nib
PROPERTIES MACOSX_PACKAGE_LOCATION Resources/en.lproj )
I get the following error when trying to embed a private framework into a Swift OS X app:
dyld: Library not loaded: #rpath/CustomCalcs.framework/Versions/A/CustomCalcs
Referenced from: /Users/sam/Library/Developer/Xcode/DerivedData/TestFramework-ckcpduuqyfclssceomyzqbxgbjdi/Build/Products/Debug/TestFramework.app/Contents/MacOS/TestFramework
Reason: image not found
I am trying to simulate the scenario where I am the receiver of a .framework file from a 3rd party and don't have access to the source code or Xcode project file (even though in my simple test of course I do)
Steps I have taken:
1. Add file to my target project making sure to copy it into the project
2. The Xcode syntax highlighting/completion then becomes aware of the classes within the framework - this is good
3. I add a "copy file" step in the Xcode "build phase". I have added it to "frameworks"
4. When examining the directory that the app runs from within DerivedData, I can find no framework directory and no .framework file
5. When I run the app the error above occurs
It would appear that I need to setup a step whereby the .framework file is copied into a deployment directory AND somehow the app knows to look in this location. How specifically do I go about doing this in Xcode?
I may be wrong but is seems like a case of "Linked Frameworks and Libraries" vs "Embedded Binaries".
Click on your project Workspace
Select your project Target
In the General tab, remove the Framework from "Linked Frameworks and Libraries"
Add it to "Embedded Binaries"
Build
It will be automatically added to the "Linked Frameworks and Libraries" also but you'll have it once instead of two times.
I've done a some looking around but most of the answers I've found have been or felt incomplete and have left me a little confused. I have been given a C Library that I need to compile into a static library using XCode 4.3 and then use in a separate iOS app project, but I'm unsure about how to proceed. I'm not sure if the directory structure matters or not, but here it is anyways:
Library -> Section1 -> src -> .c files
-> sec1 -> .h files
-> sec1.h
-> Section2 -> src -> .c files
-> sec2 -> .h files
-> sec2.h
I've been trying to work from this: http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html which was linked in a question similar to this one though being from 2008 its fairly out of date, nor could I get it to work. There is also this question: Including external C library with Xcode but it doesn't go into the details of actually generating the library, before then including in a separate project.
If someone could provide a clear and up-to-date answer I, and many others, would very much appreciate it I'm sure. Let me know if any more information is needed!
To build the static library:
Create a static library project in Xcode
Add all the .c and .h file to the project
Compile
The easiest way to use this library is then to add this static library project to you application project. This avoids having to worry about creating fat libraries (i.e. libraries with code for both the simulator and device).
To add the static library project to your application project:
Choose File > Add Files to ""...
Add the .xcodeproj for your static library
Click on your app's .xcodeproj in the Project Navigator to show build options
Click on your app's target and choose the "Build Phases" tab.
Expand the "Link With Binaries Section"
Click the '+' button
Expand the "Workspace" section (you should see your library, a .a file, there)
Click on your library and you should be good to go.
Apologies for excruciating level of detail above, but somehow people always seem to forget to do steps 4-8 and then they wonder why they are getting link errors!
Xcode will not be able to find the headers for your library. You can either add the public headers to your project as you would any other header file or set the "Header Search Paths" in your build settings.
Try the Universal Framework project, as seen on github: https://github.com/kstenerud/iOS-Universal-Framework/. I have used this extensively, and it works nicely. You just create a new XCode project for that library, put in all the source and header files, and it will build a static Framework. That you can use in other projects, and you also don't have to worry about the header search paths.
I have a main project, which includes a nested library project which produces a libCore.a library.
Both of the projects have the two configurations debug and release. Now if I build the main project with a given configuration, how can I make sure that this is passed down to the library project as well?
Make your project directly dependent on the libCore project. Do achieve this, do the following:
Drag the libCore project file to your main project. It happens sometimes, that only the xcodeproj file is moved. If this happens to you, restart XCode (this happend to me with RestKit and the latest XCode).
After point 1 is done and you can browse the dependency project, go to your target build phases and add the libCore as the target dependencies.
Link against libCore.a by adding in the Link Binary with Libraries phase.
These are 3 basic steps, I don't know what the libCore is, if it needs to be linked with any other libraries then you will also have to link your target against those libraries.
I am trying to add a dependent project in XCode 4. The link to the project is this: https://github.com/jverkoey/ObjQREncoder
The author described a way to add this but it's for XCode 3. I am trying to add it to XCode 4.
I dragged the project inmy frameworks, then went to Targets and QREncoder in Target Dependencies. Then I added libQREncoder.a in "Link Binary with Libraries". Then I added this for header search path "src/Classes".
When I include "QREncoder/QREncoder.h", it gives me this error: file://somePath/FINALQRAppDelegate.m: error: Lexical or Preprocessor Issue: 'QREncoder/QREncoder.h' file not found
This is how my project is set up:
FINALQR is my project to which I am trying to add the dependency and the dependency project is in src.
Thanks.
The problem is it doesn't recognize the QREncoder class.
Only Xcode 4 workspaces benefit from shared build folders across multiple projects. From the main menu, select File > New > New Workspace... Save the workspace, then drag your subprojects into its Project navigator panel.
Be careful where you place them (make sure you're not making one project a subproject of another within the workspace) so that they're all top-level projects within your workspace. This will cause them to share the build folder and automatic dependency detection should work.
Unless, of course, you have custom search paths set in your targets' build settings. :-)
I think your problem is you need to set the following as your search path:
"$(SRCROOT)/src/Classes"
not
"src/Classes"
If you already have an Xcode4 project, you should be able to drag QREncoder into it as a subproject, as I think you have already done, and then add the .a file, also as you've done.