可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
In Xcode 3.2.5 I use "Build And Archive" to create an IPA file without any problems.
How can I do that in Xcode 4? I think I have to use "Product -> Archive", but I get over 100 error messages in the three20 framework. Most are "No such file or directory". ("Product -> Build For -> Build For Archiving" works. No errors.)
For example, this is the first error message:
../scripts/Protect.command: line 23: cd: /Users/[USERNAME]/Library/Developer/Xcode/DerivedData/[PROJECTNAME]-blabla/ArchiveIntermediates/[PROJECTNAME]/BuildProductsPath/Release-iphoneos/../three20/Three20Core: No such file or directory
The path "/[PROJECTNAME]/BuildProductsPath/three20/"
really doesn't exists, but this path exists: "/[PROJECTNAME]/three20/"
What can I do?
回答1:
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.
回答2:
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
回答3:
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
回答4:
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.
回答5:
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.
回答6:
Make sure your scheme name doesn't contains spaces. That also leads to the "File not found" build error.
回答7:
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.
回答8:
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...
回答9:
Google Groups: Xcode 4, Three20 and Project -> Archive
http://groups.google.com/group/three20/browse_frm/thread/cde36b7dab178bad
回答10:
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.
回答11:
I did the following to make it work for me:
- 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.
- 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
- 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:
- Select the archive and click the Distribute button.
- Select the 'Save Built Products' option.
- Hit Next and Save.
- Browse the created directory in Finder.
- The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes.
- 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
回答12:
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