No shared framework schemes - ios

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

Related

How to verify information in Carthage.resolved?

Cocoapods embed a step in the build phase to check if the Pods folder is in sync with the versions in Podfile.lock. This blocks the developer to work with the stale versions of the Pod with the following error:
error: The sandbox is not in sync with the Podfile.lock. Run 'pod
install' or update your CocoaPods installation.
Carthage has Cartfile.resolved, but how is it used to check if the Carthage Builds are fresh vs stale? Is it something that has to be manually enforced via some script?
Afaik the Carthage guides do not mention this topic at all. Usually you will be informed via failing compilation that a certain framework is not found, e.g. if you switched to a new branch where a new feature is implemented that needs framework XYZ. Then you know you have to run carthage bootstrap.
We have a script that runs so fast that you could even place it into the git hooks so it runs automatically after switching branches. The carthage part just cann the following command:
carthage bootstrap --use-ssh --use-xcframeworks --cache-builds
It makes sure carthage is up to date and it is fast since it uses cached builds. Runs fine for several years now.

Is it possible to distribute binary ios framework using carthage

Please bear with me because I spent considerable amount of time on this. I am also relatively a beginner with swift and iOS.
What I did
- built a framework using cocoa touch
- clean, build and it succeeds without a problem.
- made the scheme shared
- did carthage build --no-skip-current
- did carthage archive
- copied only the zip file to a fresh new directory and uploaded with release in git.
- In a different project tried to pull the framework using carthage
and I get the error Dependency "xxx-ios" has no shared framework schemes then I copied the scheme directly and pushed it in the git along the zip. nothing. Tried without the zip together with the scheme. nothing.
Then I created a fresh framework and I did carthage build --no-skip-current and I uploaded the whole thing in the project folder to git. That pulls properly with carthage. Then I removed some part of that folder so that the scheme inside .xcodeproj and the carthage build folder remain, then I get a different error. At this point it got me thinking if carthage does support binary framework distribution.
In my company, they want it so that I don't expose the code - so I am trying to distribute built binary of the framework.
I would really appreciate any help or guides of what different things I could try to single out the problem. Thanks.
Edit
someone had almost exactly the same issue as mine in their issues here but a couple of conversations later it is closed without a solution.
It sounds like you're using a github dependency in your Cartfile and attaching a binary of your framework to the GitHub Release. But you don't have any code in the repository, so Carthage is complaining because it can't actually build it.
That's as designed—Carthage doesn't support distributing binary-only frameworks that way. Binaries attached to GitHub Releases are only meant as a way to speed up builds.
However, Carthage does have a mechanism for binary-only dependencies: binary dependencies.

How to install a development Framework in MacOS for commandline build

I have an iOS application that needs to be integrated into CI/CD pipeline in CircleCI. Most of my dependencies have been added using CocoPods. There is one particular dependency of OpenCV2 that is manually compiled and used. On the local development machine, It is simple to use with drag & drop in Xcode. But, while running the build on a CI server. We don't have access to GUI and need to link dependency from the command line. I have not found much of the resources dealing with this issue.
I have tried few options from this link
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html
The framework that I am trying to use is compiled and zipped in an archive (opencv2.framework.zip and uploaded on Amazon S3. It is because the compiled framework is about 300 MB in size. So, I can't push it to the source repository. So, I download it using curl and unzip on CI machine. I have tried unzipping it to
/System/Library/Frameworks
/Library/Frameworks
~/Library/Frameworks
gym --scheme "project" --workspace "project.xcworkspace"
None of them really worked.I would like a way to register this framework in the system so that linker can find it while linking.
Suggest a way to extract framework into a location which linker can automatically look into.
Suggest a way where I can link framework manually from command line build
I have never used OpenCV but a quick pod search gives this result, so looks like they are already supporting cocoapods.....
pod search opencv
-> OpenCV2 (3.2.0)
OpenCV (Computer Vision) for iOS.
pod 'OpenCV2', '~> 3.2.0'
- Homepage: http://opencv.org
- Source: http://github.com/bcomeau/opencv/releases/download/3.2.0/opencv-3.2.0-ios-framework.zip
- Versions: 3.2.0 [master repo]
Second:
You can use Carthage https://github.com/Carthage/Carthage
You can use both Cocoapods and Carthage at the same time as long as they are not downloading the same dependencies.
Create a private repo, follow the carthage tutorial for uploading frameworks https://github.com/Carthage/Carthage#supporting-carthage-for-your-framework
then put opencv2 to your repo.
Then add your repo to your cartfile
Then before or after you install cocoapods, install carthage frameworks too.
It is a bit work but can solve your problem.
Third:
Looks like they also support Carthage
https://github.com/card-io/card.io-iOS-source/issues/32
Look at the last couple of comments..

Build failed with Realm and circleCI (with Carthage)

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

How do I use SwiftyJSON in my iOS 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.

Resources