Xcode4 project with custom configuration name vs dependency library Debug/Release? - iphone

I have an Xcode app project with available configurations "Foo", "Bar", and "Baz". This project is dependent on a static library with configurations "Debug" and "Release".
Xcode4 is building products from the app project into a "Foo-iphoneos" directory, and products from the library project into a "Release-iphoneos" directory.
What is the best practice for having these two projects share the same build products directory?

You can add the following path to library search paths for any non-standard configuration:
"$(BUILT_PRODUCTS_DIR)/../Release-$(PLATFORM_NAME)"
This works for me with xcode 4.6. I'm not sure if there is a way to control which configuration will get built for the dependent sibling projects, but for my purposes Release was what I wanted.

One solution is that if your dependent projects have the same configuration names as the main project (i.e. Foo, Bar, Baz), then Xcode will match them up and build using the same configuration.
So, if you wanted a debug build instead of a release build, you could duplicate the Debug configuration and call it Foo. If you do not really need both, you could rename the configuration instead of duplicating it, but with example names like Foo, I am not sure what would make sense for your situation.
However, the title mentions Xcode 4. The technique described above is what I used to do in Xcode 3; I haven't figured out how to manage these configurations yet in Xcode 4. I'm trying to figure that out now.
Update: To manage configurations in Xcode 4, you can click on the name of your project or dependent project towards the top of the project navigator (where all your files/folders are listed on the left side). In the main window, select Info (the other tab is Build Settings). You will then see the Configuration section where you can add/delete/rename your configurations.

I have found that if your target and dependencies' configurations don't match then the dependencies will be built with the Release configuration.
I couldn't find a way to customize that.

Related

Automate Eclipse build configurations for referenced projects

I have 3 C projects (prj_1, prj_2 and prj_3) in my workspace. prj_3 is referenced by prj_2 and prj_2 is referenced by prj_1.
For each project I have 4 build configurations as x86_win_debug, x86_win_release, x86_linux_debug and x86_linux_release.
The problem arises when I want to change the build configuration of prj_1 from one to another. I have to change the build configuration of the sub-projects (referenced projects) one by one manually. Is there any way to automate this process without using my own makefile? i.e. I change the build configuration of prj_1 to x86_win_debug and I want all the sub-projects be compiled with x86_win_debug configuration even if their last configurations are different then x86_win_debug. Is that possible?
This is possible with the "Project References" settings in the "Paths and Symbols" page of your project's properties. See also the related Eclipse help entry.
I have just tested this by deleting the associated build folder from the referenced project and building the dependent project.

Create Swift framework (revisited)

I have read Create and import swift framework (and many more) but it does not work. Here's what I did: I created a vanilla framework and added a simple Test.swift.
This builds with no issues and I guess that this should be a valid framework containing my Test class.
Now I import this framework to another vanilla app:
But trying to access my framework fails:
With the information available from your question, "no such module" can mean that you either aren't linking against the framework, or the framework is not in the framework search path. Further, it looks like you have dragged the built framework directly into the dependent project, because I don't see the project where FW.framework included either as a top-level project in a workspace, or as a project dependency (i.e. you have not dragged FW.xcodeproj into the project navigator when you have FrameworkUse open). There are a few ways to resolve this:
Drag FW.xcodeproj into the project navigator somewhere under the FrameworkUse project (this will add FW.xcodeproj as a subproject to the FrameworkUse project). Then go to build settings and a) add the FW.framework target as a target dependency to the FrameworkUse target, b) add the framework (from the Products group under FW.xcodeproj) as an embedded binary.
Drag FW.xcodeproj to the top level in the project navigator when you have FrameworkUse project open. Xcode will ask if you want to create a new workspace (unless you already had a workspace open, at which case FW.xcodeproj will be added to the workspace). Similarly as with the above option, go to build settings and a) add the FW.framework target as a target dependency to the FrameworkUse target, b) add the framework (from the Products group under FW.xcodeproj) as an embedded binary.
If you really want to depend on the built FW.framework instead of expressing a build dependency to it with either option 1 or 2, you need to a) add the framework as an embedded binary, and b) go to Build Settings and add the directory containing the FW.framework (whose location you can find by opening it in Finder into "Framework search path", for instance "$(PROJECT_DIR)/Frameworks" if Frameworks under the project directory is where you place built frameworks).

Can't link static library in XCode 4 in workspace

So, I'm working on a project and can't get my XCode 4 workspace to behave. I have the main application as one project in the workspace. I then add the static library project into the workspace. It seems like everything is working okay. I can import files from the other project. It builds, but when I run it, I get this:
dyld: Symbol not found: _OBJC_CLASS_$_iGBC
Referenced from: /var/mobile/Applications/CD00CC83-28E4-4467-96C0-0D1777E21FDA/GBA4iOS.app/GBA4iOS
Expected in: flat namespace
in /var/mobile/Applications/CD00CC83-28E4-4467-96C0-0D1777E21FDA/GBA4iOS.app/GBA4iOS
And crashes. It appears that although Xcode believes the library has been linked, and it builds and runs, the app doesn't actually have the library. But in the derived data folder, it looks like everything that should be there... is there.
I'm going insane with XCode and all it's nuances in settings. Are there sanity checks I can go through to ensure this is working properly? What else can I do?
Edit:
Project settings are valid, and I've already linked the libraries.
Edit 2:
My workspace is setup so the libraries are also in the workspace:
I have removed the lib.a file from the main project and removed it from the Build Phase section, and added it back numerous times. There is no "copy library into destination folder" option when adding it in this way, so I can't do that.
try clean your build, if it don't work, remove the library in build phase and your project folder. When adding the lib to your project, check "copy item to destination if needed", the add that lib in build phase.

Xcode 4 Archive Version Unspecified

I'm trying to build a release version of my iPhone app in Xcode 4 and when it finishes and launches Organizer, there is no version number, it only says "unspecified". This is preventing me from using Xcode 4's Validate and Submit features.
Any ideas on how to fix this? My version number is set in my project settings, so not sure what's causing the problem.
Go to your info.plist file and create a new property "bundle versions string, short" and provide the same version number and it will show up in organizer.
Please see this question for additional detail.
The accepted answer doesn't fully solve the problem for all projects. There are several issues that all relate to each other and I will cover them all.
Xcode 4 Project Fails to compile a static library
Related question: Xcode 4 can't locate public header files from static library dependancy
Related question: “lexical or preprocessor issue file not found ” in Xcode 4
Errors might include; missing header files, "lexical or preprocessor issue"
Solutions:
Check the "user header paths" are correct
Set "Always search user paths" to YES
Create a group call "Indexing headers" in your project and drag the headers to this group, DO NOT add to any targets when prompted.
Xcode 4 project with static library dependancy fails to create a valid archive
Related question: https://stackoverflow.com/questions/5271496/xcode4-ios-4-3-no-packager-exists-for-the-type-of-archive
Errors might include;
Missing identifier and version. "No Packager exists for the type of archive"
Solutions:
For all dependancies set "Skip Install" build setting to "Yes"
Moving any "Public" headers in Build Phases to "Project"
Thanks but I needed 3 steps to entierly solve the problem with my project framework:
set the Target Build Settings/"Skip Installation" property to "YES" for every dependency project
clear the Target Build Settings "Installation Directory" property for every projects
for every projects, move every headers from section "Build Phases/Build Settings/Copy Headers" Public/Private to Project
This can also happen if your project references a misconfigured subproject for a shared library. Go through the Xcode projects for any shared libraries your project uses and make sure the target's "Skip Install" build setting is set to "Yes". Then rebuild the archive.
I had all these issues and more with an ad-hoc distribution build.
If you have static library dependencies and create a new build configuration for your Ad-hoc distributions, be sure that the library dependencies also have a matching build configuration. Otherwise, they default to using the Debug build configuration (or whatever configuration is first, I guess) and will be linked to your build.
For emphasis, in case it's not clear in other answers: set Skip Install to NO for your main project and have a valid Installation Directory set. Otherwise, they should be set to YES and empty respectively.
Also, I set a valid icon to remove the validation warning but I'm not sure whether this was required for a working package.
After updating Xcode from 4.0 to 4.1, I found that version information was missing and was blank on the specific 'Target'. And apparently now the version number was being displayed in the build field.
Just add your application version number to the version field for the 'Target' and it will implicitly update the info.plist file.
Archive the project and now you should be able to see the version number in the Archive.
And you should be good to go.
HTH.
My problem with no version or identifier on archive was simple in the end. I have one project with two targets. I have 2 schemes, each building a single target, or so I thought. My iPad scheme had the iPad and iPhone target listed in the build targets of the scheme setup. It was as simple as that, it was building both targets and not creating a valid archive.
I was having similar problem. First I was making universal app, but in the end client wanted separate prices for iPhone and for iPad app. So I created new target in xcodeproject.
When I wanted to archive iPad target I had version unspecified problem.
Here is solution.
In project set Skip Install to NO.
When you want to archive iPhone project set Skip Install to NO in iPhone target, and Skip Install to YES in iPad target.
When you want to archive iPad project set Skip Install to YES in iPhone target, and Skip Install to NO in iPad target and it should work.

Reconfiguring a dynamic library

I'm working with an open source library that's made available as a git repository (XML-RPC) and I'd like to use it in an iPad application. As I understand it, iOS applications should use static libraries for their linking.
Since this comes as a dynamic library, how can I convert it to something I can link with my app and use?
Maybe naive answer but why not just add all the relevent files in the repository to your app and just build it?
Put the files in a seperate folder obviously so you can update them to a newer version if you need to etc. Lots of projects I've done have an 'external' folder that just contains codethat I use from 3rd party sources. I've usually got the source so just compile it into my app and don't bother with making it a library.
Or are there tricky conditions that need to be met to compile this code?
I ended up doing this in several steps:
First, I opened the library project in Xcode and created a new target for the static library. I then made a directory in the project folder called "XMLRPC" and moved all the header files to it. I deleted the now-red invalid references to the header files, and re-added them (but kept the box for copying them to the current folder unchecked).
I added this Xcode project to my main project with a relative reference. I opened my main app's target and added the library project as a direct dependency, and checked the "Always search user paths" option on my main app's target settings.
Lastly, I modified the general Xcode preferences to use a shared build directory. I haven't tried it without that since it was something I wanted anyways; it might not be necessary.
My revision control has two folders in it: one's my project, and the other's the library. The library is still under git control within mercurial; I'm hoping this doesn't cause any issues.