I keep getting linker error when running my project on circleCI saying that realm framework is not found. I have no problem with the framework on my development environment. I have checked the framework search path to include both $(inherited) and carthage build folder ($(PROJECT_DIR)/Carthage/Build/iOS). Below are the content of both my cartfile and circle.yml (circleCI's configuration file)
cartfile
github "Alamofire/Alamofire" ~> 3.4
github "Alamofire/AlamofireImage" ~> 2.0
github "SwiftyJSON/SwiftyJSON" ~> 2.3.0
github "SnapKit/SnapKit" >= 0.15.0
github "realm/realm-cocoa"
circle.yml
machine:
xcode:
version: "7.3"
dependencies:
pre:
- curl -O https://gist.githubusercontent.com/cabeca/cbaacbeb6a1cc4683aa5/raw/8e17f39f5a7413fd0559c9e6808e01b6fb514422/simulator_populator
- ruby ./simulator_populator
- carthage update --platform iOS
The 2 lines before carthage update are suggested by circleCI support tech to avoid issues with tvOS framework. I have also tried switching carthage update to carthage bootstrap with the same result. Below are the error message I get
From the screenshot it seems like the error occurs when it tries to link test files, but both test and uitest files are default created by xcode, I haven't added anything on it yet
but both test and uitest files are default created by xcode, I haven't added anything on it yet
I think that's the problem here. You need to make sure that both targets can find the framework via the build setting FRAMEWORK_SEARCH_PATHS. This should include the parent directory of the relevant frameworks, e.g. $(SRCROOT)/Carthage/Build/iOS. You can achieve that usually by dragging or adding the framework(s) to the "Link Binary with Libraries" build phase.
You need
carthage bootstrap --platform iOS
not
carthage update --platform iOS
Related
After Xcode auto update to version 13.2.1, I can't build project with Carthage dependencies manager.
With one framework got from here: https://gitlab.com/trustpayments-public/mobile-sdk/ios
I get the error following:
Module compiled with Swift 5.5 cannot be imported by the Swift 5.5.2 compiler
I tried rebuilding framework and set Build libraries for distribution flag in project settings to No but it returned the error that bridging headers are not allowed.
Any ideas ?
P.S. I managed to build the app with CocoaPods, but environmental requirements force me to remain with Carthage in my iOS project.
OK, I managed to compile my project.
Steps to do:
Remove ../Carthage/Build folder
Run xcodebuild -version and check is it the newest one.
Run carthage build --platform ios --use-xcframeworks --no-use-binaries
I'm trying to convert an open source project that I do not own to use Carthage so I can include it as a dependency. I added a new scheme and have made that scheme Shared. I checked it in to my local git repo of the source. This is in my Cartfile:
git "file:///Users/crystaltwix/Projects/plcrashreporter" "shared-scheme"
When I try to run
carthage update --platform iOS
I do see that Carthage checks out plcrashreporter with the correct git hash, but the error I get is
*** Skipped building plcrashreporter due to the error:
Dependency "plcrashreporter" has no shared framework schemes for any of the platforms: iOS
Is there something else that needs to be done in order to have a framework be available through Carthage?
I did integrate the plcrashreporter framework with Carthage, but since the project is quite obsolete, I had to fork a pull request which is this one:
https://github.com/plausiblelabs/plcrashreporter/pull/9
as you can see, there are many commits there (#34), some related specifically to Carthage, some others for cleanup and fixing the targets.
You can find the repo here:
https://github.com/feelform/plcrashreporter
My test (you may find it here) has the following:
Cartfile: github "feelform/plcrashreporter"
In build settings, Run Script:
/bin/sh: /usr/local/bin/carthage copy-frameworks
Input files: $(SRCROOT)/Carthage/Build/iOS/CrashReporter.framework
Output files:$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/CrashReporter.framework
I have an application which was developed in Xcode 7.3 and Swift 2. Now I am trying to convert it to Swift 3.0.2, as the dependency manager I am using is Carthage. Now I am updating my Carthage so that all the frameworks should support swift 3.0.2. For this, first I have used the following command:
"carthage update --platform iOS"
It now fetches all the dependencies and check out all the dependencies but then after checkout it starts to build the dependencies and while building the dependency it just fails with an error.
Here is a attached screenshot of the error. I am totally blank on what I am missing in this case:
When I faced the problem , this is how I resolved it:
I deleted everything that was checked out and got all new fetches and builds
Ran carthage update --no-build && carthage bootstrap
This problem mainly occurs in Xcode 7.3 beta2 (7D129n) toolchain. Carthage version0.12 will build the cartfile successfully if you set xcselect to 7.2.1.
Version v0.11 didn't have this problem. The problem occurs during the build, maybe because all the versions of Carthage dependencies don't match too. I also read a few posts which asked me to supply with sudo carthage update --platform iOS --no-use-binaries.
And you're using a really old version of Xcode. I'll suggest you to upgrade.
I ran carthage bootstrap --platform iOS and got "Skipped installing realm-cocoa.framework binary due to the error: Incompatible Swift version - framework was built with 3.1 and the local version is 4.0", and then at the end of the build I got a full on "Build Failed: Task failed with exit code 65" error.
It points me to the derivedDataPath, and I checked the xcodebuild log for more details where it let me know "PhaseScriptExecution Download\ Core\ and\ Sync /Users/user/Libary/Caches/org.carthage.CarthageKit/DerivedData/9.0_9A###/realm-cocoa/v2.10.2/Build/Intermediates.noindex/Realm.build/Release-iphoneos/Realm.build/Script-X#X#X#X#X.sh (1 failure)".
But I'm still not totally sure what exactly is happening with Realm Cocoa, or how to fix, do you know?
TL;DR: Ensure you're using the latest Swift version, included with Xcode, and then perform carthage bootstrap --no-use-binaries --platform iOS --cache-builds
Long version:
The error you got from Xcode while building your project, Incompatible Swift version - framework was built with 3.1 and the local version is 4.0, is due to a download performed by Carthage to get a pre-built version of Realm Framework (this is a time-saver feature but sometimes there are version incompatibilities like this one).
This downloaded pre-built framework was compiled with a previous version of Swift (in this case the error is pointing v3.1 was used.) The solution for this error will be to perform the dependencies installation process using a different command:
carthage bootstrap --platform iOS --no-use-binaries
This will work for the project dependencies build to succeed. Anyway this might take a long time since it will build from scratch the Realm.framework and RealmSwift.framework from the core every time the command is executed. So it is possible to enable a local cache for the builds on Carthage. The dependencies can be installed with
carthage bootstrap --no-use-binaries --platform iOS --cache-builds
With this options Carthage will:
bootstrap, so the versions in the Cartfile.resolved will be used, no updates.
--no-use-binaries build the dependencies with no downloads of pre-built frameworks (avoiding the version incompatibility.)
--platform iOS will build the dependencies for be used only on iOS, avoiding building frameworks for Apple TV or Mac OS in case the dependency supports it. This will cut a lot of time!
--cache-builds will enable Carthage to store your built dependencies (and use it when re-needed) on a local cache, so even if you perform the command again it will just copy your stored framework, avoiding another time consuming build process.
Check your application folder and Switch your Xcode version to older version with swift 3.
sudo xcode-select --switch /Applications/Xcode.app
I recently added SwiftyJSON into my xCode project using Carthage.
Cartfile
$ cat Cartfile
github "SwiftyJSON/SwiftyJSON" >= 2.1.2
I ran this command to install SwiftyJSON
$ carthage update
I added the built Framework to my xCode project
I imported the Framework at the top of my project
But I still get this error:
Use of unresolved identifier 'JSON'
Seriously, what am I doing wrong? I'm new to iOS development.
UPDATE: I tried removing the Frameworks and re-dragging the frameworks to the Linked Frameworks and Libraries and Adding the "Run Script" section to "Build Phases" as the instructions in Carthage asked.
I'm convinced that something went awry during the Carthage Update process because I received this error on my initial attempt:
$ carthage update
*** Fetching SwiftyJSON
*** Fetching Alamofire
*** Checking out SwiftyJSON at "2.1.3"
*** Checking out Alamofire at "1.1.4"
*** xcodebuild output can be found in /var/folders/0x/swzt630n3_575tglljpwhn4h0000gn/T/carthage-xcodebuild.Pc6rLg.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
After looking up the problem, I was told that you could run
carthage update --configuration Debug
Which installed it fine, but something is still amiss...
It seems like you missed a step during the addition of SwiftyJSON and Alamofire frameworks from Carthage. Check out these steps from the Carthage readme page :
Steps :
Create a Cartfile that lists the frameworks you’d like to use in your project.
Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder, then build each one.
On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.
On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
$(SRCROOT)/Carthage/Build/iOS/SwiftyJSON.framework
Looks like you missed step 4. I tried these steps myself in a demo Swift project and they are working great. Try these steps out, and if you still have problems, leave a comment. Thanks!
I switched over to Cocoapods and it just worked. Again, I'm a total noob when it comes to iOS development. When looking for a dependency manger I looked at Cocoapods and Carthage for what they had to offer. I was intrigued by Carthage's claim of keeping things simple:
"Carthage because we wanted the simplest tool possible—a dependency manager that gets the job done without taking over the responsibility of Xcode"
While I always will choose the simpler tool when given a choice, I think I don't know enough of the iOS ecosystem (read: Xcode) to use Carthage.
TL,DR: Can't use it inside of Emulator, Use iPhone.
I also followed your way, and I found out that --configuration debug will code-sign "iOS Developer" identity as SwiftyJSON's project property.
AFAIK, Code-signed "iOS Developer" identity wasn't run with Emulator.
My issue was resolved when I run it at my iPhone 6.
I do not know why you can not add this resource with help of Carthage but if you need use SwiftyJSON you only need:
Enter this URL: SwiftyJSON
Clic the button "Clone or download" and then in "Download ZIP" like the next image shows:
Clic the button "Clone or download" and then in "Download ZIP" IMG
You will get a ZIP file with name "SwiftyJSON-master"
Extract the files
Enter the path:
SwiftyJSON-master/Source/
You will see a file with name:
SwiftyJSON.swift
Copy that file into the files of your project.
Add that file into your project directory.
That file will be like other class into your project that you may use.