3

I'm using documentation here to create my custom expo module.

npx create-expo-module FooModule

Using this instruction, for example on ios folder, only .swift files are generated.

I have to import a custom framework (a local folder) and use it inside swift files.

How can I manage it without an xcproject?

asked Mar 6, 2023 at 15:25
1
  • Hi, were you able to achieve this? I tried prebuilding using expo to generate ios dir. In xcode I can import the framework, but cannot use it in swift file generated by expo module. Can you please share me your findings? Commented Sep 28, 2023 at 11:29

2 Answers 2

1

To import a custom framework in your Expo module without an Xcode project, you can follow these steps:

  1. Create a folder in your Expo module project and copy your custom framework into it.

  2. In the iOS folder of your Expo module project, create a new folder named "Vendor". This folder is typically used to hold external libraries and frameworks.

  3. Drag the folder containing your custom framework into the "Vendor" folder in Xcode.

  4. In the "Build Phases" section of your Expo module project's target in Xcode, add a "Copy Files" build phase.

  5. In the "Copy Files" build phase, set the "Destination" to "Frameworks" and add your custom framework to the list of files to be copied.

  6. In your Swift files, import your custom framework using the import statement.

Once you've completed these steps, you should be able to use your custom framework in your Expo module's Swift files.

answered Mar 6, 2023 at 18:16
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Nahid for response. I can't manage step 4, because on generated project there is not an xcode project, that's the point of my question. If I have had an xcode project it would have been simple
well the example folder has one
0

Maybe this can help you: https://docs.expo.dev/modules/third-party-library/#add-native-dependencies. So according to the official documentation, you can simply add it to your .podspec:

 s.static_framework = true
 s.dependency 'ExpoModulesCore'
+ s.vendored_frameworks 'Frameworks/MyFramework.framework'
 # Swift/Objective-C compatibility

However, this didn't quite work for me either. I have the following question:

  • Where should my framework be (in the file system)?
  • Do I have to change anything in the Build Settings or Build Phases?
  • Is the path relative or absolute? If relative, relative to what?
  • Is there anything else I have to do before I can import the frameworks contents in my Swift code?

I also found this example, leaving me even more confused than before...

answered Jan 25, 2024 at 19:16

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.