xcodebuild fails to create Archive due to SymLink error with Alamofire - iphone

This is really winding me up now, all I am trying to do is an Xcode CLI build using the Xcode command line tools.
The flow is as follows:
App Code is cloned from Git
Info Plist and my own custom plist are generated and copied to project folder
A new app icon set copied over into the assets directory
Xcode Archive build is executed
Xcode generate IPA build is executed
The issue is the Archive part keeps failing, and I cannot get it working. Annoyingly it works fine if I open the project in Xcode and Archive it through there, but that defeats the point of this automated process.
This is the command xcodebuild -verbose -scheme EpicHRV1.1.0 -archivePath ios/app.xcarchive archive
And here is the constant resultant error. I really can't figure out what its complaining about, I mean, it says something to do with Alamofire and missing modules, but why would this work in Xcode but not the command line?
Command failed: xcodebuild -verbose -scheme EpicHRV1.1.0 -archivePath ios/app.xcarchive archive
2017-01-07 20:24:04.255 xcodebuild[43780:2460638] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-11754/DVTFoundation/Utilities/DVTFileSystemUtilities.mm:142
Details: lstat('/Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Modules') failed with errno 2 (No such file or directory)
Function: DVTRecursiveMkdirResult dvt_recursiveMkdir_returningErrorString(NSString *__strong, NSString *__autoreleasing *)
Thread: <NSThread: 0x7f90e8ae7cf0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** ARCHIVE FAILED **
Here is another lovely error which also randomly appears, but not every time...
The following build commands failed:
SymLink /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/BuildProductsPath/Release-iphoneos/Alamofire.framework /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework
And another error that sometimes appears. With all of the above the only consistent thing is Alamofire is mentioned in the error..
The following build commands failed:
Strip /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Alamofire

So I solved it with the following commands:
xcodebuild -scheme EpicHRV1.1.0 -archivePath ../ios/app.xcarchive archive
xcrun xcodebuild -exportArchive -exportOptionsPlist exportPlist.plist -archivePath ../ios/app.xcarchive -exportPath ../ios/ipa/

Related

Error While creating Custom Framework and xcframework

I am creating a Framework where i am adding multiple Third Party Libraries manually. and creating a Fat framework SomeFrameworkName.framework using the script below
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# 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}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Convenience step to open the project's directory in Finder
open "${PROJECT_DIR}"
After Archiving i am able to get the framework file but when i try to add that framework into the demo project it gives me multiple errors as follows:
dyld: Library not loaded: #rpath/TestIOS.framework/TestIOS
Referenced from: /private/var/containers/Bundle/Application/E76B5EA8-2E7C-44A4-BDCC-A8AB0B37E500/TestAshishDemo.app/TestDemo
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
or else any library names comes in the picture.
and whenever i try to create the xcframework file i get the following error
Failed to build module from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
i am on a crucial stage to solve this error. Anyone if facing the same issue or faced the same along the way they created framework Please Help me out
XCode Version - 12.5.1
In your target project, did you try to embed the Framework ?
(Old XCode screenshot of mine here)

Build Failed Task failed with exit code 65

I am working on a project that uses Carthage, it’s been a couple of months since the last time the project was opened. Now I am trying to move dependencies to .xcframeworks because with the old .framework, it wasn’t working. I encountered various errors and fixed them but there’s one dependency that I can’t fix, 

SwinjectStoryboard
.

I tried using this workaround and setting command line tools
I have also tried creating an empty project with only Swinject and SwinjectStoryboard dependency
but still, my build is failing with the following message
Build Failed Task failed with exit code 65: /usr/bin/xcrun
xcodebuild -project
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard/SwinjectStoryboard.xcodeproj
-scheme SwinjectStoryboard-iOS -configuration Release -derivedDataPath /Users/abu/Library/Caches/org.carthage.CarthageKit/DerivedData/12.5_12E262/SwinjectStoryboard/2.2.0
-sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO
-archivePath /var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/SwinjectStoryboard
SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO
CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO
FRAMEWORK_SEARCH_PATHS=$(inherited)
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcframework-HTlC
(launched in
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard)
This usually indicates that project itself failed to compile. Please
check the xcodebuild log for more details:
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcodebuild.Tafjce.log
I am running the following command to build the dependencies
carthage.sh update --use-xcframeworks --platform iOS
here's my contents of my Cartfile
github "Swinject/Swinject"
github "Swinject/SwinjectStoryboard"
I am stuck on this problem for a couple of days now and would appreciate any help

ObjectMapper: Module compiled with Swift 4.2 cannot be imported in Swift 4.1.2:

I am facing this issue on Xcode 9.4.1
I tried with
github "Hearst-DD/ObjectMapper" ~> 3.1.0 //(tried with 3.3.0)
but this error.
Module compiled with Swift 4.2 cannot be imported in Swift 4.1.2 comes every-time.
I tried below things:
Deleting the .resolved file
Deleted the build and checkout folder
Deleted the framework folder from builds inside cathage
tried with carthage bootstrap --platform iOS.
Updated: Below error keep on coming.
Build Failed Task failed with exit code 65: /usr/bin/xcrun
xcodebuild -workspace
/Users/xx/Documents/tal1.14.1/Carthage/Checkouts/mixpanel-swift/MixpanelDemo/MixpanelDemo.xcworkspace
-scheme Mixpanel -configuration Release -derivedDataPath /Users/xx/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4.1_9F2000/mixpanel-swift/v2.5.4
-sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath
/var/folders/82/_m5xwhxx4795wyxlhtw40ch509_hqq/T/mixpanel-swift
SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO
CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in
/Users/xx/Documents/tal1.14.1/Carthage/Checkouts/mixpanel-swift)
This usually indicates that project itself failed to compile. Please
check the xcodebuild log for more details:
/var/folders/82/_m5xwhxx4795wyxlhtw40ch509_hqq/T/carthage-xcodebuild.2MxUDl.log
BLDM3295-MAC:tal xx$
You need to do carthage bootstrap --no-use-binaries to make Carthage compile the frameworks locally, using the Swift 4.2 compiler that your project uses.
To fix what I did, I was having success build in Jenkins Server I kept the the same version and copied the build project and framework for the same. then run
carthage bootstrap platform iOS
I know this something hack, but this is how I am able to solve.

Uber SDK installed but can't be import in project using COCOAPOD

I want to use uber SDK in my project .i am using Xcode 8.3.3
I have installed it with cocoa pod method. it includes user scripts in the project but doesn't import its library in the project. I have also tried cartage method but it shows
"* Fetching rides-ios-sdk
Fetching ObjectMapper
Downloading rides-ios-sdk.framework binary at "v0.6.0"
Checking out rides-ios-sdk at "v0.6.0"
Checking out ObjectMapper at "1.5.0"
* xcodebuild output can be found in /var/folders/hc/bcjcqz9x2hb84g5_2786z85w0000gn/T/carthage-xcodebuild.vE5KMz.log
*** Building scheme "ObjectMapper-iOS" in ObjectMapper.xcworkspace
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -workspace /Moghees/Driver_APP/Carthage/Checkouts/ObjectMapper/ObjectMapper.xcworkspace -scheme ObjectMapper-iOS -configuration Release -derivedDataPath /Users/mac/Library/Caches/org.carthage.CarthageKit/DerivedData/ObjectMapper/1.5.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build (launched in /Moghees/Driver_APP/Carthage/Checkouts/ObjectMapper)
This usually indicates that project itself failed to compile. Please check the Xcode build log for more details: /var/folders/hc/bcjcqz9x2hb84g5_2786z85w0000gn/T/carthage-xcodebuild.vE5KMz.log"
Help me out.

(iphone) build xcode4 project from command line

I've used to build my project with
xcodebuild -proj MyProject.xcodeproj -target MyTarget - configuration Debug -sdk iphonesimulator4.3
this works(it builds fine) but when I hit run in xcode, it recompiles.
(with xcode3, there was no need to rebuild once I build using command line)
I suspect xcode build use workspace/scheme rather than project/target.
How do I find out the workspace name that my current xcode project is using?
Thank you
edit
Chetan's links gave me directions what to look for.
xcode4 stores build output in ~/Library/...
whereas xcodebuild -project .. saves build output in project's build directory.
(if you want the workspace capability, you can't use the build directory for build output)
I created a workspace containing my project and ran
xcodebuild -workspace myWorkSpace -scheme myScheme
this saves build output in ~/Library/...../Debug-iphoneos
whereas xcode4 run button from the same workspace and same scheme saves output in
~/Library/..../Debug-iphonesimulator
any guess on why xcodebuild command uses Debug-iphoneos? :(
edit2
xcodebuild -workspace myWorkSpace -scheme myScheme -sdk iphonesimulator4.3
specifying sdk solved it
I know it isn't strictly the answer to your question, but you can configure the output directory of your build using the CONFIGURATION_BUILD_DIR environment variable.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1