React native iOS library not found after updating - ios

After I update an already existing React Native library, should i relink it again?.
ld: library not found for -lBranch-SDK
in addition,when I run react-native-link I get
react-native-branch ERR! Failed to add file to project

linking just sets up your native projects to link to the module in your node_modules. Unless there is a major change to the module, you only need to do it once.
For iOS, this will modify your .pbxproj file, updating your targets and adding links to the framework (if needed) and the .xcodeproj in node_modules/<module>
For android, it will modify your settings.gradle file to include the project from node_modules. It will also update your build.gradle to compile the new library, and it will modify your MainApplication.java file to add the new lib to react.

Related

Using Xcode project in react native plugin causes header file not found errors

I'm developing a react native plugin (iOS) that uses another project as depencency. Building the project on its own, no errors occur. When I build a react native app with my plugin inside, I get the error that some header files are not found in my plugin.
My structure
MyReactNativeApp
node_modules
myPlugin
iOS
myPlugin.xcodeproj
folder1
myProject1.xcodeproj
folder2
myProject2.xcodeproj
folder3
file1.h
folder4
file2.h
myProject2 has some header files defined that reference to each other.
When I build myProject1.xcodeproj, there are no errors. When I build myPlugin, the header files can't include each other.
The header search paths are set. This shouldn't be the problem.
Does someone may has an idea what could be the reason?
I didn't find a solution for this problem, but one for my actual problem that .framework modules couldn't be found. Due to this error I tried to add the project directly.
If a .framework module could not be found, you need to add this to your .podspec file of myPlugin
s.vendored_frameworks = 'ios/Frameworks/myProject1.framework', 'ios/Frameworks/myProject2.framework'
s.public_header_files = 'ios/Frameworks/myProject1.framework/**/*.h'
Maybe only the s.public_header_files will fix the error in the question.

Module 'Swift' was created for incompatible target x86_64-apple-ios13.0

I'm creating an iOS framework and I want to copy some Xcode templates from my framework directory (that are not included in my .xcproject, but are in the folder that contains the project), when my framework is installed trought Cocoapods. In other words, when a developer installs my framework with Cocoapods or manually, I want to copy the templates into his Xcode Template Files folder.
I'm trying to execute a swift script file from the build phase of Xcode like this:
swift "${SRCROOT}/Folder/Folder/installer.swift"
But I get this error when I try to build it:
/<unknown>:1:1: module 'Swift' was created for incompatible target x86_64-apple-ios13.0: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule
If I execute swift installer.swift from the terminal, the script works. So, I think there is a problem with my Xcode.
My installer.swift file copies the template files to the Xcode Template Files folder.
I don't know if this way is the correct one, but I didn't find any other solution so far.
When I tried something similar I had to tell swift to compile for macOS by adding the following "shebang" comment as the first line of the swift script:
#!/usr/bin/env xcrun --sdk macosx swift

Using a static iOS library in a NativeScript 5.4 plugin

NativeScript 5.4.2
tns-core-modules 5.4.3
tns-ios 5.4.2
Xcode 10.2.1
I am attempting to create a plugin for this background geolocation library for iOS: https://github.com/Yermo/background-geolocation-ios
The project produces a static library, libBackgroundGeolocation.a.
I have read the documentation on how to use a static iOS library: https://docs.nativescript.org/plugins/Use-Native-iOS-Libraries#static-libraries
I have read about the required directory structure: https://docs.nativescript.org/plugins/plugin-reference#directory-structure
My plugin is based on the official plugin seed, so I have a demo directory and a src directory containing my plugin code and a platforms/ios directory under that.
I have copied the BackgroundGeolocation.a file into src/platforms/ios.
I have created a src/platforms/ios/include/BackgroundGeolocation directory and copied the public header files from the project into that directory.
I notice that src/platforms/ios/include/BackgroundGeolocation/module.modulemap file has been created.
In the plugin directory I can successfully run 'npm run build'.
However, from the demo directory if I run 'tns build ios' I consistently get a "ld: Library not found for -lBackgroundGeolocation" error.
If I rename the library to libBackgroundGeolocation.a I get the "ENOENT: no such file or directory, scandir '.....ios/include/libBackgroundGeolocation" so I surmise it's at least recognizing that the library is there.
I thought that maybe it was a path problem so I tried setting the library include path explicitly in build.xcconfig using the full path to the platforms/ios directory.
No joy. It still doesn't find the library but if I misspell the name of the directory in the -L in build.xcconfig it flags a directory not found error.
I then thought that maybe it had to do with the targets in the library so I followed the recipe here Build fat static library (device + simulator) using Xcode and SDK 4+ to include multiple targets.
Still no joy.
I suspect I am missing something fundamental.
What am I doing wrong?
Is there a working recent working sample somewhere of how to wrap a static iOS library as a NativeScript plugin?
It turns out adding
LIBRARY_SEARCH_PATHS = $(inherited) "$(SRCROOT)/../../node_modules/<projectname>/platforms/ios
to the src/platforms/ios/build.xcconfig file resolved this issue.

can't find ios framework headers in react native module library

I've included an iOS framework in the xcode project for the React Native module library I'm creating. Everything compiles fine when I build the ios project in the RN library itself, but once I npm install the library into my main RN project, running react-native link <project-name>, and then build in xcode, the included framework headers are not found.
I checked the normal build settings (Header, Framework, and Library search paths) and they all have $(inherited) listed.
Repo for the react native library that is WIP https://github.com/bsy/react-native-pollfish
Download SDK file from here . May be owner removes the SDK from github.
Please add this line in your package.json file.
"rnpm": {
"ios": {
"sourceDir": "./ios"
}
}
Also, unable to install your plugin with "npm install".
The solution to this issue was to make sure that both your Xcode subproject and your main Xcode project both point to a relative path to the SDK.
Steps to take:
Open your application's Xcode project.
If you don't have a Frameworks group in your project, create one.
Open ~/Documents/PollfishSDK using Finder.
Drag the pollfish.framework file into the Frameworks group of Xcode's Project Navigator. In the displayed dialog, choose Create groups for any added folders and deselect Copy items into destination group's folder. This references the SDK where you installed it rather than copying the SDK into your app.
For 3rd party framework set the framework search path in the library project-
$(SRCROOT)/../../../ios/Pods/3rd_party_framework_folder_name

How to embed framework without copying in project

There was a similar question, but the answer is no
I use appodeal-ios-sdk-mobile-adapter. I want to add them to your projects without copying each.
in the Link Binary with Libraries framework added
But I get:
ld: framework not found GoogleMobileAds
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In order to add the framework to your project without copying proeta folder, drag the folder using the (Create groups), and add the path where you have a set framework -> "Build Setting -> Library Search Paths and Framework Search Paths
/Users/username/Framework/AppodealAdapters/**
Well you can open the system directory where all the frameworks are present
that is in the system folder where all the frameworks are installed
Hit Shift+Command+G
and use the below address
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
Once in the directory copy the framework which you want to use. Take care to not mess around other frameworks in this directory.
Once the frameworks are copied into this directory you can add them to your project just like you include a regular system defined framework.
Try it out it works for me. I am using XCode 7.3.

Resources