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

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.

Related

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

Swift private Framework with backward xcode version compatibility

This is my first framework using Swift language and it's private framework. It's worked as expected until new Xcode 9.3 release. After upgrading newer Xcode got an issue like this Module compiled with Swift 4.0.3 cannot be imported in Swift 4.1.
After that only I realized framework doesn't support auto version (Xcode/Swift) upgrade, Did some search found there is a Universal or Fat Binary Framework single build instead of separate build for real device and simulator which I missed in previously.
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Next, work out if we're in SIM or DEVICE
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos 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
BUILD_PRODUCTS="${SYMROOT}/../../../../Products"
cp -R "${BUILD_PRODUCTS}/Debug-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_PRODUCTS}/Debug-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}"
fi
At Edit Scheme -> Archive -> Post-Action -> Run Script
This time I am used Swift Compiler - Language -> Swift 3.3
And I got expected output this time too in Xcode 9.3 with Swift 4.1
When I try to run the project with this framework at Xcode 9.2 it's show error like this
Module compiled with Swift 4.1 cannot be imported in Swift 3.2.3:
Try to resolve with backward compatibility and I didn't find. How can I run this framework in Xcode 9.2
Framework support: Swift and Objective C, Min OS iOS 8.0
**Update**
Also got something like this error
compiled with newer version of Swift language (unknown ABI version 0x06) than previous files (4.0) file 'MAC location' for architecture armv7
And tried this to my project

Module compiled with swift 4.0 cannot be imported in swift 3.1 — Carthage

I wanted to test my app using Xcode 9 beta. Now I am back to Xcode 8 and I have the following error:
Module compiled with swift 4.0 cannot be imported in swift 3.1
To solve this error I refresh all Carthage build and made some cleaning:
removed all Carthage build and checkout
removed Derived Data directory
cleaned the project
run carthage update
But the error still here.
Carthage
The command used is: 'carthage update --platform iOS'
As the problem lie on always the same framework, DeviceKit I then manage to remove it from Cartfile.
Project build then show errors as DeviceKit is not found.
I then re-add it to Cartfile and run carthage update DeviceKit --platform iOS --no-use-binaries
And the error re-appear.
This related question bring answer but for Cocoapods: Module compiled with swift 4.0 cannot be imported in swift 3.1
Solved by the following steps:
delete some Derived Data for Carthage: rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData
delete the Carthage folder for your project
Update Carthage: carthage update --platform iOS
I found the answer on the dedicated Carthage' page on GitHub: https://github.com/Carthage/Carthage/issues/2062

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.

Swift fat framework w/Objective-C Cocoapod

I've built a framework in Swift. The framework uses Cocoapods, one of the pods is written in Objective C.
I also use a custom script to make the framework a fat framework so it supports 32/64 bit systems. (This runs in a separate target on the project and I'm wondering if that has something to do with it?)
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
// 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) to the copied framework directory
cp -R "${BUILD_DIR}/${CONFIGURATION}-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}/${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}"
fi
When I create this fat framework and put it into a project I'd like to use it on the compiler always fails b/c the project can't see the objective C cocoa pod module.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: framework not found Pusher for architecture x86_64
It is not found for any architecture when I change the build platform.
Any solution where I can produce a framework that I can use in a separate Xcode project (for all iOS or OS X) would be awesome.
You can't run xcodebuild with -target when using CocoaPods. When you use -target, Xcode will only consider the active project and fail to pull in the Pod dependencies, similar to if you just opened the project file in Xcode and tried building.
You should be running xcodebuild -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${PROJECT_NAME}" ..., assuming that CocoaPods generated the workspace and Xcode generated a scheme using the target name. You will also need to make sure your scheme is marked as shared if running this on another device.
Once your framework is built you will need to include it and the frameworks it depends on in apps that will be using it. For your framework, that means including it in General > Embedded Binaries and General > Linked Frameworks and Libraries. For frameworks you depend on, (e.g. AlamoFire), you could instruct users to include it in their Podfile, you could package it and ship it along with your framework, or you could do both and let the user do what works for them.
Apparently you are missing the 64bit architecture for Simulator.
When you build a target from Xcode, depending on what kind of simulator you have selected - the produced library will contains i386 or x86_64 respectively for selected 32bit or 64bit version of the simulator.
I guess that the cli build is producing only i386 version.
You can try to set the architectures in the script:
xcodebuild -target "${PROJECT_NAME}" ARCHS="i386 x86_64" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
As an alternative You can try to build by hand using 64bit simulator (iPhone 5S +), then extract the missing architecture and then put it into the final library using lipo command.