Three20 v1.1 and Xcode 4
Asked Answered
O

3

6

Is there an easy way of getting Three20 v1.1 to work under xCode 4? I followed the steps on http://three20.info/article/2011-03-10-Xcode4-Support but that seems to be for the master. I use v1.1 as I use the TTLauncher.

The project builds fine with a normal build, and runs perfect on an iPhone. But when I want to create the archive (for the IPA for distribution) then I get 18 errors and 8 warnings.

The first one is:

../scripts/Protect.command: line 23: cd: /Users/XXX/Library/Developer/Xcode/DerivedData/iDoms-cmyivarwxpbvqdfnyclqdrikrtmw/ArchiveIntermediates/iDoms/BuildProductsPath/Release-iphoneos/../three20/Three20UICommon: No such file or directory

Most others are 'no such file or directory' on e.g.: #import "Three20Core/TTGlobalCoreLocale.h"

or 'undeclared (first use of function)' which comes from the 'no such file or directory issue I presume'.

In my 'Header search paths' I have:

$(BUILT_PRODUCTS_DIR)/../three20
$(BUILT_PRODUCTS_DIR)/../../three20
../../three20/Build/Products/three20
/usr/include/libxml2

Any help would be very appreciated!

Otilia answered 16/3, 2011 at 13:43 Comment(0)
M
3

You should check out this StackOverflow question.

I've reproduced the accepted answer below:

So it looks like the easiest way to get old Xcode 3.2 projects to work with Xcode 4 is to do the following:

Go into Xcode 4's preferences (Cmd+,). Select the "Locations" tab. Where it says "Build Locations", select the drop down and pick "Place build products in locations specified by targets" I'll write up a three20.info article going into more details about this.

Mouthwash answered 17/3, 2011 at 3:40 Comment(3)
I tried that, and that does seem to reduce the amount of errors from over a 100 to 18. I will have a look at the code changes mention in the other answers in the referenced post tomorrow and see if that makes a change to the v1.1 code.Otilia
I ended up recreating the whole project in Xcode 4 as with all my trying to get it work Xcode crashed every time I opened the project. I now use the 1.0.5 release and created my own TTLaunchViewController and it works perfect!Otilia
I'd rather keep all build products in a derived location (also Apple's recommended approach). So far I'm having no luck with that option. I tried using SRCROOT instead of BUILD_PRODUCTS_DIR but I suspect that's not correct either. (Still trying to find where it's placing all the combined three20 headers. Doesn't seem to be under EITHER of those!)Donnelly
D
10

Just to add to Colin's answer: you can use Xcode's dependent projects feature to use three20, even though the three20 website says it's not "officially supported":

  1. In your workspace, right-click on the empty space in your project navigator. Select "Add files to "My Workspace", and select the three20 project (three20/src/Three20/Three20.xcodeproj). This is the only project you need to add: it is not necessary to manually add the three20 subprojects.

  2. Select your project in the navigator, go to Build Phases, open "Link binary with libraries", click on the "+" in the bottom left corner, and add the Three20 libraries: libThree20.a, libThree20Core.a, libThree20Network.a, libThree20Style.a, libThree20UI.a, libThree20UICommon.a and libThree20Navigator.a. This will cause Xcode to build Three20 when you build your project.

  3. Add ${BUILD_DIR}/three20 to your include path as per Colin's answer: go to build settings, double click on "Header Search Paths", and add ${BUILD_DIR}/three20 (it will show as build/three20 when you close the dialog).

  4. Add three20/src/Three20.bundle to your resources.

  5. It's probably also a good idea to add the linker flags -ObjC and -all_load if you haven't already done so (same dialog, setting "Other Linker Flags").

The steps above are good enough for compiling the code. To make "Archive" work too, you will need to:

  1. Add $(BUILT_PRODUCTS_DIR)/../three20 and $(BUILT_PRODUCTS_DIR)/../../three20 to the Header Search Paths setting. If you don't you will get compilation errors that the three20 headers cannot be found.

  2. For all Three20 projects (so not just the top-level project), go the Build Settings and set "Skip Install" to YES. If you don't, the project will build, but you will not be able to create an IPA.

Make sure that your product name (select your target, go to Build Settings, then setting "Product Name") does not contain spaces, otherwise archiving will not work.

Finally, if you're getting errors such as ld: library not found for -lThree20 and you are using a custom build configuration (such as AdHoc), make sure to add the same build configuration to each of the Three20 projects too (just duplicate the Release configuration).

Dicho answered 18/7, 2011 at 15:31 Comment(1)
This worked for me when nothing else would. Thank you so much!Firedog
M
3

You should check out this StackOverflow question.

I've reproduced the accepted answer below:

So it looks like the easiest way to get old Xcode 3.2 projects to work with Xcode 4 is to do the following:

Go into Xcode 4's preferences (Cmd+,). Select the "Locations" tab. Where it says "Build Locations", select the drop down and pick "Place build products in locations specified by targets" I'll write up a three20.info article going into more details about this.

Mouthwash answered 17/3, 2011 at 3:40 Comment(3)
I tried that, and that does seem to reduce the amount of errors from over a 100 to 18. I will have a look at the code changes mention in the other answers in the referenced post tomorrow and see if that makes a change to the v1.1 code.Otilia
I ended up recreating the whole project in Xcode 4 as with all my trying to get it work Xcode crashed every time I opened the project. I now use the 1.0.5 release and created my own TTLaunchViewController and it works perfect!Otilia
I'd rather keep all build products in a derived location (also Apple's recommended approach). So far I'm having no luck with that option. I tried using SRCROOT instead of BUILD_PRODUCTS_DIR but I suspect that's not correct either. (Still trying to find where it's placing all the combined three20 headers. Doesn't seem to be under EITHER of those!)Donnelly
B
1

Add these two paths to your header search paths in the build settings for your target:

"$(BUILD_DIR)/three20" "$(BUILD_DIR)/../three20"

The first entry is needed for regular builds and the second entry is needed for archives.

It's that easy.


Incidentally, to create a file in your home directory with a list of all of Xcode's environment variables for your target's environement, add the following Run script build phase to your target with contents: ENV > ~/xcode-environment.sh

Note that in this case, if your project is not making it through the compile phase of the build process, and your Run script comes later, the script won't get executed, so put it first.

Bedstead answered 12/7, 2011 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.