GithubHelp home page GithubHelp logo

sudoplz / react-native-amplitude-analytics Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 62.0 208 KB

React Native iOS and Android wrapper for Amplitude

License: MIT License

JavaScript 31.38% Java 31.63% Objective-C 29.18% Ruby 2.53% Starlark 5.28%

react-native-amplitude-analytics's People

Contributors

alex123456780 avatar almostintuitive avatar arvindhsukumar avatar berndschrooten avatar bilalsyed001 avatar capitanredbeard avatar chendo avatar dkpalmer avatar dozoisch avatar dryna avatar ericpkerr avatar francisco-sanchez-molina avatar guidolodetti avatar iamsoorena avatar ilydnic avatar kristinns avatar levibuzolic avatar lukem512 avatar mansya avatar msquitieri avatar nofxincubus avatar qvick1pro avatar rjbernaldo avatar sudoplz avatar titozzz avatar venom42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-amplitude-analytics's Issues

NPM package url problem

Hi!

In package.json, the URL key points to a different package, making anyone who doesn't refer to this repository by its correct url install a different package.

"url": "git+https://github.com/SudoPlz/react-native-amplitude-sdk.git"

Is this intentional? I'm very confused :)

Thank you!

Error with pod install

I was able to follow your instructions and get this running on Android, however I am hitting issues with iOS. After setting up the pod and running pod install I'm getting a failed build, below are the logs:

Showing Recent Issues

Build target yoga of project React with configuration Debug


Build target jsinspector of project React with configuration Debug


Build target privatedata of project React with configuration Debug


Build target double-conversion of project React with configuration Debug


Build target third-party of project React with configuration Debug


Build target jschelpers of project React with configuration Debug


Build target cxxreact of project React with configuration Debug


Build target React of project React with configuration Debug


Build target RCTSettings of project RCTSettings with configuration Debug


Build target RCTGeolocation of project RCTGeolocation with configuration Debug


Build target ART of project ART with configuration Debug


Build target RCTLinking of project RCTLinking with configuration Debug


Build target RCTImage of project RCTImage with configuration Debug


Build target RCTAnimation of project RCTAnimation with configuration Debug


Build target RCTText of project RCTText with configuration Debug


Build target fishhook of project RCTWebSocket with configuration Debug


Build target RCTWebSocket of project RCTWebSocket with configuration Debug


Build target PerformanceBezier of project PerformanceBezier with configuration Debug


Build target QuartzBookPack of project QuartzBookPack with configuration Debug


Build target RNSVG of project RNSVG with configuration Debug


Build target RCTVibration of project RCTVibration with configuration Debug


Build target RCTActionSheet of project RCTActionSheet with configuration Debug


Build target RCTBlob of project RCTBlob with configuration Debug


Build target RNVectorIcons of project RNVectorIcons with configuration Debug


Build target RNAmplitudeSDK of project RNAmplitudeSDK with configuration Debug


Build target RNImagePicker of project RNImagePicker with configuration Debug


Build target RCTNetwork of project RCTNetwork with configuration Debug


Build target TheApp of project TheApp with configuration Debug

Ld /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/TheApp.app/TheApp normal x86_64
    cd /Users/theuser/code/TheApp/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -L/Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator -L/Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/Amplitude-iOS -F/Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator -filelist /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Intermediates.noindex/TheApp.build/Debug-iphonesimulator/TheApp.build/Objects-normal/x86_64/TheApp.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -Xlinker -object_path_lto -Xlinker /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Intermediates.noindex/TheApp.build/Debug-iphonesimulator/TheApp.build/Objects-normal/x86_64/TheApp_lto.o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -lAmplitude-iOS -lsqlite3.0 -ObjC -lc++ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Intermediates.noindex/TheApp.build/Debug-iphonesimulator/TheApp.build/TheApp.app-Simulated.xcent /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTBlob.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libReact.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTActionSheet.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTGeolocation.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTImage.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTLinking.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTNetwork.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTSettings.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTText.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTVibration.a /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libRCTWebSocket.a -lRNImagePicker /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/libART.a -lRNSVG -lRNVectorIcons -lRNAmplitudeSDK -lPods-TheApp -Xlinker -dependency_info -Xlinker /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Intermediates.noindex/TheApp.build/Debug-iphonesimulator/TheApp.build/Objects-normal/x86_64/TheApp_dependency_info.dat -o /Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/TheApp.app/TheApp

ld: warning: directory not found for option '-L/Users/theuser/Library/Developer/Xcode/DerivedData/TheApp-avzkxzwxtqbeorehxtbykvxaefjp/Build/Products/Debug-iphonesimulator/Amplitude-iOS'
ld: library not found for -lAmplitude-iOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)



Build failed    7/17/18, 12:14 AM

RNAmplitudeSDK: No native client found.

react-native 0.54.2
nodejs 8.4.0

  1. add line to pod
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'

target 'atlantm' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  pod 'Amplitude-iOS', '~> 4.0.4'
end

  1. Install pods
pod install
  1. Build app
react-native run-ios
  1. Add js code to app index.js
import RNAmplitute from 'react-native-amplitude-analytics';

console.log('RNAmplitute', RNAmplitute);

const amplitude = new RNAmplitute('....');

amplitude.logEvent('test event');

Get the error

Unhandled JS Exception: RNAmplitudeSDK: No native client found. Is RNAmplitudeSDK installed in your native code project?

I tried to debug the problem and found that in index.js in react-native-amplitude-analytics – RNAmplitudeSDK is undefined.

// Libraries
import { NativeModules, Platform } from 'react-native';

// Native Modules
const { RNAmplitudeSDK } = NativeModules;
var amplitudeHasInitialized = false;

console.log('RNAmplitudeSDK', RNAmplitudeSDK);

class Amplitude {

[Question] Initialization in several components

Hi! I have a little question about using package, is there an opportunity to init Amplitude in main component and log events in several child components and do we need this or we can just init amplitude in each component and then log events?
Thanks

Ошибка сборки кастомного presenter

Осваиваю эту библиотеку и пробую сделать кастомный Presenter
Presenter:

@InjectViewState
public class MainPresenter extends MvpPresenter {
DbHandler dbHandler;

public MainPresenter(DbHandler dbHandler) {
    this.dbHandler = dbHandler;
}

`

Activity:

`
public class MainActivity extends MvpAppCompatActivity implements MainView {

private Button timeStamp;
private RecyclerView listTimestamp;
private TimeStampAdapterRV adapterRV;
private DbHandler dbHandler = new DbHandler(this);

@InjectPresenter MainPresenter presenter;

@ProvidePresenter
MainPresenter createMainPresenter(DbHandler handler){
    return new MainPresenter(dbHandler);
}

`

Получаю ошибку:
error: method createMainPresenter in class MainActivity cannot be applied to given types; required: DbHandler found: no arguments reason: actual and formal argument lists differ in length

Raw SQL queries used for SQLLite database

Issue

App uses SQLite Database and execute raw SQL query. Untrusted user input in raw SQL queries can cause SQL Injection. Also sensitive information should be encrypted and written to the database.

Risk

A SQL injection attack involves integrating SQL commands into input data, mimicking the syntax of a predefined SQL command. A successful SQL injection attack allows the attacker to read or write to the database and possibly execute administrative commands, depending on the permissions granted by the server.

Fix

Verify that the following best practices have been followed: - Untrusted inputs are type-checked and/or validated using a list of acceptable values. -Prepared statements with variable binding (i.e. parameterized queries) are used when performing database queries. If prepared statements are defined, user-supplied data and SQL code are automatically separated.

Code

On File com/amplitude/api/DatabaseHelper.java


public void onCreate(SQLiteDatabase sQLiteDatabase) { 
sQLiteDatabase.execSQL(CREATE_STORE_TABLE); 
sQLiteDatabase.execSQL(CREATE_LONG_STORE_TABLE);
sQLiteDatabase.execSQL(CREATE_EVENTS_TABLE);
sQLiteDatabase.execSQL(CREATE_IDENTIFYS_TABLE);
}
if (i == 1) {
sQLiteDatabase.execSQL(CREATE_STORE_TABLE); if (i2 <= 2) {
}
sQLiteDatabase.execSQL(CREATE_IDENTIFYS_TABLE); sQLiteDatabase.execSQL(CREATE_LONG_STORE_TABLE);
}

private void resetDatabase(SQLiteDatabase sQLiteDatabase) {
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS store"); 
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS long_store");
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS events");
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS identifys");
onCreate(sQLiteDatabase);

NPM install / setUserPropertyOnce is not a function

Hi,

Thanks for the lib'.
Just for info, the installation by npm does not deliver (a priori) the latest version of the library code.

Indeed, the following function is not available despite the merge of PR #32 :

// set the user property once
amplitude.setUserPropertyOnce (property, value)

Cheers

Doubt about pod install in iOS

I have a doubt about why, as stated in the iOS installation docs, we need to add the line:

pod 'Amplitude-iOS', '~> 4.3.1'

If we follow the installation instructions, we need to do first

react-native link react-native-amplitude-analytics

which adds to the pod file the following line:

pod 'react-native-amplitude-analytics', :path => '../node_modules/react-native-amplitude-analytics'

In the react-native-amplitude-analytics.podspec file we are already saying that react-native-amplitude-analytics depends on Amplitude-iOS with the following line:

s.dependency "Amplitude-iOS", "~> 4.3.1"

So why do we need to modify the Podfile again with pod 'Amplitude-iOS'....?

[Android] com.amplitude.api.AmplitudeClient: Invalid API key, make sure your API key is correct in initialize()

I've integrated the module into our project and it is working successfully for iOS.
However, when we are attempting to trigger events on Android I am seeing the following error in the console when running adb logcat | grep AmplitudeClient:

com.amplitude.api.AmplitudeClient: Invalid API key, make sure your API key is correct in initialize()

I checked the Android example in the examples folder and there doesn't seem to be any code instantiating the client. Is it possible to verify that the code is currently working on Android?

Thanks!

For version 0.1.16, build fails due to createJSModules being removed in RN 0.47

Hi there,

When linking this library against RN 0.55 we found errors due to this override:

> Task :react-native-amplitude-analytics:compileReleaseJavaWithJavac
/Users/gk/geet/SGLearner/node_modules/react-native-amplitude-analytics/android/src/main/java/com/sudoplz/reactnativeamplitudeanalytics/RNAmplitudeSDKPackage.java:30: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: /Users/gk/geet/SGLearner/node_modules/react-native-amplitude-analytics/android/src/main/java/com/sudoplz/reactnativeamplitudeanalytics/RNAmplitudeSDK.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

It seems that this method got removed in RN 0.47.2, by this commit:

facebook/react-native@ce6fb33

Locally simply removing createJSModules worked for me. In terms of a proper fix, should we just get rid of the @Override (so that the lib still builds against older RN versions, but won't cause problems with newer RN versions)?

convertArrayToJson is missing on Android

node_modules/react-native-amplitude-analytics/android/src/main/java/com/sudoplz/reactnativeamplitudeanalytics/RNAmplitudeSDK.java:168: error: cannot find symbol
            array.put(convertArrayToJson(readableArray.getArray(i)));
                      ^
  symbol:   method convertArrayToJson(ReadableArray)
  location: class RNAmplitudeSDK

i have error like that when trying compile android app with latest version.

After added methods from this gist (https://gist.github.com/viperwarp/2beb6bbefcc268dee7ad) all works. Could your please check this on our end ?

RN 0.57.1

TypeScript typings

Hi!

I have a TS file definition for this component. Would you like me to PR it here as index.d.ts OR would you prefer I add it to DefinitelyTyped.

PR'ing it here makes it easier to keep it in sync since it's side by side, but I'll go with your preference.

New logo/icon

Hi, I am a graphic designer, I want to help others in graphic design.

After I reviewed your project, you have no logo on this project. Therefore I want to contribute to this project by creating a new logo / icon. what do you think?

Failed to Build with an exception all of a sudden from today

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-amplitude-analytics'.
      > Could not resolve all dependencies for configuration ':react-native-amplitude-analytics:_debugPublishCopy'.
         > Could not find any version that matches com.facebook.react:react-native:0.18.+.
           Versions that do not match:
               0.20.1
               0.19.1
               0.17.1
               0.16.0
               0.15.0
               + 5 more
           Required by:
               project :react-native-amplitude-analytics

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I have been using react-native-amplitude-analytics for few days but all of a sudden im getting this error

Trouble building the app

I'm having trouble in building the app

I'm working with
react native 0.55.4
cocoapods 1.5.3
react-native-firebase 4.2.0

npm i react-native-amplitude-analytics --save
react-native link react-native-amplitude-analytics

added the pod to the podfile:
pod 'Amplitude-iOS', '~> 4.3.1'

screen shot 2018-10-22 at 6 32 40 pm

Passing receipt to logPurchase on Android

Hi!

Thanks for this library, we find it really useful!
According to the code, the IAP receipt can be passed to logPurchase on iOS, but not on Android. Is there any reason why logPurchase is not supported on Android that we should be aware of?

Thank you!

hard coded buildToolsVersion causing warning after upgrading to RN 0.57

Configure project :react-native-amplitude-analytics
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Build Failed in Android

I did everything according to the documentation for configure react-native-amplitude-analytics. But my build failed in Android:

.../MainApplication.java:64: error: constructor RNAmplitudeSDKPackage in class RNAmplitudeSDKPackage cannot be applied to given types;
new RNAmplitudeSDKPackage(),
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length

I need to put MainApplication.this in new RNAmplitudeSDKPackage(MainApplication.this), at MainApplication.java

I`m adding this question here in case anyone has the same problem.

Updating Amplitude SDK to 4.3.1 ?

Hi there,

I was just wondering if it was possible to update the iOS SDK to the latest one (4.3.1). Th 4.0.4 will be soon one year old (October 2017),

Thanks,
Best regards

'Amplitude.h' file not found

I'm trying to integrate Amplitude into React Native app using this library. Android works fine although the iOS fails with error:

"(...)/node_modules/react-native-amplitude-analytics/ios/AmplitudeSDK.h:11:9: 'Amplitude.h' file not found

#import "Amplitude.h""
^

When I check this in the Xcode I can see AmplitudeSDK.h which refers to Amplitude.h which is missing.

React Native version: 0.55.4

Steps I made:

  1. yarn add react-native-amplitude-analytics
  2. react-native link react-native-amplitude-analytics
  3. check if everything was added correctly

Is there anything I am missing?

0.60.x problems on Android

Hey there

I have been migrating my project over to RN 0.60.x and am having trouble with react-native-amplitude-analytics - the error i am seeing is:

AwesomeProject/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:51: error: constructor RNAmplitudeSDKPackage in class RNAmplitudeSDKPackage cannot be applied to given types;
      new RNAmplitudeSDKPackage()
      ^
  required: Application
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error

Which you can replicate on a fresh project like this:

react-native init AwesomeProject
cd AwesomeProject
yarn add react-native-amplitude-analytics
react-native run-android

This is to do with the change to auto-linking combined with the new build process on Android but i am not familiar with how the PackageList.java file is generated by the new CLI stuff so can't create a pull request to fix.

Environment:

System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 1.36 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.2.0 - /usr/local/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.10.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      API Levels: 23, 28
      Build Tools: 28.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.3 => 0.60.3 
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1

WORKAROUND:

In the meantime - the following is needed to workaround the issue:

  1. Create a file called react-native.config.js in the root of the project (same place as package.json)
  2. Put this into that file: module.exports = { dependencies: { 'react-native-amplitude-analytics': { platforms: { android: undefined } } } };

This will then let you use all the manual linking as currently documented in the readme.

Deprecate this repository in favor of @amplitude/react-native

Now that @amplitude/react-native exists, it seems unneeded for this package to remain around. Unless there is a valid reason to continue to use this SDK for some users, having two SDKs can lead developers astray from the officially supported package.

I recommend that this github repo be archived, the npm package marked deprecated, and a message added to the readme telling others to use https://www.npmjs.com/package/@amplitude/react-native instead.

If there is still a valid use-case for this SDK, then a link to https://www.npmjs.com/package/@amplitude/react-native should still be provided, along with an explanation why this repo is still relevant.

[iOS] Not finding Amplitude-iOS SDK when building with manual SDK

EDIT/UPDATE

TL;DR Got this working by using Carthage to handle the SDK dependency. Read below for more info.


Env

    react-native-amplitude-analytics @ ^0.2.6
	XCode @ 10.1
	MacOS Mojave @ 10.14

Problem

The iOS app doesn't build without errors due to problems with the manually downloaded Amplitude-iOS SDK.

Note: Library is building and running fine on Android

Steps

So following the build instructions for iOS:

  1. Installed npm i react-native-amplitude-analytics --save
  2. Linked libraries react-native link react-native-amplitude-analytics
  3. Double check that RNAmplitudeSDK.xcodeproj is in 'Libraries' and ** libRNAmplitudeSDK.a** is in 'Link Binary With Libraries'
  4. Manually setup Amplitude SDK
    a. Downloaded the latest SDK here.
    b. Unzip download, rename folder from Amplitude-iOS-master => Amplitude-iOS
    c. Move directory to the <PROJ_ROOT>/ios directory
  5. Build App, observe the following error:
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_AMPIdentify", referenced from:
      objc-class-ref in libRNAmplitudeSDK.a(AmplitudeSDK.o)
  "_OBJC_CLASS_$_AMPRevenue", referenced from:
      objc-class-ref in libRNAmplitudeSDK.a(AmplitudeSDK.o)
  "_OBJC_CLASS_$_Amplitude", referenced from:
      objc-class-ref in libRNAmplitudeSDK.a(AmplitudeSDK.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thoughts

This error indicates that some of the defined structs, AMPIdentify, AMPRevenue, Amplitude can not be found within the libRNAmplitudeSDK.a file.
So this implies that the checked(✅) steps are all working as intended, it's the SDK that is not being found properly.

Things I've tried so far:

  1. Using and renaming the downloaded Amplitude-iOS-master/Amplitude to Amplitude-iOS instead of the root downloaded directory.
  2. Full cleaning everything, watchman delete + derived data delete + clean build folder + computer restart
  3. Adding $(PROJECT_DIR)/Amplitude-iOS to my 'Framework Search Paths'

@SudoPlz Have you gotten the manual installation to work? If so is there something special I need to do with my Amplitude-iOS directory?

Carthage build fails.

"$(SRCROOT)/../../../ios/Carthage/Checkouts/Amplitude-iOS/Amplitude"
needs to be added to the Header Search Paths just like the Pod directory already is:
"$(SRCROOT)/../../../ios/Pods/Amplitude-iOS",

Otherwise: "Amplitude.h" and "AMPRevenue.h" are not found when attempting to build target: RNAmplitudeSDK.

It must have worked because the build had a Pod install included as well already. But on a straight Carthage build the ios/Pods directory will not exist and these header files cannot be found.

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.