views:

416

answers:

3

Hi,

I am currently trying to build the distribution product of my (first) iphone app so that it can be uploaded to the App Store. I have gone through all of the App ID and Distribution Provisioning profile process and finally got the Organizer and target's build configuration to recognize it.

The problem is that when setting the "Active Configuration" on "Distribution" (duplicate of the "Release" config. per iPhone Dev Center directions) I cannot get the code to compile. The project contains a reference to a static library which contains several classes that are used as base classes in many of the project's classes. So when building on Distribution configuration, the compiler throws errors saying that it cannot find the base classes from the static library, and the build fails.

If I switch the Active Config. to "Debug" (as used on development) there is no problem at all, and the app compiles correctly as expected.

I cannot get to find what the problem might be. I found this another similar question here but it seems to be a different case:

http://stackoverflow.com/questions/913259/iphone-static-library-distribution-and-release-build-errors-but-not-for-debug

Google also seems not to have many useful results. I have also checked the target's info in the Build section, and switched back and forth between "Debug" and "Distribution" configurations to check for any relevant difference, but no one is found so far. Actually I didn't find any relevant info on the static lib. Only on the General Tab of the info window, but the static lib is displayed correctly in the Direct Dependencies.

So, at this point I am clueless. I have tried to follow the instructions as exactly as possible, but I guess that was not enough and I am having problems now. I suppose the fix should be somewhat simple (maybe just set some parameter, somewhere) however I have not been able to find that out.

Could you please (PLEASE :) ) provide some help on this. Any help or hint, is greatly appreciated.

Thank you in advance!

+3  A: 

Check the build options for the Debug configuration; for example, header search paths for the Debug configuration may be different than for the Distribution configuration. Select the menus Project > Edit Project Settings and type: Header Search Paths to check those settings for the listed Configuration. If something is different between configurations, make them the same for both.

Alex Reynolds
I found what the problem was, thanks to Alex's hint. I will post the result below. Thank you Alex!
A: 

I have heard of linker issues with the iPhone OS 3.0 SDK; Some of the workarounds include adding -all_load to the linker flags when building your project (though this could have unintended side effects). Another option is to upgrade to the 3.1 SDK, where I believe these issues have been resolved. Of course, this might not be your problem at all...

Other places for help:

fbrereto
I was going to post this too, but in addition to -all_load, i'd make sure that you have -ObjC as well
Malaxeur
+5  A: 

Here it is:

To make the distribution build, (per iPhone Dev Center directions) you have to make a copy of the "Release" configuration and name it as "Distribution", and then build the project under this Active Configuration. Checking the "Header Search Paths" in the target's info window for Debug and Distribution configs, I noticed a difference in the value, which was set as (for both configs):

${BUILD_STYLE}-${PLATFORM_NAME}/usr/local/include

so that resulted in ${BUILD_STYLE}-${PLATFORM_NAME} being replaced with "Debug-iphoneos" and "Distribution-iphoneos" for each config. All the base classes from the static lib were stored in the "include" folder, however there was not a "Distribution-iphoneos" folder.

This was because I did not add a "Distribution" configuration in the static lib project, as I did in the main app's project (I didn't know I had to). So to fix the problem, I only added the same config. in the static lib project and built it.

So in summary, if you add a new config in a project that uses classes from a referenced static lib, also add that same config in the static lib project and perform a build. This way the main project will be able to find the base classes.

Maybe this is actually basic stuff, sorry I am just learning the language (and XCode) :).

Hope this helps, thanks to Alex again.

Regards

Glad that it helped!
Alex Reynolds