Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Improve iOS support for users without Cocoapods (segmentio#27)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: We've improved iOS support for non-Cocoapods users. You do not need to follow these steps if you are using Cocoapods.

### Migration instructions

- Remove `Analytics.framework` from your Xcode project
- Remove `Analytics.framework` from `Embedded Binaries`
- Follow [Current instructions](#current-instructions)

### Current instructions

1. Add `analytics-ios` as a npm dependency: `yarn add @segment/analytics-ios@github:segmentio/analytics-ios#3.6.10`
2. In the `General` tab for your project, search for `Embedded Binaries` and add the `Analytics.framework`
   ![Embed Analytics.framework](https://segment.com/docs/sources/mobile/react-native/images/embed-analytics-framework.png)

### Previous instructions

1.  Download the [latest built SDK](https://github.com/segmentio/analytics-ios/releases), and unzip the zip file.
2.  Drag the unzipped Analytics.framework folder into your Xcode project.
    Make sure to check `Copy items if needed`.
    ![Add Analytics.framework](https://segment.com/docs/sources/mobile/react-native/images/add-analytics-framework.png)
3.  In the `General` tab for your project, search for `Embedded Binaries` and add the `Analytics.framework`.
    ![Embed Analytics.framework](https://segment.com/docs/sources/mobile/react-native/images/embed-analytics-framework.png)
  • Loading branch information
fathyb authored Dec 12, 2018
1 parent 727de66 commit e90a58c
Show file tree
Hide file tree
Showing 16 changed files with 2,058 additions and 41 deletions.
24 changes: 20 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,21 @@ jobs:

- run: yarn test-app test:android

test-ios:
test-ios-vanilla:
<<: *job
macos:
xcode: "9.4.0"
steps:
- checkout
# macOS VMs doesn't support Docker based caches
- run: yarn install --frozen-lockfile
- *attach
- run: brew tap wix/brew
- run: brew install wix/brew/applesimutils

- run: yarn test-app test:ios:vanilla

test-ios-cocoapods:
<<: *job
macos:
xcode: "9.4.0"
Expand All @@ -117,7 +131,7 @@ jobs:

- restore_cache:
key: cocoapods-specs
- run: yarn test-app test:ios
- run: yarn test-app test:ios:cocoapods
- save_cache:
key: cocoapods-specs
paths:
Expand All @@ -138,7 +152,8 @@ workflows:
jobs:
- install
- test-android: *requiresTestApp
- test-ios: *requiresTestApp
- test-ios-vanilla: *requiresTestApp
- test-ios-cocoapods: *requiresTestApp
- test-core: *requiresInstall
- lint: *requiresInstall
- build-integrations: *requiresInstall
Expand All @@ -152,7 +167,8 @@ workflows:
requires:
- build-test-app
- test-android
- test-ios
- test-ios-vanilla
- test-ios-cocoapods
- test-core
- lint
filters:
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import analytics from '@segment/analytics-react-native'
import GoogleAnalytics from '@segment/analytics-react-native-google-analytics'

await analytics.setup('writeKey', {
using: [GoogleAnalytics]
using: [GoogleAnalytics]
})
```

Expand Down Expand Up @@ -145,12 +145,9 @@ However, if you cannot use Cocoapods, you can manually install our dynamic frame

Here are the steps for installing manually:

1. Download the [latest built SDK](https://github.com/segmentio/analytics-ios/releases), and unzip the zip file.
2. Drag the unzipped Analytics.framework folder into your Xcode project.
Make sure to check `Copy items if needed`.
![Add Analytics.framework](docs/ios/add-analytics-framework.png)
3. In the `General` tab for your project, search for `Embedded Binaries` and add the `Analytics.framework`.
![Embed Analytics.framework](docs/ios/embed-analytics-framework.png)
1. Add `analytics-ios` as a npm dependency: `yarn add @segment/analytics-ios@github:segmentio/analytics-ios#3.6.10`
2. In the `General` tab for your project, search for `Embedded Binaries` and add the `Analytics.framework`
![Embed Analytics.framework](https://segment.com/docs/sources/mobile/react-native/images/embed-analytics-framework.png)

Please note, if you are choosing to not use a dependency manager, you must keep files up-to-date with regularly scheduled, manual updates.

Expand Down
Binary file removed docs/ios/add-analytics-framework.png
Binary file not shown.
Binary file removed docs/ios/embed-analytics-framework.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"lint-staged": "^7.2.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.14.2",
"react": "16.6.0-alpha.8af6728",
"react": "16.6.1",
"react-native": "^0.57.3",
"rimraf": "^2.6.2"
}
Expand Down
91 changes: 84 additions & 7 deletions packages/core/ios/RNAnalytics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,34 @@
objects = {

/* Begin PBXBuildFile section */
B3E7B58A1CC2AC0600A0062D /* RNAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNAnalytics.m */; };
4B5DE17A21B9DF4B00BF8844 /* Analytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B5DE17421B9DF3900BF8844 /* Analytics.framework */; };
B3E7B58A1CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
4B5DE17321B9DF3900BF8844 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = EADEB85B1DECD080005322DA;
remoteInfo = Analytics;
};
4B5DE17521B9DF3900BF8844 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = EADEB86A1DECD0EF005322DA;
remoteInfo = AnalyticsTests;
};
4B5DE17721B9DF4700BF8844 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = EADEB85A1DECD080005322DA;
remoteInfo = Analytics;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
58B511D91A9E6C8500147676 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
Expand All @@ -24,15 +49,17 @@

/* Begin PBXFileReference section */
134814201AA4EA6300B7C361 /* libRNAnalytics.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNAnalytics.a; sourceTree = BUILT_PRODUCTS_DIR; };
B3E7B5881CC2AC0600A0062D /* RNAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNAnalytics/RNAnalytics.h; sourceTree = "<group>"; };
B3E7B5891CC2AC0600A0062D /* RNAnalytics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNAnalytics/RNAnalytics.m; sourceTree = "<group>"; };
4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Analytics.xcodeproj; path = "../../analytics-ios/Analytics.xcodeproj"; sourceTree = "<group>"; };
B3E7B5881CC2AC0600A0062D /* RNAnalytics/RNAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNAnalytics/RNAnalytics.h; sourceTree = "<group>"; };
B3E7B5891CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNAnalytics/RNAnalytics.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
58B511D81A9E6C8500147676 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4B5DE17A21B9DF4B00BF8844 /* Analytics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -47,12 +74,30 @@
name = Products;
sourceTree = "<group>";
};
4B5DE16F21B9DF3900BF8844 /* Products */ = {
isa = PBXGroup;
children = (
4B5DE17421B9DF3900BF8844 /* Analytics.framework */,
4B5DE17621B9DF3900BF8844 /* AnalyticsTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
4B5DE17921B9DF4B00BF8844 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
B3E7B5881CC2AC0600A0062D /* RNAnalytics.h */,
B3E7B5891CC2AC0600A0062D /* RNAnalytics.m */,
4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */,
B3E7B5881CC2AC0600A0062D /* RNAnalytics/RNAnalytics.h */,
B3E7B5891CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m */,
134814211AA4EA7D00B7C361 /* Products */,
4B5DE17921B9DF4B00BF8844 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -70,6 +115,7 @@
buildRules = (
);
dependencies = (
4B5DE17821B9DF4700BF8844 /* PBXTargetDependency */,
);
name = RNAnalytics;
productName = RCTDataManager;
Expand Down Expand Up @@ -100,24 +146,55 @@
mainGroup = 58B511D21A9E6C8500147676;
productRefGroup = 58B511D21A9E6C8500147676;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 4B5DE16F21B9DF3900BF8844 /* Products */;
ProjectRef = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
},
);
projectRoot = "";
targets = (
58B511DA1A9E6C8500147676 /* RNAnalytics */,
);
};
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
4B5DE17421B9DF3900BF8844 /* Analytics.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Analytics.framework;
remoteRef = 4B5DE17321B9DF3900BF8844 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
4B5DE17621B9DF3900BF8844 /* AnalyticsTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = AnalyticsTests.xctest;
remoteRef = 4B5DE17521B9DF3900BF8844 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXSourcesBuildPhase section */
58B511D71A9E6C8500147676 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B3E7B58A1CC2AC0600A0062D /* RNAnalytics.m in Sources */,
B3E7B58A1CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
4B5DE17821B9DF4700BF8844 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = Analytics;
targetProxy = 4B5DE17721B9DF4700BF8844 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
58B511ED1A9E6C8500147676 /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -204,7 +281,7 @@
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-app/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ for integration in `cd $build_dir && echo @segment/*`; do
integrations_require+="SEGMENT_INTEGRATIONS.push(integration_$counter);"
done

echo -e $integrations_require >> App.tsx
echo -e $integrations_require >> requires.js

yarn add $install_command @babel/runtime
yarn add typescript react-native-typescript-transformer @types/{react,react-native} --dev
Expand Down
13 changes: 10 additions & 3 deletions packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"private": true,
"scripts": {
"build": "./generate.sh",
"test:ios": "./test_ios.sh",
"test:ios:cocoapods": "COCOAPODS=yes ./test_ios.sh",
"test:ios:vanilla": "COCOAPODS=no ./test_ios.sh",
"test:android": "./test_android.sh",
"test": "run-s test:{ios,android}"
},
"devDependencies": {
"react-native-cli": "^2.0.1"
},
"dependencies": {
"detox": "^8.1.4",
"detox": "^9",
"isomorphic-fetch": "^2.2.1",
"mocha": "^5.2.0"
},
Expand All @@ -21,7 +22,13 @@
"specs": "e2e",
"runner-config": "e2e/mocha.opts",
"configurations": {
"ios": {
"ios-vanilla": {
"binaryPath": "project/ios/build/Build/Products/Release-iphonesimulator/project.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project project/ios/project.xcodeproj -scheme project -configuration Release -sdk iphonesimulator -derivedDataPath project/ios/build -quiet -UseModernBuildSystem=NO",
"type": "ios.simulator",
"name": "iPhone 7"
},
"ios-cocoapods": {
"binaryPath": "project/ios/build/Build/Products/Release-iphonesimulator/project.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace project/ios/project.xcworkspace -scheme project -configuration Release -sdk iphonesimulator -derivedDataPath project/ios/build -quiet -UseModernBuildSystem=NO",
"type": "ios.simulator",
Expand Down
File renamed without changes.
Loading

0 comments on commit e90a58c

Please sign in to comment.