AppLovin / AppLovin-MAX-React-Native

MIT License
55 stars 30 forks source link

iOS Build Failure #318

Open himanshut230 opened 8 months ago

himanshut230 commented 8 months ago

MAX Module Version

6.2.3

React Native Version

0.69.3

Device/Platform Info

iOS 17.0.1

Current Behavior

I am getting this error when trying to build with Xcode 15.0.1:

ld: Undefined symbols: _ALMediationProviderMAX, referenced from: -[AppLovinMAX initialize::::] in AppLovinMAX.o _OBJCCLASS$_ALAtomicBoolean, referenced from: in AppLovinMAXNativeAdView.o _OBJCCLASS$_ALPrivacySettings, referenced from: in AppLovinMAX.o _OBJCCLASS$_ALSdk, referenced from: in AppLovinMAX.o _OBJCCLASS$_ALSdkSettings, referenced from: in AppLovinMAX.o _OBJCCLASS$_MAAdFormat, referenced from: in AppLovinMAX.o _OBJCCLASS$_MAAdView, referenced from: in AppLovinMAX.o _OBJCCLASS$_MAAppOpenAd, referenced from: in AppLovinMAX.o _OBJCCLASS$_MAInterstitialAd, referenced from: in AppLovinMAX.o _OBJCCLASS$_MANativeAdLoader, referenced from: in AppLovinMAXNativeAdView.o _OBJCCLASS$_MARewardedAd, referenced from: in AppLovinMAX.o _OBJCCLASS$_RCTImageView, referenced from: in AppLovinMAXNativeAdView.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected Behavior

No response

How to Reproduce

After following the documentation of Preparing Mediated Networks and adding the below CocoaPods script to my PodFile:

# Sources
source 'https://cdn.cocoapods.org/'

# Settings
use_frameworks!
inhibit_all_warnings!
# Pods
target 'YOUR_PROJECT_NAME' do
    pod 'AppLovinSDK'
end

and running the command pod install --repo-update after this when I build my iOS app I get this error:

ld: Undefined symbols:
  _ALMediationProviderMAX, referenced from:
      -[AppLovinMAX initialize::::] in AppLovinMAX.o
  _OBJC_CLASS_$_ALAtomicBoolean, referenced from:
       in AppLovinMAXNativeAdView.o
  _OBJC_CLASS_$_ALPrivacySettings, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_ALSdk, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_ALSdkSettings, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_MAAdFormat, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_MAAdView, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_MAAppOpenAd, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_MAInterstitialAd, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_MANativeAdLoader, referenced from:
       in AppLovinMAXNativeAdView.o
  _OBJC_CLASS_$_MARewardedAd, referenced from:
       in AppLovinMAX.o
  _OBJC_CLASS_$_RCTImageView, referenced from:
       in AppLovinMAXNativeAdView.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My PodFile:

$RNFirebaseAsStaticFramework = true
$RNFirebaseAnalyticsWithoutAdIdSupport = true

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

production = ENV["PRODUCTION"] == "1"
use_frameworks! :linkage => :static
$RNGoogleMobileAdsAsStaticFramework = true

source 'https://cdn.cocoapods.org/'
use_frameworks!
inhibit_all_warnings!

abstract_target 'TargetCommonPods' do

  target 'Target1' do
  end

  target 'Target2' do
  end

  target 'Target3' do
  end

  target 'Target4' do
  end

  target 'Target5' do
  end

  target 'Target6' do
  end

  target 'Target7' do
  end

  target 'Target8' do
  end

  target 'Target9' do
  end

  target 'Target10' do
  end

  pod 'AppLovinSDK',

  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :production => production,
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    # :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.162.0' }),
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways/Permission-LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse/Permission-LocationWhenInUse.podspec"

  # If you're using autolinking, this line might not be needed
  pod 'WatermelonDB', :path => '../node_modules/@nozbe/watermelondb'

  # NOTE: Do not remove, needed to keep WatermelonDB compiling:
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true

  # NOTE: This is required as of v0.23
  pod 'simdjson', path: '../node_modules/@nozbe/simdjson'

  target 'TargetTests' do
    inherit! :complete
    # Pods for testing
  end

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

    installer.pod_targets.each do |pod|
      if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
        end
        if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
          target.build_configurations.each do |config|
              config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
          end
        end
    end
  end
end

Additional Info

No response

alhiwatan commented 7 months ago

@himanshut230, the first code script in the documentation of Preparing Mediated Networks is for a plain iOS project. I guess you have installed our AppLoin Max package for React Native via npm.

npm install react-native-applovin-max

In that case, node_modules/react-native-applovin-max/react-native-applovin-max.podspec will be evaluated to install a specific version of AppLovinSDK for your installed react-native-applovin-max. Normally, it is automatically linked, but if you need it by yourself, can you do it like this to link AppLovinSDK?

pod 'react-native-applovin-max', :path => '../node_modules/react-native-applovin-max'