When updating to Xcode 10, iOS static library target fails to build. Way how I am trying to build it is following:
xcodebuild -target TargetName -configuration Release clean build
With Xcode 9 everything runs smoothly, but when Xcode 10 is used for build, I am getting following error (after clean runs smoothly):
note: Using new build system
note: Planning build
note: Constructing build description Build system information error:
unable to attach DB: error: accessing build database
"/Users/uerceg/random-path/build/XCBuildData/build.db": database is
locked Possibly there are two concurrent builds running in the same
filesystem location.
** BUILD FAILED **
** BUILD FAILED **
The following build commands failed: PhaseScriptExecution
MultiPlatform\ Build
/Users/uerceg/random-path/build/Library.build/Release-iphoneos/LibraryTarget.build/Script-9DE7C9021AE68FA5001556E5.sh
(1 failure)
This probably unrelated, but I noticed that new Xcode 10 build system flags duplicated Copy Bundle Resource Info.plist files as errors, so I did make sure that there're no duplicated entries, but probably this error is not related to this fact.
Does anyone have any idea what might be wrong?
Okay, seems like I managed to solve it. I was having /bin/sh script in Build Phases that was trying to build fat static library. In the script, I had OBJROOT path set like this:
OBJROOT="${OBJROOT}"
Seems like Xcode 10 and new build system changed some paths on the way and this line was the source of the issue. It needs to be adjusted to:
OBJROOT="${OBJROOT}/DependentBuilds"
After that, xcodebuild manages to build this target without issues with new build system introduced in Xcode 10.
I didn't get to this solution by myself, big thanks to Matt Gallagher and his post in here: https://github.com/mattgallagher/CwlSignal/issues/24#issuecomment-396931001
As requested by #TMin in comment, here's how my script looks like:
set -e
# If we're already inside this script then die
if [ -n "$RW_MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then
exit 0
fi
export RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1
RW_FRAMEWORK_NAME=${PROJECT_NAME}
RW_INPUT_STATIC_LIB="lib${PROJECT_NAME}.a"
RW_FRAMEWORK_LOCATION="${BUILT_PRODUCTS_DIR}/static/${RW_FRAMEWORK_NAME}Sdk.framework"
function build_static_library {
echo "1"
echo "${BUILD_DIR}"
# Will rebuild the static library as specified
# build_static_library sdk
xcrun xcodebuild -project "${PROJECT_FILE_PATH}" \
-target "${TARGET_NAME}" \
-configuration "${CONFIGURATION}" \
-sdk "${1}" \
ONLY_ACTIVE_ARCH=NO \
BUILD_DIR="${BUILD_DIR}" \
OBJROOT="${OBJROOT}" \
BUILD_ROOT="${BUILD_ROOT}" \
SYMROOT="${SYMROOT}" $ACTION
}
function make_fat_library {
# Will smash 2 static libs together
# make_fat_library in1 in2 out
xcrun lipo -create "${1}" "${2}" -output "${3}"
}
# 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]; then
RW_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi
# 2 - Extract the version from the SDK
if [[ "$SDK_NAME" =~ ([0-9]+.*$) ]]; then
RW_SDK_VERSION=${BASH_REMATCH[1]}
else
echo "Could not find sdk version from SDK_NAME: $SDK_NAME"
exit 1
fi
# 3 - Determine the other platform
if [ "$RW_SDK_PLATFORM" == "iphoneos" ]; then
RW_OTHER_PLATFORM=iphonesimulator
else
RW_OTHER_PLATFORM=iphoneos
fi
# 4 - Find the build directory
if [[ "$BUILT_PRODUCTS_DIR" =~ (.*)$RW_SDK_PLATFORM$ ]]; then
RW_OTHER_BUILT_PRODUCTS_DIR="${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}"
else
echo "Could not find other platform build directory."
exit 1
fi
# Build the other platform.
build_static_library "${RW_OTHER_PLATFORM}${RW_SDK_VERSION}"
# If we're currently building for iphonesimulator, then need to rebuild
# to ensure that we get both i386 and x86_64
if [ "$RW_SDK_PLATFORM" == "iphonesimulator" ]; then
build_static_library "${SDK_NAME}"
fi
# Join the 2 static libs into 1 and push into the .framework
make_fat_library "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk"
# Ensure that the framework is present in both platform's build directories
cp -a "${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/static/${RW_FRAMEWORK_NAME}Sdk.framework/Versions/A/${RW_FRAMEWORK_NAME}Sdk"
# Copy the framework to the project directory
ditto "${RW_FRAMEWORK_LOCATION}" "${SRCROOT}/Frameworks/static/${RW_FRAMEWORK_NAME}Sdk.framework"
Problem is in build_static_library method in this line:
OBJROOT="${OBJROOT}" \
Changing that line to:
OBJROOT="${OBJROOT}/DependantBuilds" \
solves the issue for me.
Open XCode File->Project Settings
Build System->Legacy Build System
Configure XCode of version 10.0 project settings can solve the problem.
If you use build script to build submodule's libraries like me.
You also need to disable new build system in your build script explicitly by using -UseModernBuildSystem=NO in your xcodebuild command.
For example:
xcodebuild -configuration "${CONFIGURATION}" -project "${PROJECT_NAME}.xcodeproj" -target "${TARGET_NAME}" -sdk "${OTHER_SDK_TO_BUILD}" ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" -UseModernBuildSystem=NO
Deleting the Derived Data worked for me.
See how you can do it: https://programmingwithswift.com/delete-derived-data-xcode/
I have the same issues and try everything from the hints but this error still continues. Sometimes the project is built, next time there is no and error. And the solution that helps me is to edit scheme and switch off Parallelize Build. After that everything works fine.
Use this script it will it is working fine with new build system
# Step 1 search RECURSION and if detected stop "*/
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Step 2. Build Device and Simulator versions
xcodebuild -target logger ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target logger-configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 3. Create universal binary file using lipo
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}universal.a" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a"
# Last touch. copy the header files. Just for convenience
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/include" "${UNIVERSAL_OUTPUTFOLDER}/"
fi
before Xcode 10 build system uses single thread, but in Xcode 10 usees new build system with multiple threads, so every time you run your build Xcode run button this script
xcodebuild -target logger ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}".
will call one more time for build so on, that will create RECURSION
Don't forgot to end you Script With (fi) its end of IF condition
Step 1 is to Detect RECURSION and stop them
If you want to keep the XCode 10 default build system but still running your build outside of the IDE (in a CI machine for instance), just replace your -target parameter for the -scheme parameter in your xcodebuild command like:
xcodebuild -scheme SchemeName -configuration Release clean build
Thanks to this post from 2015 that talks about a very similar problem and it gave me the hint to solve this problem. As the same author says,
I would hazard a guess, that xcodebuild without a scheme goes
wrongly through the "modern build system", giving the mentioned error
Adding a Clean derived data step in my build scripts (before an Xcode build) seems to fix the problem for me.
Not sure if it's related, but my project uses Realm (installed with CocoaPods). This is the GitHub issue that inspired the "fix" -> https://github.com/realm/realm-cocoa/issues/5812.
I encountered this issue when running swift run <your_proj>.
A quick fix can be achieved by deleting the build.db file, along with its sibling files and directories. This may seem trifle, but it worked for me.
I am reposting this because a moderator saw it fit to delete my previous answer.
I encountered the same issues when I upgraded by builds to New Build System because of xcframeworks requirements.
Error: ".....Build/Intermediates.noindex/XCBuildData/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location."
The build was previously working fine when triggered with xcodebuild( )
None of the above/approved answered worked for me.
What worked for me was a switch from xcodebuild( ) to build_app( ) in my Fastlane script.
Hope this answer helps someone in the future.
For me, I just cleaned my project.
Restarted the IDE & rebuilt the project & it worked like a charm.
It could be because you have in your podfile an incompatible version to make sure open the runner.xcodeproj with xcode and see the version then go and see podfile to make sure it is the same and uncomented if not make them the same.
hope this is helpful.
Related
I'm trying to create and use a framework in iOS. It was working previously and it works on the simulator but not a newer iPhone 6.
I suspect it has to do with the script, but from what I can see (I copied the script for the internet for the most part) it does have arm64 in it:
set -e
set +u
# Avoid recursively calling this script.
if [[ $SF_MASTER_SCRIPT_RUNNING ]]
then
exit 0
fi
set -u
export SF_MASTER_SCRIPT_RUNNING=1
# Constants
SF_TARGET_NAME=${PROJECT_NAME}
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Take build target
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]
then
SF_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
echo "Please choose iPhone simulator as the build target."
exit 1
fi
IPHONE_DEVICE_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
# Build the other (non-simulator) platform
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/arm64" SYMROOT="${SYMROOT}" ARCHS='arm64' VALID_ARCHS='arm64' $ACTION
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION
# Copy the framework structure to the universal folder (clean it first)
rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
# Smash them together to combine all architectures
lipo -create "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/armv7/${PROJECT_NAME}.framework/${PROJECT_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
Any idea what I need to do to get this to compile for arm64 so it'll run on an iPhone 6+?
I seem to get this error:
Please choose iPhone simulator as the build target.
Command /bin/sh failed with exit code 1
Which it sounds like has to do with a script not running. Since I don't have any scripts in my test project, I went back to my framework and tried setting it to Run script only when installing and re-built my framework, but that still does not appear to be working.
You can't, unless you have the source code to the framework, and can recompile it. (That is your best solution anyway.) It's really that you are now running 64 bit code, and your framework is compiled only for 32 bit code. I did write a hack that allowed you to use previous versions of arm libraries, but I don't think that hack will survive the jump to larger bit size. You can try it if you want: click for hack.
Your script generates that error message and quits (without generating any libraries) whenever you're not building for the iOS simulator. This is the offending code:
# Take build target
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]
then
SF_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
echo "Please choose iPhone simulator as the build target."
exit 1
fi
Check your architecture and valid architecture and add $(inherited) to Other Linker Flags.
I have a workspace which has 2 projects: One is a Cocoa touch framework and the other is the app which uses the framework.I have added the framework in the embedded binaries section. When I run the app, it compiles the framework and the app and things are fine. However, I need the framework to compile for all architectures and not just the one it is currently being built for. I have searched for this and the most common solution is to add a run script to enable this functionality. However, every run script I have come across is different from one another, so I am confused what is the script that is ideal for this situation? Also, is it a good idea to create a fat binary for this purpose?
I am using the following script at the moment, that I have added to the build phase of the framework (taken from http://www.insert.io/frameworkios8xcode6/):
set -e
set +u
# Avoid recursively calling this script.
if [[ $SF_MASTER_SCRIPT_RUNNING ]]
then
exit 0
fi
set -u
export SF_MASTER_SCRIPT_RUNNING=1
# Constants
SF_TARGET_NAME=${PROJECT_NAME}
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Take build target
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]
then
SF_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
echo "Please choose iPhone simulator as the build target."
exit 1
fi
IPHONE_DEVICE_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
# Build the other (non-simulator) platform
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/arm64" SYMROOT="${SYMROOT}" ARCHS='arm64' VALID_ARCHS='arm64' $ACTION
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION
# Copy the framework structure to the universal folder (clean it first)
rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
# Smash them together to combine all architectures
lipo -create "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/armv7/${PROJECT_NAME}.framework/${PROJECT_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
This script requires that the framework be built for iOS Simulator. After building the the .framework in the Products folder in my workspace shows that the framework is in iphoneos folder instead of the Universal folder. Should I drag the .framework from the Universal folder into the Products section in the worksapce?
I don't know about having the framework project and the app project in the same workspace, however you can see my answer here on how I did this. I didn't have to put the framework in embedded binaries. I only had to put in Linked Frameworks and Libraries. I just set up a build script that when I build for a Generic iOS Device, it builds a Fat Framework to my desktop. I can then run the -lipo info command to confirm this is actually a fat framework. From there I put the framework in my Linked Frameworks and Libraries in my app.
What it worked for me was the following complete tutorial:
https://github.com/jverkoey/iOS-Framework
There you can see the benefits of using a Cocoa Touch static Library based Framework over a Static iOS Framework. It really is an open discuss, but I am only telling you my positive experience with it in a production environment.
The important command you have to care about is the lipo one. It's the one who will smash the binaries into a fat one. With that command you can easily check if the result contains the architectures you wanted or not. If not, check first this and then ensure you follow the instructions of the guide above.
Once you create the static library you can run the following command to check the architectures:
lipo -info YourLibrary.framework/YourLibrary
This solutions also allows you to include the framework as a dependent target to your project making your Framework development much easier. For that purpose check this chapter of the guide.
The following script is part of an aggregate target build phase that is supposed to be used to combine simulator and device targets into one universal framework build. The build originated from this SO answer.
set -e
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
echo "PROJECT_NAME: ${PROJECT_NAME}"
echo "CONFIGURATION: ${CONFIGURATION}"
echo "BUILD_DIR: ${BUILD_DIR}"
echo "SIMULATOR_LIBRARY_PATH: ${SIMULATOR_LIBRARY_PATH}"
echo "DEVICE_LIBRARY_PATH: ${DEVICE_LIBRARY_PATH}"
echo "UNIVERSAL_LIBRARY_DIR: ${UNIVERSAL_LIBRARY_DIR}"
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
Here is the first error I get when executing this script:
PROJECT_NAME: My-project_Framework
CONFIGURATION: Debug
BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products
SIMULATOR_LIBRARY_PATH: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_Framework.framework
DEVICE_LIBRARY_PATH: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos/My-project_Framework.framework
UNIVERSAL_LIBRARY_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneuniversal
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator
SDKROOT = iphonesimulator8.1
=== CLEAN TARGET My-project_Framework OF PROJECT My-project_Framework WITH CONFIGURATION Debug ===
Check dependencies
Create product structure
/bin/mkdir -p /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
Clean.Remove clean /Volumes/local\ my-project/my-project/ios/Framework/build/My-project_Framework.build/Debug-iphonesimulator/My-project_Framework.build
builtin-rm -rf /Volumes/local\ my-project/my-project/ios/Framework/build/My-project_Framework.build/Debug-iphonesimulator/My-project_Framework.build
Clean.Remove clean /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
builtin-rm -rf /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
** CLEAN SUCCEEDED **
=== BUILD TARGET My-project_Framework OF PROJECT My-project_Framework WITH CONFIGURATION Debug ===
Check dependencies
error: Unable to create directory: /Volumes/local my-project/my-project/ios/Framework/build (Permission denied)
Now here is the problem
This mount point, /Volumes/local my-project (with a space) has been replaced with /Volumes/localmy-project (without a space). Yet XCode still seems to have the old path somewhere.
Here's what I did to try rip it out of XCode (version 6.1.1):
Added the echo calls to the script to show all the command line inputs to xcodebuild. As you can see this path doesn't come in from the command line call.
Cleaned all targets (Choose each target, Product->Clean).
Checked all the files included in this framework project - all of them have location set to Relative to Project in the inspector.
Restarted XCode.
Restarted the Mac.
Checked project.pbxproj and all other XML files found in the project package contents - no absolute path to be found.
Checked the target in the inspector - its location is absolute (cannot be changed) and correctly points to the new path (/Volumes/localmy-project/...)
Went into the organizer and went Projects->My-Project->Derived Data->Delete.
After all this, the error still persists. So - where the hell is XCode getting this old path from?
Update
I've added the following echos to show a few more build environment variables according to #Louis Tur:
BUILT_PRODUCTS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
CACHE_ROOT: /var/folders/w1/v31fpgnd7sl0yp5ctqjgsxsh0000gn/C/com.apple.DeveloperTools/6.1.1-6A2008a/Xcode
CONFIGURATION_BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
CONFIGURATION_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-Project_Framework.build/Debug-iphoneos
SYMROOT: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products
Update2 - Now with even more echos!
DEPLOYMENT_LOCATION: NO
DERIVED_FILE_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/DerivedSources
DSTROOT: /tmp/My-project_Framework.dst
INSTALL_DIR: /tmp/My-project_Framework.dst
INSTALL_PATH:
OBJECT_FILE_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/Objects
OBJECT_FILE_DIR_normal: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/Objects-normal
OBJECT_FILE_DIR_debug:
OBJROOT: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates
PROJECT_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build
REZ_COLLECTOR_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/ResourceManagerResources
REZ_OBJECTS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/ResourceManagerResources/Objects
SHARED_PRECOMPS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/PrecompiledHeaders
SRCROOT: /Volumes/localmy-project/my-project/ios/Framework
TARGET_BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
TARGET_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build
Still none of these point to the old path then..
I encountered this problem and solved by reset the Location of Derived data folder in Xcode preference.
After setting, I quit Xcode and relaunch again. It solved.
I still don't know how that old path is coming in, but I've found a workaround that works for me: I can force the correct DerivedData path by using xcodebuild the following way (which replaces the old calls in the script):
xcodebuild -scheme ${PROJECT_NAME} -derivedDataPath ${BUILD_DIR}/../../ -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
xcodebuild -scheme ${PROJECT_NAME} -derivedDataPath ${BUILD_DIR}/../../ -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
If anyone has an idea where the old path could still persist, please let me know.
This is the first time I have ever tried to create a custom iOS Framework. I'm trying to create custom iOS Framework using xCode by following this tutorial. I have gotten all the way to the very last step (Step 12).
Step 12: Build Project with Aggregate scheme
Select Aggregate("UniversaliOS") Scheme
Select iOS device
Build Project (⌘-B)
But the build fails with a Shell Script Invocation Error: Command /bin/sh failed with exit code 1. The error details are:
ditto: can't get real path for source
lipo: can't create temporary output file: /Users/pdl/Library/Developer/Xcode/DerivedData/InnerID-iOS-SDK-dgyjuudeootshidhpzlejhbyqvco/Build/Products/InnerID-iOS-SDK-Bundle.framework/InnerID-iOS-SDK-Bundle.lipo (No such file or directory)
Command /bin/sh failed with exit code 1
I have absolutely no clue as to what to do now. Any suggestions? I can provide the PhaseScriptExecution dump if necessary.
Thank you in advance for your help.
This is the correct shell script to be used (for swift).
CONFIG=Release
# Step 1. Make sure the output directory exists
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIG}-universal
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 2. Build Device and Simulator versions
codebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIG} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIG} -sdk iphonesimulator -arch x86_64 -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 3. Copy the framework structure to the universal folder. Subsequently copy the files of the swiftmodule (in Modules directory) of -iphonesimulator to the swiftmodule of universal framework directory.
cp -R "${BUILD_DIR}/${CONFIG}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
cp -R "${BUILD_DIR}/${CONFIG}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIG}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIG}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
If you still have any doubts, you can look at the video tutorial.
You didn't compile your iOSBundle for both(Step 10) and directly attempt to merge both iOS simulator and device(Step 12).
Basically what Step 10 is doing?
Its's just creating Framework for both Simulator and Device, So for some reason your build folder gets empty and your script not able find framework for iOS-Simulator and Device both or any one.
Quick resolution :
Perform Step 10, one more time before Step 12, this will create iOS-simulator Framework and Device Framework both, After that build project for your Aggregate scheme, this will merge both framework.
You can find all three(iOS-Simulaor, Device, Merged) framework at below
/Users/jaym/Library/Developer/Xcode/DerivedData/iOSFramework-doeqysadgntrrlguuvcivuhapnlr/Build/Products/
In your case, /Users/pdl/Library/Developer/Xcode/DerivedData/InnerID-iOS-SDK-dgyjuudeootshidhpzlejhbyqvco/Build/Products/
I'm trying to create a universal framework for iOS and I have "Add Copy Files" build phase in my aggregate target which tends to behave unexpected (copy some of the files at target location), can you tell me if this can be resolved somehow?
I have added 3 files in this copy build phase...
After the build is done, this is what I see build log..
The result is not consistent - sometimes all (3) files get copied but most times it copies only few files to the target location. The build log doesn't give any error/warning for this (copy) phase.
Most probably it's an issue with Xcode. Any workaround/idea to get around this problem is highly appreciated since i need to build the project multiple times in a day (to save time).
Updates/Edits
If I don't edit any of 3 header files added (+) in 'add copy files' after last build then none of the files is copied inside framework folder on build (cmd+B).
Below are the scripts used in targeted build phases-
Script 1: Build static lib
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
Script 2: Build universal framework
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a" &&
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" &&
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal" &&
UNIVERSAL_LIBRARY_PATH="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}" &&
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}.framework" &&
# Create framework directory structure.
rm -rf "${FRAMEWORK}" &&
mkdir -p "${UNIVERSAL_LIBRARY_DIR}" &&
mkdir -p "${FRAMEWORK}/Versions/A/Headers" &&
mkdir -p "${FRAMEWORK}/Versions/A/Resources" &&
# Generate universal binary for the device and simulator.
lipo "${SIMULATOR_LIBRARY_PATH}" "${DEVICE_LIBRARY_PATH}" -create -output "${UNIVERSAL_LIBRARY_PATH}" &&
# Move files to appropriate locations in framework paths.
cp "${UNIVERSAL_LIBRARY_PATH}" "${FRAMEWORK}/Versions/A" &&
ln -s "A" "${FRAMEWORK}/Versions/Current" &&
ln -s "Versions/Current/Headers" "${FRAMEWORK}/Headers" &&
ln -s "Versions/Current/Resources" "${FRAMEWORK}/Resources" &&
ln -s "Versions/Current/${PRODUCT_NAME}" "${FRAMEWORK}/${PRODUCT_NAME}"
I seriously need to fix the underlying real issue to automate the build (avoid workarounds mentioned in my answer). Thank you.
I found that one of the workaround is - just open and save all the files you included in the copy build phase and then build (Cmd+B). (just make the file dirty by adding a space so that modified date is updated)