RevenueCat / purchases-flutter

Flutter plugin for in-app purchases and subscriptions. Supports iOS, macOS and Android.
https://www.revenuecat.com/
MIT License
607 stars 168 forks source link

ld: symbol(s) not found for architecture x86_64 #120

Closed signshah closed 3 years ago

signshah commented 4 years ago

I just upgraded my Flutter to 1.22.2. When I add the purchases_flutter: ^1.4.0 dependency into my pubspec.yaml, I am not able to install the app on my IOS simulator or IPhone 8+ physical device. When I remove the dependency then it starts working again. It works fine for Android devices.

Error: ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Pods-Runner-cvxqmtxmlqszrsduaocldvwyjygq note: Using new build system note: Building targets in parallel note: Planning build note: Constructing build description

  1. Environment

    1. Platform: IOS

    2. SDK version: Flutter 1.22.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 84f3d28555 (7 days ago) • 2020-10-15 16:26:19 -0700 Engine • revision b8752bbfff Tools • Dart 2.10.2

    3. OS version: MacOS Catalina (Version 10.15.7)

    4. Android Studio version: 4.0.2

    5. XCode: XCode 12

  2. Debug logs that reproduce the issue ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Pods-Runner-cvxqmtxmlqszrsduaocldvwyjygq note: Using new build system note: Building targets in parallel note: Planning build note: Constructing build description

  3. Steps to reproduce, with a description of expected vs. actual behavior When the purchases_flutter: ^1.4.0 included in the pubspec.yaml then the app cannot be installed in IOS devices. On Android it works fine. If this dependency removed then it starts working on IOS devices too.

aboedo commented 3 years ago

@erf yeah, I can believe that. The crazy inconsistencies in these things are what's making it hard to figure out the issues. Thanks for sticking with it! Let me know if you run into any issues again.

obrunsmann commented 3 years ago

I still have this issue on codemagic.

Some builds are working, some builds are crashing with the exact same git commit.

               Ld /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/armv7/Binary/purchases_flutter normal armv7 (in target 'purchases_flutter' from project 'Pods')
                   cd /Users/builder/clone/ios/Pods
                   /Applications/Xcode-12.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target armv7-apple-ios9.0 -dynamiclib -isysroot /Applications/Xcode-12.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk -L/Users/builder/clone/build/ios/Release-iphoneos/purchases_flutter -F/Users/builder/clone/build/ios/Release-iphoneos/purchases_flutter -F/Users/builder/clone/build/ios/Release-iphoneos/Purchases -F/Users/builder/clone/build/ios/Release-iphoneos/PurchasesCoreSwift -F/Users/builder/clone/build/ios/Release-iphoneos/PurchasesHybridCommon -F/Users/builder/clone/ios/Pods/../Flutter -filelist /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/armv7/purchases_flutter.LinkFileList -install_name @rpath/purchases_flutter.framework/purchases_flutter -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/armv7/purchases_flutter_lto.o -fobjc-arc -fobjc-link-runtime -framework Flutter -framework Foundation -framework PurchasesHybridCommon -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/armv7/purchases_flutter_dependency_info.dat -o /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/armv7/Binary/purchases_flutter
               Undefined symbols for architecture armv7:
                 "_OBJC_CLASS_$_RCPurchases", referenced from:
                     objc-class-ref in PurchasesFlutterPlugin.o
               ld: symbol(s) not found for architecture armv7
               clang: error: linker command failed with exit code 1 (use -v to see invocation)

               Ld /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/arm64/Binary/purchases_flutter normal arm64 (in target 'purchases_flutter' from project 'Pods')
                   cd /Users/builder/clone/ios/Pods
                   /Applications/Xcode-12.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios9.0 -dynamiclib -isysroot /Applications/Xcode-12.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk -L/Users/builder/clone/build/ios/Release-iphoneos/purchases_flutter -F/Users/builder/clone/build/ios/Release-iphoneos/purchases_flutter -F/Users/builder/clone/build/ios/Release-iphoneos/Purchases -F/Users/builder/clone/build/ios/Release-iphoneos/PurchasesCoreSwift -F/Users/builder/clone/build/ios/Release-iphoneos/PurchasesHybridCommon -F/Users/builder/clone/ios/Pods/../Flutter -filelist /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/arm64/purchases_flutter.LinkFileList -install_name @rpath/purchases_flutter.framework/purchases_flutter -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/arm64/purchases_flutter_lto.o -fobjc-arc -fobjc-link-runtime -framework Flutter -framework Foundation -framework PurchasesHybridCommon -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/arm64/purchases_flutter_dependency_info.dat -o /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Pods.build/Release-iphoneos/purchases_flutter.build/Objects-normal/arm64/Binary/purchases_flutter

I never had this issue locally, on CM this issue occurs randomly. The same git hash first fails then succeeds.

Edit: seems working for now with Xcode 11.7

zierka commented 3 years ago

I had the same issue, when running the iOS app on a device (simulator worked fine). A clean + delete derived data magically fixed it...

erf commented 3 years ago

I noticed the build only fails on a device when i run it in debug mode. In release it runs ok.

Here is the log from the latest build fail:

Running pod install...                                             12.8s
Running Xcode build...
Xcode build done.                                           12.8s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **

Xcode's output:
↳
    /Users/erlend/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.4.1/ios/Classes    /PurchasesFlutterPlugin.m:197:28: warning:
    'addAttributionData:network:networkUserId:' is deprecated: Use the set<NetworkId>
    functions instead. [-Wdeprecated-declarations]
        [RCCommonFunctionality addAttributionData:data network:network
        networkUserId:networkUserId];
                               ^
    In module 'PurchasesHybridCommon' imported from
    /Users/erlend/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.4.1/ios/Classes    /PurchasesFlutterPlugin.m:5:
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCo    mmon/PurchasesHybridCommon/RCCommonFunctionality.h:22:130: note:
    'addAttributionData:network:networkUserId:' has been explicitly marked deprecated
    here
    + (void)addAttributionData:(NSDictionary *)data network:(NSInteger)network
    networkUserId:(NSString *) networkUserId __attribute((deprecated("Use the
    set<NetworkId> functions instead.")));

                                             ^
    1 warning generated.
    Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$_RCPurchases", referenced from:
          objc-class-ref in PurchasesFlutterPlugin.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Could not build the precompiled application for the device.
aboedo commented 3 years ago

@erf I just noticed this in one of your previous comments:

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target Runner to `Target

I saw that you mentioned the deployment target warning but I missed the part about the xcconfig files.

There's a solution posted here: https://github.com/flutter/flutter/issues/66222#issuecomment-695802808 Could you give that a shot? I'm not sure it's related, but it's worth a shot. Also, question: are you running on physical device or simulator?

erf commented 3 years ago

@aboedo ok, thanks will check it out. I'm able to debug on a simulator now, but not on a real device. I was able to run the release version on a real device though.

signshah commented 3 years ago

Now again I am not able to build and run my app on IOS devices due to the PurchasesHybridCommon error. Missing submodule 'Purchaes.Purchase' :-(

Screen Shot 2020-11-03 at 4 40 18 PM
aboedo commented 3 years ago

@signshah what's the output of pod install?

aboedo commented 3 years ago

just published 1.4.2, with a slight improvement in definitions of excluded archs. I'm not sure it'll solve the build issues, but give it a shot when you get the chance.

erf commented 3 years ago

@aboedo just tried to install with 1.4.2 run it from Android Studio on an iOS Simulator after clearing everything, and i got the same error as last time.

EDIT: When i set purchases_flutter in pubspec.lock back to 1.4.1 i got it running again..

That is:

Launching lib/main.dart on iPhone 12 mini in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           76.5s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **

Xcode's output:
↳
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.m:13:17: warning: method definition for '_setPushTokenString:' not found [-Wincomplete-implementation]
    @implementation RCPurchases (HybridAdditions)
                    ^
    In file included from /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.m:6:
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.h:14:1: note: method '_setPushTokenString:' declared here
    - (void)_setPushTokenString:(nullable NSString *)pushToken;
    ^
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.m:13:17: warning: method definition for 'configureWithAPIKey:appUserID:observerMode:userDefaults:platformFlavor:platformFlavorVersion:' not found [-Wincomplete-implementation]
    @implementation RCPurchases (HybridAdditions)
                    ^
    In file included from /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.m:6:
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.h:23:1: note: method 'configureWithAPIKey:appUserID:observerMode:userDefaults:platformFlavor:platformFlavorVersion:' declared here
    + (instancetype)configureWithAPIKey:(NSString *)APIKey
    ^
    2 warnings generated.
    /Users/erlend/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.4.2/ios/Classes/PurchasesFlutterPlugin.m:197:28: warning: 'addAttributionData:network:networkUserId:' is deprecated: Use the set<NetworkId> functions instead. [-Wdeprecated-declarations]
        [RCCommonFunctionality addAttributionData:data network:network networkUserId:networkUserId];
                               ^
    In module 'PurchasesHybridCommon' imported from /Users/erlend/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.4.2/ios/Classes/PurchasesFlutterPlugin.m:5:
    /Users/erlend/projects/my_project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCCommonFunctionality.h:22:130: note: 'addAttributionData:network:networkUserId:' has been explicitly marked deprecated here
    + (void)addAttributionData:(NSDictionary *)data network:(NSInteger)network networkUserId:(NSString *) networkUserId __attribute((deprecated("Use the set<NetworkId> functions instead.")));
                                                                                                                                     ^
    1 warning generated.
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_RCPurchases", referenced from:
          objc-class-ref in PurchasesFlutterPlugin.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
aboedo commented 3 years ago

@erf did you get the cocoapods xcconfig files configuration fixed?

erf commented 3 years ago

It seemed correct according to the Stackoverflow url you linked to.

aboedo commented 3 years ago

just published version 1.4.3 which I believe should fix the linking issues. Be sure to do a pod clean and pod install if you continue to experience issues, and delete derived data. @erf @signshah

signshah commented 3 years ago

Hi, After deleting the derived data folder and trying couple of times it allowed me to build and publish the app. But It is not straightforward. At least two to three times I need to clean and delete derived data folder..

obrunsmann commented 3 years ago

Seems resolved for me with the latest version. Thanks for the quick solution

aboedo commented 3 years ago

I'm tentatively closing this ticket since it seems like it was finally resolved, but let me know if you're still facing issues with it. Thanks for your patience everyone!

metarsul commented 3 years ago

Hi, flutter build ios works fine but then when I'm trying to archive:

../ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.h:12:12: error: declaration of 'RCPurchases' must be imported from module 'Purchases' before it is required

image

aboedo commented 3 years ago

@metarsul I managed to reproduce this on the sample app, and I realized that flutter now adds the following lines to the Podfile:

use_frameworks!
use_modular_headers!

With those lines added, the project compiles and archives correctly for me. Could you ensure that those lines are there? You can also try deleting Podfile and Podfile.lock so that flutter re-generates the Podfile automatically (make sure to set the deployment target afterwards, though)

metarsul commented 3 years ago

@aboedo Yes! I checked, and its there! I belive that when i clicked on ‘fix issues ‘ , Xcode problaby fixed it for me

aboedo commented 3 years ago

@metarsul I figured out a way to reproduce this consistently with the sample app:

  1. clean derived data
  2. flutter clean
  3. flutter build ios
  4. archive
  5. 💥 archive error in xcode.

However, it gets fixed when I add:

use_frameworks!
use_modular_headers!

to the Podfile, and then:

  1. clean derived data
  2. flutter clean
  3. flutter build ios
  4. archive
  5. ✅ archive success

Please give it a shot, while making sure to delete the derived data folder, run flutter clean and then flutter build ios!

TQCasey commented 6 months ago

ok. it looks like adding a single, empty swift file should fix it. I'm currently looking for a workaround in the plugin side to see if this can be prevented, but in the meantime, the empty swift file should solve the issue

you saved my whole day!!! , thanks