adaptyteam / AdaptySDK-React-Native

React Native SDK for growing in-app subscriptions
https://docs.adapty.io/docs/quickstart
MIT License
125 stars 12 forks source link

protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable' #74

Closed leons1767 closed 1 year ago

leons1767 commented 1 year ago

Description

Hello,

I tried to build for iOS with Expo EAS build today, and the build failed with the above error

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » EventsManager.swift

Version

v2.4.6

What platforms are you seeing the problem on?

iOS

System info

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 4800U with Radeon Graphics
    Memory: 2.79 GB / 15.37 GB
  Binaries:
    Node: 18.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - ~\AppData\Roaming\npm\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.17763.0, 10.0.19041.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: Not Found
  Languages:
    Java: 11.0.2
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0
    react-native: 0.69.6 => 0.69.6
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.71.4 is now available (your project is running on v0.69.6).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.71.4.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.69.6.
info To upgrade, run "react-native upgrade".
divanc commented 1 year ago

Hello! Checking that...

divanc commented 1 year ago

@leons1767 can you share cloud build link? If it sensitive, then it's let's try to find a problem without it.

I primarily expect that Expo version you use have an older version of Swift. Can you tell what Expo version do you use? Also does it happen during debug or production builds?

My empty projects with Adapty were successfully built: My iOS Development logs | iOS Production logs

leons1767 commented 1 year ago

@divanc I'm using Expo SDK46 and the error happen when I try to build a developmemt build/client. The development build is successful after I stripped out Adapty SDK.

eas build --profile development --platform ios

Did you build yours using expo (local) or eas?

leons1767 commented 1 year ago

@divanc I tried again to build using eas, this time building a production build

eas build --profile production --platform ios

The build fail with the following errors

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }

› Packaging react-native Pods/RCT-Folly » libRCT-Folly.a

▸ ** ARCHIVE FAILED **

▸ The following build commands failed:

▸   CompileSwift normal arm64 (in target 'Adapty' from project 'Pods')

▸   CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Adapty' from project 'Pods')

▸   CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'ASN1Decoder' from project 'Pods')

▸ (3 failures)

+-------------+-------------------------+
|           Build environment           |
+-------------+-------------------------+
| xcode_path  | /Applications/Xcode.app |
| gym_version | 2.206.1                 |
| sdk         | iPhoneOS15.5.sdk        |
+-------------+-------------------------+
leons1767 commented 1 year ago

I tried building from scratch with both Expo SDK46 and SDK48 with the following sequence, and I could see the same errors in SDK46, while SDK48 does not have the errors. Unfortunately, I am not able to upgrade to SDK48 at the moment because it mandates RN0.71.

npx expo init adaptyExpoTest --template expo-template-blank@sdk-46 
cd adaptyExpoTest
npx expo install expo-dev-client
npx expo install react-native-adapty
eas build --profile development --platform ios

No codes are added, just a blank template

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » EventsManager.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » EventsStorage.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » EventsStorage+UserDefaults.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protoco
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » EventType.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FallbackPaywalls.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchAllProductsRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchAllProductVendorIdsRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchEventsConfigRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchPaywallRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchProfileRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » FetchUIPaywallConfigurationRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » Font.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » Font+Decodable.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPCancelable.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPCodableConfiguration.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPConfiguration.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPDataResponse.Validator.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPEncodableRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPEndpoint.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPError.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPMethod.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
› Compiling react-native-adapty Pods/Adapty » HTTPRequest.swift

❌  (ios/Pods/Adapty/Sources/Events/Entities/EventType.swift:55:36)

  53 |         case let .system(value):
  54 |             try container.encode(Name.system, forKey: .type)
> 55 |             let data = try Backend.encoder.encode(value)
     |                                    ^ protocol 'AdaptySystemEventParameters' as a type cannot conform to 'Encodable'
  56 |             let string = String(decoding: data, as: UTF8.self)
  57 |             try container.encode(string, forKey: .customData)
  58 |         }
leons1767 commented 1 year ago

Fixed the issue in Expo SDK46 by setting the xcode version in fastlane gym to latest in eas.json, "image": "latest"

"build": {
    "development": {
      "channel": "development",
      "ios": {
        "enterpriseProvisioning": "adhoc",
        "image": "latest"
      },
      "developmentClient": true,
      "distribution": "internal"
    },
divanc commented 1 year ago

Wow, don't even know what this does. We should support expo 46 certainly. Thanks for figuring out!

leons1767 commented 1 year ago

It is not obvious, took me a while to figure it out. "image" is basically the iOS build server image with the corresponding MacOS and XCode version among others.

https://docs.expo.dev/build-reference/infrastructure/#macos-ventura-133-xcode-143-latest-for-apple-silicon-builders-only-available-for-apple-silicon-builders

Putting it down here for the benefits of others.

Cheers.