Code Monkey home page Code Monkey logo

Comments (19)

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024 1

@Gustash, Sure I'll create and share a repo that reproduces this issue.

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024 1

I've found a workaround to fix the the Apple Mach-O Linker error problem. Create a swift file in project and when prompted to create a bridging file select yes. Re-build the project again and it builds successfully. For more info refer https://stackoverflow.com/questions/52536380/why-linker-link-static-libraries-with-errors-ios/61582562#61582562

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

Hello @RajatKumarChahar, Require Only App-Extension Safe API isn't supposed to be set in the Share Extension target, but in every target inside the Pods project.

To fix this, add a post_install script anywhere in your Podfile like this:

post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
      end
    end
  end

Also, unless you're going to use the same native modules in your Share Extension as you do in your main app, I would recomment slimming down the ShareExtension target by only doing this:

target 'ShareExtension' do
  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'

  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 'RNShareMenu', :path => '../node_modules/react-native-share-menu'
end

This way you can manually link only the native modules you're going to use in your Share Extension, and keep the bundle size minimal.

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

Hello @Gustash, I've added post_install script. Now the error which was coming earlier is not coming but now

Apple Mach-O Linker error

is coming.
I've cleaned the project and built the app again but it's still coming.

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

Can you check if you have. -ObjC abd -lc++ in your Other Linker Flags on the Share Extension's Build Settings?

If not, add those and try again please.

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

Yes I've checked Other Linker Flags on the Share Extension's Build Settings and both -ObjC and -lc++ are present.
To be more specific errors are

ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
Undefined symbols for architecture x86_64:
  "Foundation._convertErrorToNSError(Swift.Error) -> __C.NSError", referenced from:
      RNShareMenu.ShareMenuReactView.dismissExtension(Swift.String?) -> () in libRNShareMenu.a(ShareMenuReactView-B190363797C90082.o)
      reabstraction thunk helper from @escaping @callee_unowned @convention(block) (@unowned __C.NSString?, @unowned __C.NSString?, @unowned __C.NSError?) -> () to @escaping @callee_guaranteed (@guaranteed Swift.String?, @guaranteed Swift.String?, @guaranteed Swift.Error?) -> () in libRNShareMenu.a(ShareMenuReactView-B190363797C90082.o)
  "Foundation.URL.pathExtension.getter : Swift.String", referenced from:
      RNShareMenu.ShareMenuReactView.extractMimeType(from: Foundation.URL) -> Swift.String in libRNShareMenu.a(ShareMenuReactView-B190363797C90082.o)
      (extension in RNShareMenu):Foundation.URL.extractMimeType() -> Swift.String in libRNShareMenu.a(URL+Extensions.o)
  "Foundation.URL.absoluteString.getter : Swift.String", referenced from:
      closure #1 (__C.NSSecureCoding?, Swift.Error?) -> () in RNShareMenu.ShareMenuReactView.extractDataFromContext(context: __C.NSExtensionContext, withCallback: (Swift.String?, Swift.String?, __C.NSException?) -> ()) -> () in libRNShareMenu.a(ShareMenuReactView-B190363797C90082.o)
      closure #2 (__C.NSSecureCoding?, Swift.Error?) -> () in RNShareMenu.ShareMenuReactView.extractDataFromContext(context: __C.NSExtensionContext, withCallback: (Swift.String?, Swift.String?, __C.NSException?) -> ()) -> () in libRNShareMenu.a(ShareMenuReactView-B190363797C90082.o)
  "static Foundation.URL._unconditionallyBridgeFromObjectiveC(__C.NSURL?) -> Foundation.URL", referenced from:
      @objc static RNShareMenu.ShareMenuMessenger.share(application: __C.UIApplication, openUrl: Foundation.URL, options: [__C.UIApplicationOpenURLOptionsKey : Any]) -> () in libRNShareMenu.a(ShareMenuMessenger.o)
.
.
.
.

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

Did you create a Bridging Header in your Share Extension, like the docs mention?

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

No, because it was mentioned for Custom IOS share View which was optional so I didn't.

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

It shouldn't be necessary if you're not using a custom view, but can you please try it just as a sanity check?

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

I added the ShareExtension-BridgingHeader but it's still giving the same error

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

Is it possible to get a repo that reproduces this problem? If you can't share your project, a stripped down version of it without any JS code and keys would be helpful

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

@RajatKumarChahar what version of Xcode are you using btw?

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

@Gustash, I am using Xcode: 11.2.1

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

@RajatKumarChahar okay, is it possible for you to share a project that reproduces that issue? I can't replicate it locally so I'd need to take a closer look at an affected project

from react-native-share-menu.

codewithgigi avatar codewithgigi commented on June 11, 2024

HI @Gustash I'm having the same issue. Did you find a solution for this?

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

@jgardi which problem are you having? The first, or the second one?

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

@RajatKumarChahar you mean creating a bridging header on the main app target?

from react-native-share-menu.

RajatKumarChahar avatar RajatKumarChahar commented on June 11, 2024

@Gustash, Yes

from react-native-share-menu.

Gustash avatar Gustash commented on June 11, 2024

Thanks for letting me know. These instructions are already on the README. I will close this issue as it seems like it was just a step missed on the instructions

from react-native-share-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.