lottie-ios icon indicating copy to clipboard operation
lottie-ios copied to clipboard

XCode 14.3.1 - iOS Build / Run Failed - underlying Objective-C module 'Lottie' not found

Open maddy16 opened this issue 1 year ago • 8 comments

I just updated my XCode from 14.2 to 14.3.1 and now my react native application isn't building or running. On Xcode 14.2, everything was working fine.

MacOS Ventura 13.1 Apple Macbook Pro M1 (Silicon)

Wasted a lot of time searching for an appropriate solution, unable to find any.

Here's my Podfile:

`platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end
target 'MyProject' do
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true


  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
  pod 'OpenTok', '2.20.1'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
  pod 'react-native-branch', path: '../node_modules/react-native-branch'
  use_native_modules!

end

target 'MyProject-tvOS' do

end


pre_install do |installer|
  puts("Image fix for ios14: remove this pre_install script from podfile when upgrading to >= 0.63.3")
  find = "_currentFrame.CGImage;"
  replace = "_currentFrame.CGImage ;} else { [super displayLayer:layer];"
  op = `sed -ie "s/#{find}/#{replace}/" ../node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m`
  puts("Image fix for ios14 done")
end


post_install do |installer|
    puts("Initiating fix for XCode 12.5")
    find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
    "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
    find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
      "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass([module class]))")
    puts("Fix for XCode 12.5 complete")
    installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
                config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
            end
        end
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

`

Which Version of Lottie are you using?

"lottie-ios": "3.1.8",
"lottie-react-native": "3.5.0",

Expected Behavior

The build should complete without any errors.

Actual Behavior

image

maddy16 avatar Jun 13 '23 15:06 maddy16

Can you please share a sample Xcode project that demonstrates this issue?

calda avatar Jun 13 '23 15:06 calda

Same here, updated to xCode 14.3 and with commented out use_frameworks! in the podfile I get the same error. Using native iOS project

viktasidenfy avatar Jun 14 '23 07:06 viktasidenfy

I can't use use_frameworks! as it conflicts with some of the libraries like OneSignal. I'll try to spare sometime to prepare an example project to replicate this issue.

maddy16 avatar Jun 14 '23 13:06 maddy16

@maddy16 try adding this to your post_install script. It seems to work for me.

      if target.name == "lottie-ios"
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'NO'
      else
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end

viktasidenfy avatar Jun 20 '23 13:06 viktasidenfy

Relevant compiler issue: https://github.com/apple/swift/issues/64669

Ideally, there's a better long-term solution than disabling module interface verification, but for the time being, this works for me in Cocoapods:

  post_install do |installer|
    targets_to_skip_verification = [
      'lottie-ios',
      'lottie-react-native'

      # add others as necessary...
    ]

    installer.pods_project.targets.each do |target|
      if targets_to_skip_verification.include?(target.name)
        target.build_configurations.each do |config|
          puts "Updating OTHER_SWIFT_FLAGS for target #{target.name} to include -no-verify-emitted-module-interface"

          # It's very important that the "$(inherited)" part is added, otherwise this will
          # overwrite all other flags and cause a whole separate set of issues
          config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -no-verify-emitted-module-interface'
        end
      end
    end
  end

jonstaff avatar Jun 20 '23 15:06 jonstaff

This issue is stale because it is marked "can't reproduce" and has had no activity in the past week. Please comment with additional information, or this issue will be closed due to inactivity in one week.

github-actions[bot] avatar Jun 28 '23 02:06 github-actions[bot]

We are able to reproduce using the latest RN:

package.json "lottie-react-native": "5.1.6"

Xcode Version 14.3.1 (14E300c)

theonetheycallneo avatar Jun 28 '23 02:06 theonetheycallneo

This issue is stale because it is marked "can't reproduce" and has had no activity in the past week. Please comment with additional information, or this issue will be closed due to inactivity in one week.

github-actions[bot] avatar Jul 06 '23 02:07 github-actions[bot]

if target.name == "lottie-ios" config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'NO' else config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' end

same me

hungnd6282 avatar Jul 10 '23 16:07 hungnd6282

This issue is stale because it is marked "can't reproduce" and has had no activity in the past week. Please comment with additional information, or this issue will be closed due to inactivity in one week.

github-actions[bot] avatar Jul 25 '23 02:07 github-actions[bot]

Has anyone resolved this, i am getting the same in my Xcode 15.2

umerdogar avatar Feb 01 '24 08:02 umerdogar

Relevant compiler issue: apple/swift#64669

Ideally, there's a better long-term solution than disabling module interface verification, but for the time being, this works for me in Cocoapods:

  post_install do |installer|
    targets_to_skip_verification = [
      'lottie-ios',
      'lottie-react-native'

      # add others as necessary...
    ]

    installer.pods_project.targets.each do |target|
      if targets_to_skip_verification.include?(target.name)
        target.build_configurations.each do |config|
          puts "Updating OTHER_SWIFT_FLAGS for target #{target.name} to include -no-verify-emitted-module-interface"

          # It's very important that the "$(inherited)" part is added, otherwise this will
          # overwrite all other flags and cause a whole separate set of issues
          config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -no-verify-emitted-module-interface'
        end
      end
    end
  end

Relevant compiler issue: apple/swift#64669

Ideally, there's a better long-term solution than disabling module interface verification, but for the time being, this works for me in Cocoapods:

  post_install do |installer|
    targets_to_skip_verification = [
      'lottie-ios',
      'lottie-react-native'

      # add others as necessary...
    ]

    installer.pods_project.targets.each do |target|
      if targets_to_skip_verification.include?(target.name)
        target.build_configurations.each do |config|
          puts "Updating OTHER_SWIFT_FLAGS for target #{target.name} to include -no-verify-emitted-module-interface"

          # It's very important that the "$(inherited)" part is added, otherwise this will
          # overwrite all other flags and cause a whole separate set of issues
          config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -no-verify-emitted-module-interface'
        end
      end
    end
  end

it works for me ! good!!!!

podspec

s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'NO', 'OTHER_SWIFT_FLAGS' =>'$(inherited) -no-verify-emitted-module-interface', }

gratefulHeart avatar Mar 26 '24 09:03 gratefulHeart