I'm looking into cartfile. Can't wait to "simply create a cartfile" like all the instructions say to do.
Only... how do you "simply" create a Cartfile?
I've created a plain text document, named it cartfile and copied some dependencies in it.
Ran carthage update inside my root project directory
Get this error: "No such file in directory"
Downloaded an example carthage project and the Cartfile is actually an executable.. So how do I "simply create" a Cartfile, cause there aren't any instructions on how to
From the command line, navigate to your project directory.
touch Cartfile
Now the Cartfile is created, make it executable with:
chmod +x [YourDirectory/Cartfile]
You can open it with any text editor. Then insert whatever library and source you want (Example: github "SwiftyJSON/SwiftyJSON" >= 2.1.2)
Carthage Tutorial: Getting Started is a must read. It explains things much better than the Carthage documentation does.
Steps
In a Terminal, cd to the root directory of the project that you want to add the framework to. This should be the same directory as your *.xcodeproj file.
cd ~/Path/To/Your/Project/
Create an empty file called Cartfile like this:
touch Cartfile
Open that file with Xcode:
open -a Xcode Cartfile
Paste the framework info that you need into the Cartfile. For example:
github "stephencelis/SQLite.swift" ~> 0.10.1
Close the file in Xcode and in Terminal run the following command to make Carthage update the dependencies in your project. (You should still be in the same directory as your Cartfile.)
carthage update --platform iOS
Notes
Using the method above, there is no need to change the execution permissions of the Cartfile.
You will still need to add the framework link to your project before you can use it. See the tutorial I linked to at the top for more information.
Install by running below command if carthage is not installed.
brew install carthage
if you are using for the first time carthage
download the package first
Download the latest Carthage pkg and of course run it to install it.
and follow above steps
2 In a Terminal, cd to the root directory of the project that you want to add the framework to. This should be the same directory as your *.xcodeproj file.
cd ~/Path/To/Your/Project/
Create an empty file called Cartfile like this:
touch Cartfile
4.Open that file with Xcode:
open -a Xcode Cartfile
5.Paste the framework info that you need into the Cartfile. For example:
github "stephencelis/SQLite.swift" ~> 0.10.1
6.Close the file in Xcode and in Terminal run the following command to make Carthage update the dependencies in your project. (You should still be in the same directory as your Cartfile.)
carthage update --platform iOS
Cartfile is a usual text file without any extensions. You can create it using any possibilities like command line or any applications. This file is case sensitive.
If you create cartfile(from lower case) or Cartfile.txt(with extension) and run carthage update you get something like this:
2021-04-23 17:00:27.692 carthage[94911:3694738] INFO: fetch-response is unable to open the file /Users/alex/Library/Caches/carthage/fsCachedData/F1841822-AACC-4E8A-ACB0-D801D3C72063. Errno: 2
Failed to read file or folder at <some_path>/Cartfile: Error Domain=NSCocoaErrorDomain Code=260 "The file “Cartfile” couldn’t be opened because there is no such file." UserInfo={NSFilePath=<some_path>/Cartfile, NSUnderlyingError=0x7ff8f7727240 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
To check extension
Right click on Cartfile -> Get Info -> [Name & Extension:]
//you are able to remove the extension here
Related
The teams developing frameworks for our iOS app are migrating from Cocoapods to Carthage.
Under Cocoapods, I could set up dependencies as "development pods". For example, instead of having the main app download a specific version of an xyzzy dependency, I could set up xyzzy as a development pod and point it to my local directory where I had checked out xyzzy from its Git repo. While I was working in the main app's project, any edits I'd do to xyzzy's files would be made in that directory. This let me build and test changes immediately, and when I was ready to check them in, Git would find them in the xyzzy project's directory.
Under Carthage I haven't found a way to do this. I see http://allocinit.io/ios/debugging-carthage-dependencies/ which explains how to create symbolic links so that I can see the dependency source files to make debugging easier, but any edits I make to them are under the main application's Carthage/Builds directory.
How do I set up the equivalent of development pods under Carthage?
I believe Carthage doesn't have something similar to "development pods" yet.
But you could simulate "development pods" just following these steps:
Steps:
Add the .xcodeproj to your workspace
Remove all the dependencies you have in your project of the framework you added in step 1. (probably you may need to remove it from Build Phases -> Run Script -> Input Files too )
Go to General tab of the target you want to run, add the framework under Linked Frameworks and Libraries (it is going to take the one added from the .xcoproj)
(optional) you may need to run carthage bootstrap in the framework's repo you want to add locally.
That's it.
After that you will be able to run your project and update framework's code in the same workspace.
This works just as well as development pods for me, as of Xcode 8.3.3 and Carthage 0.24.0:
In app path, rm -rf Carthage
Point at the appropriate branch or tag in Cartfile
carthage update --use-submodules (generates .gitmodules and clones repo into Carthage/Checkouts)
In Xcode under project -> Build Phases -> Run Script, comment out the line that ends with carthage update --cache-builds if present.
Change to the General tab and remove the lib from Embedded Binaries
Right-click project, Add Files to app..., add lib from Carthage/Checkouts
Under project -> General, re-add the library, choosing the one you added in the previous step.
App should now build with the local lib. Make sure that your .gitignore has Carthage/{Build,Checkouts} and .gitmodules.
This answer is a summary of a successful implementation of the solution introduced here.
A cleaner solution is using local paths for dependencies in Cartfile.
Environment
Xcode 10.1
macOS 10.13.6
Step 1. Symbolic linking
1.1 Change $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) directory to a symbolic link pointing to source root directory of your developing framework $(SRCROOT_DEVELOPING_FRAMEWORK), where $(SRCROOT_MAIN) is source root directory of your main app. Backup existing directories before this change.
This linking enables version-controlled changes in your developing framework.
Syntax when using ln utility,
$ ln -s "$SRCROOT_DEVELOPING_FRAMEWORK" "$SRCROOT_MAIN/Carthage/Checkouts/$DEVELOPING_FRAMEWORK_NAME"
1.2 Change $(SRCROOT_DEVELOPING_FRAMEWORK)/Carthage/Build directory in your framework to a symbolic link pointing to $(SRCROOT_MAIN)/Carthage/Build directory. Backup existing directories before this change.
This linking enables access to all frameworks built by Carthage from both your developing framework and your main app.
Syntax when using ln utility,
$ ln -s "$SRCROOT_MAIN/Carthage/Build" "$SRCROOT_DEVELOPING_FRAMEWORK/Carthage/Build"
Step 2. Framework Replacement
2.1 Remove your developing framework in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries (that is, the one located in $(SRCROOT_MAIN)/Carthage/Build/iOS).
2.2 Add $(DEVELOPING_FRAMEWORK_NAME).xcodeproj (found in directory pointed by $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) symbolic link) into your main app
2.3 Build the developing framework product for device and simulator
2.4 Add the new developing framework auto-detected by Xcode in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries.
2.5 Add $(DEVELOPING_FRAMEWORK_NAME).framework as a target dependency by adding $(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Target Dependencies.
2.6 Copy $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework to $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework by adding a new input file $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework and a new output file $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Run Script of Carthage Embed Framework.
Reference
Debugging Carthage Dependencies
https://allocinit.io/ios/debugging-carthage-dependencies/
Build Setting Reference
https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
I've just pulled my latest commits at home, run npm install and then get some issues running react-native run-ios:
xcodebuild: error: The workspace named "Contractor" does not contain a scheme named "Contractor". The "-list" option can be used to find the names of the schemes in the workspace.
When I opened up the .xcworkspace in XCode there's nothing in the project navigator sidebar and no schemes. If I open up the .xcodeproj file, all of my source files are there, so it seems like there's been some disconnect between the workspace and the project?
I'm not really sure where to go from here..
Are you using cocoapods? I ran into the same issue, cd PROJECT_ROOT/ios && pod install fix it for me.
ln: It/BuildProductsPath/Release/Realm/Realm.framework/Headers: No such file or directory
ln: It/BuildProductsPath/Release/Realm/Realm.framework/PrivateHeaders: No such file or directory
I can build & run the project, but when I am trying to archive the project, it shows me this error. I have tried cleaning up the project and deleting derived data, but that didn't help me.
I am using Realm in macOS App. I installed macOS 10.12.1 and tried archiving the project, then this error appeared. It was working fine in previous macOS version.
Please help me to solve this, Thanks in Advance.
I have updated to new cocoa pods [ Dmitry pointed out ], now I am using cocoa pods beta version.
I have installed the beta version using this command sudo gem install cocoapods --pre. Now the pod --version command shows me that the cocoa pods version is 1.2.0.beta.1. Tried archiving the project again, but the same error appears.
This is a CocoaPods issue that was fixed in https://github.com/CocoaPods/CocoaPods/pull/6146.
Please try to update to the latest CocoaPods [beta] version.
Looks like the current beta doesn't include that fix, so for now the workaround I suggest is to simply add missing quotes to your project manually:
Select Pods project in project navigator
Select Realm target -> Build Phases
Find Create Symbolic Links to Header Folders and replace the script to
base="$CONFIGURATION_BUILD_DIR/$WRAPPER_NAME"
ln -fs "$base/${PUBLIC_HEADERS_FOLDER_PATH#$WRAPPER_NAME/}" "$base/${PUBLIC_HEADERS_FOLDER_PATH#$CONTENTS_FOLDER_PATH/}"
ln -fs "$base/${PRIVATE_HEADERS_FOLDER_PATH#$WRAPPER_NAME/}" "$base/${PRIVATE_HEADERS_FOLDER_PATH#$CONTENTS_FOLDER_PATH/}"
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.
I had cocoapods in my project and it worked fine. But now that I upgraded my xCode and everything else, I get a linker error about the pods when I try to archive the project.
I was trying to follow the solutions in this answer but the steps they mention are not quite what I see on my screen.
What are the steps to configure my cocoapods correctly?
Here is a screenshot of how things are appearing for me with the libraries in red on the left side, and some configurations on the main area of the screen.
Make a backup of your .pod config file that has all your third party project references in it. Delete pods folder and delete workspace that Cocopods creates by default.
This is the file to backup
$ sudo gem install cocoapods
Navigate to where project lives:
cd /Users/yourUserFolder/LocationOfProject/
Then Run:
$ pod install
Open Workspace
$ open App.xcworkspace
**Make sure you open the workspace file. Not the .project file.
Image of what my .pod file looks like, just for your reference to make sure you have the correct format.