0

When archiving my iOS app the Windows Azure Mobile Services library fails to build.

The App builds fine when using Debug configuration.

While running this script:

 /bin/sh -c \"/Users/user/Library/Developer/Xcode/DerivedData/myapp-bxucrfbhixkrpqfwaaovtqqpsvyd/Build/Intermediates/ArchiveIntermediates/MyApp\ (testing)/IntermediateBuildFilesPath/WindowsAzureMobileServices.build/Release-iphoneos/WindowsAzureMobileServices.build/Script-E8E37A27161FAA9600C13F00.sh\"

This turns out to be, this script form the "Build Phases" tab:

# Exit immediately on any errors
set -e

# Set some variables
OUTPUT=${BUILT_PRODUCTS_DIR}
WAMS="WindowsAzureMobileServices"
WAMS_FRAMEWORK="${WAMS}.framework"
WAMS_LIB="lib${WAMS}.a"
HEADERS="Headers"

# Create the needed directories for the framework
mkdir -p "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A"
mkdir -p "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"

# Add the headers and lib to the framework
cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
lipo -create "${OUTPUT}/${WAMS_LIB}" -output "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/${WAMS}"

# Set up the links to complete the framework
ln -sf Versions/Current/Headers "${OUTPUT}/${WAMS_FRAMEWORK}/Headers"
ln -sf "Versions/Current/${WAMS}" "${OUTPUT}/${WAMS_FRAMEWORK}/${WAMS}"
ln -sf A "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/Current"

It fails with this error:

cp: /Users/user/Library/Developer/Xcode/DerivedData/MyApp-bxucrfbhixkrpqfwaaovtqqpsvyd/Build/Intermediates/ArchiveIntermediates/MyApp (testing)/BuildProductsPath/Release-iphoneos/Headers/: No such file or directory

I'm assuming that the error corresponds to this line:

cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"

I cannot see any differences in the build settings between Release and Debug.

Update

After some investigation I have determined that when Xcode archives a product it does not create the "headers" folder in ${BUILT_PRODUCTS_DIR}. It instead puts them in `/Build/Intermediates/ArchiveIntermediates/UninstalledProducts'. So the script fails.

Setting the "Skip Install" to NO for the Release build and then checking for the existence of the ${INSTALL_DIR} in the script will successfully build the library.

if [ -d "${INSTALL_DIR}" ]; then
    cp -a "${INSTALL_DIR}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
else
    cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
fi

However, Xcode failed to build because it can't find the headers:

fatal error: 'WindowsAzureMobileServices/WindowsAzureMobileServices.h' file not found
#import <WindowsAzureMobileServices/WindowsAzureMobileServices.h>

Update 2

Setting "Skip install" to no causes archiving issues, see this question: Compile, Build or Archive problems with Xcode 4 (and dependencies)

So I have removed the script that fails in the build phases and added "${PROJECT_DIR}/../azure-mobile-services/sdk/iOS/src" to the "User Header Search Paths" list.

This is messy and not my preferred solution.

Community
  • 1
  • 1
Richard Stelling
  • 25,607
  • 27
  • 108
  • 188
  • I'll have to take a look at the build, I assume you have a workspace and are linking to the .a file? In the meantime, if you have custom changes in the WAMS project you want in your app, you can use the build.command script in the iOS SDK folder to rebuild the framework file and drop that into your app instead. – phillipv Feb 22 '14 at 02:37
  • If you don't have customizations, you can also include the official released builds from http://www.windowsazure.com/en-us/downloads/ – phillipv Feb 23 '14 at 01:24
  • @phillipv Yes, I am using a workspace. I don't have any custom changes to the SDK but I am using a git submodule to keep it up-to-date. I have currently "fixed" the issue by removing the copy headers code in the script an adding `"${PROJECT_DIR}/../azure-mobile-services/sdk/iOS/src"` to the header search paths. – Richard Stelling Feb 24 '14 at 10:21

0 Answers0