PayHereLK / payhere-mobilesdk-reactnative

PayHere Mobile SDK for React Native
8 stars 6 forks source link

iOS build error #13

Closed Januka closed 2 years ago

Januka commented 3 years ago

Returning bellow error when try to run the app. Undefined symbols for architecture x86_64: "Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from: generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element> in libAlamofire.a(NetworkReachabilityManager.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

PayHereDevs commented 2 years ago

Hello @Januka, apologies that we couldn't get back to you in reasonable time. Please make sure you have run the following command in your project root folder.

npx react-native link @payhere/payhere-mobilesdk-reactnative

Running the above command should resolve issues with the SDK's dependencies not being linked correctly with CocoaPods. Please let us know if the issue persists, and we will be glad to be of further support.

PayHereDevs commented 2 years ago

We will be stating here a possible solution for future readers of this issue. If the solution fixed your issue, please provide some feedback so that we can close the issue with the accepted solution.

Step 1: Add an Empty Swift File.

  1. Open up your React Native iOS project's .xcworkspace file.
  2. Go to the File > New > File menu.
  3. Click on the "ios" tab and select "Swift File"
  4. Click Next, and enter a name such as "TestSwift.swift"
  5. If you are prompted asking the creation of a "Bridging Header File", click YES.

If you were not prompted asking the creation of a Bridging Header File, follow these steps:

  1. Press Command + Shift + O inside Xcode, and type in "Bridging".
  2. See if you find a file name similar to "-Bridging-Header.h" that is NOT under the Pods folder.
  3. If there is already such a file, Step 1 is complete. Please go to Step 2. (. Otherwise go to File > New > File and create a new Header File (.h) named as follows.
  1. From the Left Panel (Project Navigator) in Xcode, Select the Top Most item.
  2. Select your iOS App target.
  3. Click the "Build Settings" Tab.
  4. Select the "All" information level.
  5. Type in "Bridg" into the Search Panel.
  6. Set the below properties and values.

At this point, your Xcode window should look as follows.

Image Link

Step 2: Remove references to "swift-5.0/$(PLATFORM_NAME)"

  1. Right click on the Top-Most item in your Xcode Project Navigator (left panel)
  2. Select "Show in Finder"
  3. On the ".xcodeproj" file that is highlighted in the Finder window, Right click on it.
  4. Select "Show Package Contents"
  5. Find the file named "project.pbxproj"
  6. Right click on it, and open it with TextEdit.app
  7. Inside Text Edit press Command + F (to open search mode)
  8. Paste in the following text and press Enter.
"\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\\"",

Your TextEdit window should now look like this:

TextEdit App Showing Search Result
  1. Remove all traces of the above line from the pbxproj file.
  2. Save the file.
  3. Re-open the .xcworkspace.
  4. Clean the project from the Project > Clean Build Folder menu item.
  5. Re-build the project!