Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Errors When Building From Source #194

Closed
dosentmatter opened this issue Jun 5, 2020 · 4 comments
Closed

Compiler Errors When Building From Source #194

dosentmatter opened this issue Jun 5, 2020 · 4 comments

Comments

@dosentmatter
Copy link

Hello, I am trying to build from source but I keep running into two types of errors:

  1. Type of expression is ambiguous without more context
  2. Ambiguous reference to member 'map'

I am new to Swift. I have a solution but it requires modifying some Swift source code. I'm wondering why it doesn't compile right off the bat.


Machine information:

MacOS Mojave 10.14.6
Xcode 11.3.1

I installed rustup with brew install rustup-init and then rustup-init. I added ~/.cargo/bin to PATH.
I did brew install gcc@9 SwiftLint.


I am on git tag v2.7.1.


Signing Certificate Configuration:

I changed the signing certificate for Gifski project:
image

I changed the signing certificate for ShareExtension project:
image

Here is the diff from the certificate changes:

diff --git a/Gifski.xcodeproj/project.pbxproj b/Gifski.xcodeproj/project.pbxproj
index ed8ef63..8d21c91 100644
--- a/Gifski.xcodeproj/project.pbxproj
+++ b/Gifski.xcodeproj/project.pbxproj
@@ -532,11 +532,11 @@
 				CLANG_ENABLE_OBJC_WEAK = YES;
 				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
 				CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
-				CODE_SIGN_IDENTITY = "Mac Developer";
+				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 36;
-				DEVELOPMENT_TEAM = YG56YK5RN5;
+				DEVELOPMENT_TEAM = R5T7F4W3YF;
 				ENABLE_HARDENED_RUNTIME = YES;
 				GCC_C_LANGUAGE_STANDARD = gnu11;
 				INFOPLIST_FILE = ShareExtension/Info.plist;
@@ -567,7 +567,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 36;
-				DEVELOPMENT_TEAM = YG56YK5RN5;
+				DEVELOPMENT_TEAM = R5T7F4W3YF;
 				ENABLE_HARDENED_RUNTIME = YES;
 				GCC_C_LANGUAGE_STANDARD = gnu11;
 				INFOPLIST_FILE = ShareExtension/Info.plist;
@@ -704,11 +704,11 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = Gifski/Gifski.entitlements;
-				CODE_SIGN_IDENTITY = "Mac Developer";
+				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 36;
-				DEVELOPMENT_TEAM = YG56YK5RN5;
+				DEVELOPMENT_TEAM = R5T7F4W3YF;
 				ENABLE_HARDENED_RUNTIME = YES;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -750,11 +750,11 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = Gifski/Gifski.entitlements;
-				CODE_SIGN_IDENTITY = "Mac Developer";
+				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 36;
-				DEVELOPMENT_TEAM = YG56YK5RN5;
+				DEVELOPMENT_TEAM = R5T7F4W3YF;
 				ENABLE_HARDENED_RUNTIME = YES;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",

Build Errors:

Then I try to build a release version by going to the top menu "Product > Archive".

I get 3 errors total, but they are only of 2 different types:

image

image

image


My Solution:

I added extensions to Sequence that take in key paths because it looked like they were missing.

diff --git a/Gifski/util.swift b/Gifski/util.swift
index 2970d23..22e6e06 100644
--- a/Gifski/util.swift
+++ b/Gifski/util.swift
@@ -2284,6 +2284,14 @@ extension Sequence {
 
 		return result
 	}
+
+	func sum<T: AdditiveArithmetic>(_ keyPath: KeyPath<Element, T>) -> T {
+		sum { $0[keyPath: keyPath] }
+	}
+
+	func map<T>(_ keyPath: KeyPath<Element, T>) -> [T] {
+		map { $0[keyPath: keyPath] }
+	}
 }

Am I missing something? Is there a way to get it to build without adding those extensions?

@sindresorhus
Copy link
Owner

You need the latest version of Xcode.

@sindresorhus
Copy link
Owner

I think you also need macOS 10.15 to be able to compile Swift 5.2.

@dosentmatter
Copy link
Author

@sindresorhus, thanks for the quick response.

So I installed Xcode 11.3.1 because according to this compatibility table, the latest version of Xcode MacOS Mojave 10.14.6 can run is 11.3.1:

image


You are right about Swift 5.2. According to this post, "Swift 5.2 ships as part of Xcode 11.4" and from the wiki table linked above, the minimum macOS version for Xcode 11.4 is macOS 10.15.2.

I can see in my "Build Settings" that I only have Swift 5 but not 5.2:

image


Also, the readme.md says "Requires macOS 10.14 or later.". I'm assuming that requirement is just for running the app and not building?

image


I guess those 3 errors are the only Swift 5.2 features Gifski@v2.7.1 is using since I am able to build and run the app fine with the code patch I typed in the original post.

@sindresorhus
Copy link
Owner

Also, the readme.md says "Requires macOS 10.14 or later.". I'm assuming that requirement is just for running the app and not building?

Correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants