Xcode 4 & three20 & create IPA archive: No such file or directory

我的未来我决定 提交于 2019-11-28 21:29:08
Amir Naor

The Three20 documentation did not solve this issue for me (unfortunately...). Eventually what worked for me was a mix of a few solutions. There is a difference between "Archive" and "Build for Archiving" (or build for run) and using these steps I have both of them working with no build issues:

You will need to change the scripts as Manni mentioned, set the "Skip Install" flag for each Three20 project linked to your project tree and add the following paths to your project's "Header search paths":

"$(BUILT_PRODUCTS_DIR)/../three20" "$(BUILT_PRODUCTS_DIR)/../../three20"

this will get you to work with the Build option. When you want to perform the archive action, then you will also need to change the "Locations" preference in Xcode as featherless mentioned above.

I documented these steps in this post.

Configuration that works both for build and archive in Xcode4.
https://github.com/pazustep/three20/commit/4a9aad4eb90a6962dd729d245f9293a7cc0d7f36


src/common/Configurations/Paths.xcconfig

REPO_ROOT_PATH    = $(SRCROOT)/../..
ROOT_SOURCE_PATH  = $(REPO_ROOT_PATH)/src

//OBJROOT = $(REPO_ROOT_PATH)/Build
//SYMROOT = $(OBJROOT)/Products

// Search Paths

LIBRARY_SEARCH_PATHS    = $(STDLIB_LIBRARY)
//HEADER_SEARCH_PATHS     = $(STDLIB_HEADERS) "$(CONFIGURATION_BUILD_DIR)/../three20"
HEADER_SEARCH_PATHS     = $(STDLIB_HEADERS) "$(BUILT_PRODUCTS_DIR)/../three20" "$(BUILT_PRODUCTS_DIR)/../../three20"

src/scripts/Protect.command

# Ignore whitespace characters in paths
IFS=$'\n'

#cd ${CONFIGURATION_BUILD_DIR}${PUBLIC_HEADERS_FOLDER_PATH}

if [ "${DEPLOYMENT_LOCATION}" == "YES" ]; then
    PREFIX=${BUILT_PRODUCTS_DIR}/..
else
    PREFIX=${BUILT_PRODUCTS_DIR}
fi

cd ${PREFIX}${PUBLIC_HEADERS_FOLDER_PATH}

chmod a-w *.h 2>> /dev/null
chmod a-w private/*.h 2>> /dev/null

exit 0

Another thing that could throw off the build process is using a scheme name that contains spaces.

XCode won't stop you from doing it, but if you use a name like "Ad Hoc" for your scheme, you'll end up the same errors:

Three20/Three20+Additions.h: No such file or directory

I'm looking into this right now and will hopefully put together an adequate patch that works in both Xcode 3.2.# and Xcode 4.

Edit: 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.

three20.info: Xcode 4 Transition Guide
http://three20.info/article/2011-03-10-Xcode4-Support

This guide has been put together by the Three20 team in order to help you migrate your apps to Xcode 4 successfully.

Make sure your scheme name doesn't contains spaces. That also leads to the "File not found" build error.

I had to go under Project Info > Build (tab) and add the following to the header search path:

three20/Build/Products/three20

This path may be specific to my project, but there it is in case it works for someone else.

Open the file /src/common/Configurations/Paths.xcconfig

old code:

HEADER_SEARCH_PATHS     = $(STDLIB_HEADERS) "$(CONFIGURATION_BUILD_DIR)/../three20"

new code:

HEADER_SEARCH_PATHS     = $(STDLIB_HEADERS) "$(CONFIGURATION_BUILD_DIR)/../../three20"

So, I still have 7 errors, but I can create the archive...

Google Groups: Xcode 4, Three20 and Project -> Archive
http://groups.google.com/group/three20/browse_frm/thread/cde36b7dab178bad

Amir Naor's answer is perfect. I verified his answer on xcode 4.2 and it worked. I missed the step "You will need to change the scripts as Manni mentioned above" so I kept getting the similar error as quoted in the original question post. hope you don't make the same mistake. also as of xcode 4.2, the step "then you will also need to change the "Locations" preference in Xcode as featherless mentioned above." isn't needed any more.

I did the following to make it work for me:

  1. for the three20 static library, I used cocoapods to include the files within the main project.. it just got rid of all the trouble three20 was giving me (and they are lots..) btw i tried replacing three20 with Nimbus.. but Nimbus was lacking on some of the features that my project was using three20 for.. so Nimbus wasn't helpful.
  2. set skip install to yes under build settings for all other sub projects/static libraries and switched the copy headers from public to project under build phases
  3. most importantly: under the sub libraries.. under build phases i ensured that copy files destination was changed from Absolute path to products directory.

and that was it!

hint: to get an idea of the offending files that's causing your archive to create an archive file rather than an ipa do this:

  1. Select the archive and click the Distribute button.
  2. Select the 'Save Built Products' option.
  3. Hit Next and Save.
  4. Browse the created directory in Finder.
  5. The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes.
  6. in some cases usr/local/include will identify the culprit header files you need to move from Public to Project or the files that you have to change from absolute path to products directory. but that directory (ie usr/local/include) varies depending on your sublibrary directory structure

If you want a quick workaround, just do next simple steps:

1. go to the mentioned /Users/[USERNAME]/Library/Developer/Xcode/DerivedData/[PROJECTNAME]-blabla/ArchiveIntermediates/[PROJECTNAME]/BuildProductsPath/ path (it will be in your error message). It should be a substring till /.. in that path.
2. create Release-iphoneos (or Debug-iphoneos if appropriate) folder there

Then everything will build fine!

Three20 script assumes you already have that folder, but when you build first time there is no one exists. That's why you need to fix "Build" and "Archive" separately: "Build" action usually uses Debug-iphoneos folder and "Archive" action uses Release-iphoneos.

Tip: you can create all the required folders at once to avoid problems with different configurations. These are:
Release-iphoneos
Debug-iphoneos
Release-iphonesimulator
Debug-iphonesimulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!