Afnetworking: Carthage Xcode 11 beta 2 error

Created on 18 Jun 2019  ·  7Comments  ·  Source: AFNetworking/AFNetworking

Error with carthage update AFNetworking --platform iOS any idea ?:

`* Building scheme "AFNetworking iOS" in AFNetworking.xcworkspace
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -workspace /Users/xxx/Desktop/ios/Carthage/Checkouts/AFNetworking/AFNetworking.xcworkspace -scheme AFNetworking\ iOS -configuration Release -derivedDataPath /Users/xxx/Library/Caches/org.carthage.CarthageKit/DerivedData/11.0_11M337n/AFNetworking/3.2.1 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/mg/jj2l1dpn0bb7kt9v9spfzq8m0000gn/T/AFNetworking SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/xxx/Desktop/ios/Carthage/Checkouts/AFNetworking)

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/mg/jj2l1dpn0bb7kt9v9spfzq8m0000gn/T/carthage-xcodebuild.ShOP4X.log`

Most helpful comment

Until this issue is actually addressed, for those using AFNetworking as a managed dependency and building using Xcode 11.x (but also wanting to avoid forking to edit the project file to ignore the warnings shown above), it turns out you can workaround this issue when using Carthage quite easily.

Firstly, save a new xcconfig file with the following content:

CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO

Then you can provide this to Carthage when calling carthage build or similar:

XCODE_XCCONFIG_FILE=path/to/AFNetworking_workaround.xcconfig carthage build …

Hopefully this is of some use to anyone hitting this in Xcode 11.x with Carthage builds!

All 7 comments

I'm seeing the same issue - did you find a solution?

The full error can be seen in the carthage xcodebuild log:

$ cat /var/folders/jq/0vvn04111f57vtyhmgnd19xw6w3gfm/T/carthage-xcodebuild.2b0BIG.log | xcpretty
▸ Processing Info.plist
▸ Compiling AFURLSessionManager.m
▸ Compiling AFURLResponseSerialization.m
▸ Compiling AFSecurityPolicy.m
▸ Compiling AFURLRequestSerialization.m

❌  /Users/xxx/Carthage/Checkouts/AFNetworking/AFNetworking/AFURLRequestSerialization.m:574:26: implicit conversion changes signedness: 'AFHTTPRequestQueryStringSerializationStyle' (aka 'enum AFHTTPRequestQueryStringSerializationStyle') to 'NSInteger' (aka 'long') [-Werror,-Wsign-conversion]

    [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
    ~                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



❌  /Users/xxx/Carthage/Checkouts/AFNetworking/AFNetworking/AFURLRequestSerialization.m:1298:26: implicit conversion changes signedness: 'NSJSONWritingOptions' (aka 'enum NSJSONWritingOptions') to 'NSInteger' (aka 'long') [-Werror,-Wsign-conversion]

    [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))];
    ~                    ^~~~~~~~~~~~~~~~~~~



❌  /Users/xxx/Carthage/Checkouts/AFNetworking/AFNetworking/AFURLRequestSerialization.m:1384:26: implicit conversion changes signedness: 'NSPropertyListFormat' (aka 'enum NSPropertyListFormat') to 'NSInteger' (aka 'long') [-Werror,-Wsign-conversion]

    [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))];
    ~                    ^~~~~~~~~~~


▸ Compiling AFHTTPSessionManager.m
▸ Compiling AFNetworkReachabilityManager.m
▸ Compiling AFNetworking_vers.c

The fix seems to be explicitly casting a few arguments to NSInteger.

diff --git a/AFNetworking/AFURLRequestSerialization.m b/AFNetworking/AFURLRequestSerialization.m
index a4d5d9d..0fd987d 100644
--- a/AFNetworking/AFURLRequestSerialization.m
+++ b/AFNetworking/AFURLRequestSerialization.m
@@ -571,7 +571,7 @@ - (void)encodeWithCoder:(NSCoder *)coder {
     dispatch_sync(self.requestHeaderModificationQueue, ^{
         [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))];
     });
-    [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
+    [coder encodeInteger:(NSInteger)self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
 }

 #pragma mark - NSCopying
@@ -1295,7 +1295,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
 - (void)encodeWithCoder:(NSCoder *)coder {
     [super encodeWithCoder:coder];

-    [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))];
+    [coder encodeInteger:(NSInteger)self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))];
 }

 #pragma mark - NSCopying
@@ -1381,7 +1381,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
 - (void)encodeWithCoder:(NSCoder *)coder {
     [super encodeWithCoder:coder];

-    [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))];
+    [coder encodeInteger:(NSInteger)self.format forKey:NSStringFromSelector(@selector(format))];
     [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))];
 }

A viable workaround is to build this framework with GCC_TREAT_WARNINGS_AS_ERRORS=NO. AFNetworking.xcodeproj has it set to YES, and that's what Carthage uses to build it by default.

Why was this issue closed? This is still a problem in the later Xcode 11 betas, where the latest 3.2.1 release of AFNetworking fails to build with this error...

Same here. This issue should not be closed.

Until this issue is actually addressed, for those using AFNetworking as a managed dependency and building using Xcode 11.x (but also wanting to avoid forking to edit the project file to ignore the warnings shown above), it turns out you can workaround this issue when using Carthage quite easily.

Firstly, save a new xcconfig file with the following content:

CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO

Then you can provide this to Carthage when calling carthage build or similar:

XCODE_XCCONFIG_FILE=path/to/AFNetworking_workaround.xcconfig carthage build …

Hopefully this is of some use to anyone hitting this in Xcode 11.x with Carthage builds!

Still an issue.

the workaround working great.

Was this page helpful?
0 / 5 - 0 ratings