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 4 years ago
signshah commented 4 years ago

event sent after app closed: {id: 0, progressId: null, message: Running "flutter pub get" in demopro...} event sent after app closed: {id: 0, progressId: null, finished: true} Launching lib/main.dart on Demo’s iPhone in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: 5LMP7AU4U9 Running pod install... Running Xcode build... Xcode build done. 100.5s Failed to build iOS app Error output from Xcode build: ↳ 2020-10-22 15:45:01.040 xcodebuild[12458:113091] DTDeviceKit: deviceType from a578d1d6cb0d414525f7c02a1748da68dc4c6cee was NULL 2020-10-22 15:45:01.197 xcodebuild[12458:113095] DTDeviceKit: deviceType from a578d1d6cb0d414525f7c02a1748da68dc4c6cee was NULL 2020-10-22 15:45:01.197 xcodebuild[12458:113095] DTDeviceKit: deviceType from a578d1d6cb0d414525f7c02a1748da68dc4c6cee was NULL BUILD FAILED

Xcode's output: ↳ /Volumes/sign/projects/new/demopro/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/FIRMessagingPubSub.m:283:12: warning: parameter 'expression' not found in the function declaration [-Wdocumentation]

Could not build the precompiled application for the device.

Error launching application on Demo’s iPhone.

aboedo commented 4 years 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

signshah commented 4 years ago

When you say adding an empty swift file, what does it mean. Can you please provide the steps on how to add it? Thanks for your quick response!

aboedo commented 4 years ago
  1. open up the project in xcode (it should be located on your ios folder). Make sure to open the one that ends in .xcworkspace
  2. click on your project in the navigator in xcode, then file, new, file, select Swift file from the options, click next
  3. give it any name, make sure that it's included in the target (i.e.: the checkbox at the bottom, make sure that your app is selected)
  4. if prompted, create a bridging header
  5. Product -> Clean Build Folder
  6. Product -> Run
signshah commented 4 years ago

Thanks @aboedo for your quick responses. Creating the swift file made it work. Hope to see the issue fixed in the plugin soon. Thank you once again....

signshah commented 4 years ago

Hi, Do you have any targeted date about when will be the issue get fixed? So we don't need to create the swift file. Thank you

aboedo commented 4 years ago

I just published version 1.4.1, which adds a swift file inside the project. I'm not sure if it'll remove the need to add a Swift file to the project at all, but it might.

Flutter improved their swift support a while back so new projects don't run into this, so maybe upgrading your flutter version also helps?

@signshah give it a shot when you get the chance and let me know if it helps!

signshah commented 4 years ago

When I updated the dependency to 1.4.1 and then added the dummy swift file, it started working. But when I am trying to release the application and going to Product -> Destination -> it shows "Any IOS device (arm64)" and not showing "Generic iOS Device". I believe if I publish this app it will not work for x86_64.. Not sure this issue is related to this or not though...

signshah commented 4 years ago

When I tried to do Product -> Archive, it gave me error saying Build Failed. It shows error about PurchasesHybrideCommon.

Please see the attached files. Thank you.

Screen Shot 2020-10-24 at 12 06 47 AM Screen Shot 2020-10-23 at 11 59 29 PM
aboedo commented 4 years ago

Could you make sure that "Enable modules" is set to YES in build settings?

signshah commented 4 years ago

Hi,

I just checked and found that the option "Enable Modules (C and Objective-C) is set to YES.

Screen Shot 2020-10-24 at 8 47 21 PM
rhinck commented 4 years ago

@aboedo I'm having a similar issue with this. I'll try adding the empty file and see if that changes it for me.

aboedo commented 3 years ago

I think there might still be some build artifacts lying around. Maybe try removing and re-adding the plugin?

rhinck commented 3 years ago

@aboedo I added the plugin version you recommended as well as the empty swift file to the project. I was able to get a development version of the app running again, thanks! I'll have to see if I encounter similar issues to @signshah when I release an app update. I'm using Flutter version 1.22.2.

aboedo commented 3 years ago

@rhinck thanks for the confirmation! Glad it worked

signshah commented 3 years ago

Maybe try removing and re-adding the plugin?

@aboedo When you say removing and re-adding the plugin, you are talking about the purchases_flutter dependency in yaml file? or in the Xcode the Enable Modules (C and Objective-C) set to NO and then reset it to YES? Thanks

aboedo commented 3 years ago

@signshah I meant from the yaml file, then doing flutter build ios so that it removes the pod, then re-adding and running again so that the pod is re-installed.

Other things to check:

aboedo commented 3 years ago

fwiw I was running into some weird archive failed issues a couple of mins ago, and I tried opening Xcode 11 and archiving (success), then went back to Xcode 12 and archived again and it works. And I had cleaned derived data, uninstalled the pod and done other things before. Xcode 12 behaves inconsistently.

signshah commented 3 years ago

@signshah I meant from the yaml file, then doing flutter build ios so that it removes the pod, then re-adding and running again so that the pod is re-installed.

Other things to check:

  • make sure that you're opening the .xcworkspace file, since the .xcproject one won't have access to pods
  • maybe try using frameworks: add use_frameworks! to the Podfile
  • if that fails, try static linking: add use_frameworks! :linkage => :static to the Podfile

@aboedo,

I created a new project and tried to do archive in XCode without the purchases_flutter dependency and it worked well. But when I add the purchase_flutter dependency into the yaml the archive fails with the same error.

I am opening the XCode by right clicking the ios folder -> Open ios module in XCode. So I think it is opening the xcworkspace only.

I also tried putting use_frameworks! or use_frameworks! :linkage => :static but getting same error. I trying putting these lines one at time as the first line of the Podfile.

aboedo commented 3 years ago

@signshah I just went through those exact steps just in case on my computer and I did get the linker error:

image

However, I did a clean build folder with cmd + shift + k and then it worked

image

Flutter doctor output:

image

relevant pubspec.yaml section:

image

I did run pod install manually, but other than that I didn't do anything particularly interesting.

I'm curious about your case: how are you creating the project? Is it with flutter create or through the IDE? what's the output of xcode-select -p?

aboedo commented 3 years ago

I just tried again, with a new app (created with flutter create), this time with the latest stable version of flutter and cocoapods, and installing pods through flutter build ios. Didn't run into any issues this time around (I did have to modify the Podfile to uncomment the platform :ios, '9.0' line, as specified in our docs.

Do you run into the same issues if you use xcode 11 instead of 12?

signshah commented 3 years ago

Hi,

I created a new project with flutter create command. I am able to install and run the app in the emulator but when I run the command flutter build ios then it is failing with the exception.

It is giving "ld: symbol(s) not found for architecture arm64" error. So I opened a XCode and created the dummy swift file. This time Xcode did not ask me to create a bridging header. However, I was able to run the application in the emulator without creating the swift file.

Following is the output of flutter build ios command. `Demos-MacBook-Pro:demoapp DemoDemo$ flutter build ios Running "flutter pub get" in demoapp... 0.3s Building com.demo.test.demoapp for device (ios-release)... Automatically signing iOS for device deployment using specified development team in Xcode project: ABCDDEEE Running pod install... 1.3s Running Xcode build...
Xcode build done. 10.1s Failed to build iOS app Error output from Xcode build: ↳ BUILD FAILED

Xcode's output: ↳ /Volumes/Demo/projects/test/demoapp/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 /Volumes/Demo/projects/test/demoapp/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.m:6: /Volumes/Demo/projects/test/demoapp/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/RCPurchases+HybridAdditions.h:14: 1: note: method '_setPushTokenString:' declared here

Encountered error while building for device. `

aboedo commented 3 years ago
signshah commented 3 years ago

Hi @aboedo,

After performing the above steps several times, I was able to finally build and upload the app to the Apple Appstore. However this is not related to this issue but they rejected my app saying my app is missing Missing Purpose String in Info.plist.

It looks like all the above permissions are required by the purchases_flutter package if I am not wrong.

aboedo commented 3 years ago

@signshah I'm glad it started working. I'm not sure what caused the issues, but I'm guessing some weird xcode leftover cache, given that it eventually worked without other changes.

Our SDK does not use or request any of those permissions, though. I'd advise to look closer into other dependencies you may have (like firebase or others) to see if they actually need any of those.

The-Redhat commented 3 years ago

The last instruction you posted @aboedo worked on my local machine. But the build keeps failing on codemagic (without dependency caching) with the original error message.

aboedo commented 3 years ago

@The-Redhat one thing you could try for codemagic is to build using xcode 11, and then possibly going back to 12 again

Skyost commented 3 years ago

Hey, so as I said in #99 (this comment), I'm also getting this error. I tried everything that has been posted (having a Swift file — in fact my project has been created with -i Swift —, pod install --repo-update, the steps here …) but without any success so far.

aboedo commented 3 years ago

@Skyost could you share your version of cocoapods? pod --version I'm trying to get repro steps

The-Redhat commented 3 years ago

@The-Redhat one thing you could try for codemagic is to build using xcode 11, and then possibly going back to 12 again

worked for me. thank you @aboedo

Skyost commented 3 years ago

@aboedo I'm using the latest version (1.10.0).

aboedo commented 3 years ago

@Skyost could you try building with xcode 11 and then 12 again?

erf commented 3 years ago

I rolled back to 1.3.1, which builds ok for me.

UPDATE: i was able to do flutter run --release, but flutter build ios failed with:

Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **

Xcode's output:
↳
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    error: The linked framework 'Pods_Runner.framework' is missing one or more architectures
    required by this target: armv7. (in target 'Runner' from project 'Runner')

UPDATE 2:

After cleaning everyting and installing pods again i was able to build using flutter build ios

aboedo commented 3 years ago

@erf so after cleaning and reinstalling pods, flutter build ios worked, but is that still on 1.3.1? does 1.4.1 still not work?

erf commented 3 years ago

I'm on 1.3.1. 1.4.1 failed to build.

scullabyte commented 3 years ago

None of the above worked for me, so I ended up fixing this by shutting down Xcode, then replacing all versions of IPHONEOS_DEPLOYMENT_TARGET in project.pbxproj to match my Podfile - then running flutter build ios in Terminal. After that, I could Run/Archive inside Xcode again.

aboedo commented 3 years ago

@erf that error message is interesting. Note that it's actually pointing you towards Pods_runner.framework, not Purchases. I think it might be related to a change in Xcode 12, where the architectures for a project have moved from VALID_ARCHS to EXCLUDED_ARCHS.

I think updating your version of cocoapods and flutter might help. If not, you can try removing deleting the values of VALID_ARCHS and EXCLUDED_ARCHS in your Xcode project to use the defaults.

aboedo commented 3 years ago

@scullabyte thanks for posting that solution. Yeah, the value for IPHONEOS_DEPLOYMENT_TARGET can be different than that of the Podfile, and both need to be at least iOS 9.0 in order to use the PurchasesFlutter framework

erf commented 3 years ago

@aboedo i tried to upgrade cocopods to latest (cocoapods-1.10.0), but now i just get this message for every command:

 % pod install
Traceback (most recent call last):
        15: from /usr/local/bin/pod:23:in `<main>'
        14: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
        13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:272:in `find_spec_for_exe'
        12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:280:in `matching_specs'
        11: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:847:in `stubs_for'
        10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:788:in `installed_stubs'
         9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:795:in `map_stubs'
         8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:795:in `flat_map'
         7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:795:in `each'         6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:798:in `block in map_stubs'
         5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:774:in `gemspec_stubs_in'
         4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:774:in `select'
         3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/stub_specification.rb:204:in `valid?'
         2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/stub_specification.rb:114:in `data'
         1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/stub_specification.rb:114:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/stub_specification.rb:114:in `initialize': Permission denied @ rb_sysopen - /Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.10.0.gemspec (Errno::EACCES)
aboedo commented 3 years ago

looks like that might be an issue with your Ruby installation. You might want to use something like rbenv (https://github.com/rbenv/rbenv) to manage ruby environments.

erf commented 3 years ago

@aboedo got it working with rbenv, thanks!

aboedo commented 3 years ago

@erf I'm glad it's working 🎉

erf commented 3 years ago

I managed to make cocoapods work again, but still can't build with 1.4.1. I get the following build error if i try:

~/projects/project % flutter run -d 0A7DFF83-FD1C-476E-BBAB-5645DDE6B007
Running "flutter pub get" in project...                         1,519ms
Launching lib/main.dart on iPhone 12 mini in debug mode...
Running pod install...                                             13.1s
Running Xcode build...
Xcode build done.                                           70.7s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **

Xcode's output:
↳
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.m:13:17: warning: method definition for
    '_setPushTokenString:' not found [-Wincomplete-implementation]
    @implementation RCPurchases (HybridAdditions)
                    ^
    In file included from
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.m:6:
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.h:14:1: note: method '_setPushTokenString:'
    declared here
    - (void)_setPushTokenString:(nullable NSString *)pushToken;
    ^
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.m:13:17: warning: method definition for
    'configureWithAPIKey:appUserID:observerMode:userDefaults:platformFlavor:platformFlavorVersio    n:' not found [-Wincomplete-implementation]
    @implementation RCPurchases (HybridAdditions)
                    ^
    In file included from
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.m:6:
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/RCPurchases+HybridAdditions.h:23:1: note: method
    'configureWithAPIKey:appUserID:observerMode:userDefaults:platformFlavor:platformFlavorVersio    n:' declared here
    + (instancetype)configureWithAPIKey:(NSString *)APIKey
    ^
    2 warnings generated.
    /Users/erlend/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.4.1/ios/Classes/Purchas    esFlutterPlugin.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/Purchas    esFlutterPlugin.m:5:
    /Users/erlend/projects/project/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/Pur    chasesHybridCommon/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

Could not build the application for the simulator.
Error launching application on iPhone 12 mini.
erf commented 3 years ago

Oh, wait. I was able to run it from XCode but not from the terminal.

aboedo commented 3 years ago

what happens if you cd into the iOS project path and run

pod cache clean Purchases
pod cache clean PurchasesCoreSwift
pod cache clean PurchasesHybridCommon
pod cache clean purchases_flutter
pod install

?

erf commented 3 years ago

I get the following error after that:

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

Xcode's output:
↳
    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

Could not build the application for the simulator.
Error launching application on iPhone 12 mini.

Note that calling:

 % pod cache clean purchases_flutter

[!] No cache for pod named purchases_flutter found

Also when i call pod install i get the following warnings, can i ignore them?

[!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] 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
Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).

Btw, i'm on dev channel now.

flutter --version
Flutter 1.24.0-6.0.pre • channel dev • https://github.com/flutter/flutter.git
Framework • revision 13896b3bd1 (5 days ago) • 2020-10-28 19:43:19 -0700
Engine • revision 073263e39d
Tools • Dart 2.11.0 (build 2.11.0-260.0.dev)
aboedo commented 3 years ago

thanks for sharing. that warning seems safe to ignore because it's auto-assigning iOS 9.0, which is compatible. Please try opening the project in Xcode directly, and deleting derived data https://programmingwithswift.com/delete-derived-data-xcode/.

Does this also happen when running against a physical device?

erf commented 3 years ago

It did run in XCode (on Simulator), but it fails in Android Studio and from the Terminal. I delete the derived data, but that does't help.

Same thing happens on a physical device, yes.

erf commented 3 years ago

No idea why, but i was able to build and run version 1.4.1 via Android Studio now on an iOS simulator. Did not change anything i'm aware off.