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

Commit e90a58c

Browse files
authored
Improve iOS support for users without Cocoapods (segmentio#27)
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)
1 parent 727de66 commit e90a58c

File tree

16 files changed

+2058
-41
lines changed

16 files changed

+2058
-41
lines changed

.circleci/config.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,21 @@ jobs:
103103

104104
- run: yarn test-app test:android
105105

106-
test-ios:
106+
test-ios-vanilla:
107+
<<: *job
108+
macos:
109+
xcode: "9.4.0"
110+
steps:
111+
- checkout
112+
# macOS VMs doesn't support Docker based caches
113+
- run: yarn install --frozen-lockfile
114+
- *attach
115+
- run: brew tap wix/brew
116+
- run: brew install wix/brew/applesimutils
117+
118+
- run: yarn test-app test:ios:vanilla
119+
120+
test-ios-cocoapods:
107121
<<: *job
108122
macos:
109123
xcode: "9.4.0"
@@ -117,7 +131,7 @@ jobs:
117131

118132
- restore_cache:
119133
key: cocoapods-specs
120-
- run: yarn test-app test:ios
134+
- run: yarn test-app test:ios:cocoapods
121135
- save_cache:
122136
key: cocoapods-specs
123137
paths:
@@ -138,7 +152,8 @@ workflows:
138152
jobs:
139153
- install
140154
- test-android: *requiresTestApp
141-
- test-ios: *requiresTestApp
155+
- test-ios-vanilla: *requiresTestApp
156+
- test-ios-cocoapods: *requiresTestApp
142157
- test-core: *requiresInstall
143158
- lint: *requiresInstall
144159
- build-integrations: *requiresInstall
@@ -152,7 +167,8 @@ workflows:
152167
requires:
153168
- build-test-app
154169
- test-android
155-
- test-ios
170+
- test-ios-vanilla
171+
- test-ios-cocoapods
156172
- test-core
157173
- lint
158174
filters:

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import analytics from '@segment/analytics-react-native'
9999
import GoogleAnalytics from '@segment/analytics-react-native-google-analytics'
100100

101101
await analytics.setup('writeKey', {
102-
using: [GoogleAnalytics]
102+
using: [GoogleAnalytics]
103103
})
104104
```
105105

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

146146
Here are the steps for installing manually:
147147

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

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

docs/ios/add-analytics-framework.png

-114 KB
Binary file not shown.
-214 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"lint-staged": "^7.2.0",
6969
"npm-run-all": "^4.1.3",
7070
"prettier": "^1.14.2",
71-
"react": "16.6.0-alpha.8af6728",
71+
"react": "16.6.1",
7272
"react-native": "^0.57.3",
7373
"rimraf": "^2.6.2"
7474
}

packages/core/ios/RNAnalytics.xcodeproj/project.pbxproj

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,34 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
B3E7B58A1CC2AC0600A0062D /* RNAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNAnalytics.m */; };
10+
4B5DE17A21B9DF4B00BF8844 /* Analytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B5DE17421B9DF3900BF8844 /* Analytics.framework */; };
11+
B3E7B58A1CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m */; };
1112
/* End PBXBuildFile section */
1213

14+
/* Begin PBXContainerItemProxy section */
15+
4B5DE17321B9DF3900BF8844 /* PBXContainerItemProxy */ = {
16+
isa = PBXContainerItemProxy;
17+
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
18+
proxyType = 2;
19+
remoteGlobalIDString = EADEB85B1DECD080005322DA;
20+
remoteInfo = Analytics;
21+
};
22+
4B5DE17521B9DF3900BF8844 /* PBXContainerItemProxy */ = {
23+
isa = PBXContainerItemProxy;
24+
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
25+
proxyType = 2;
26+
remoteGlobalIDString = EADEB86A1DECD0EF005322DA;
27+
remoteInfo = AnalyticsTests;
28+
};
29+
4B5DE17721B9DF4700BF8844 /* PBXContainerItemProxy */ = {
30+
isa = PBXContainerItemProxy;
31+
containerPortal = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
32+
proxyType = 1;
33+
remoteGlobalIDString = EADEB85A1DECD080005322DA;
34+
remoteInfo = Analytics;
35+
};
36+
/* End PBXContainerItemProxy section */
37+
1338
/* Begin PBXCopyFilesBuildPhase section */
1439
58B511D91A9E6C8500147676 /* CopyFiles */ = {
1540
isa = PBXCopyFilesBuildPhase;
@@ -24,15 +49,17 @@
2449

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

3157
/* Begin PBXFrameworksBuildPhase section */
3258
58B511D81A9E6C8500147676 /* Frameworks */ = {
3359
isa = PBXFrameworksBuildPhase;
3460
buildActionMask = 2147483647;
3561
files = (
62+
4B5DE17A21B9DF4B00BF8844 /* Analytics.framework in Frameworks */,
3663
);
3764
runOnlyForDeploymentPostprocessing = 0;
3865
};
@@ -47,12 +74,30 @@
4774
name = Products;
4875
sourceTree = "<group>";
4976
};
77+
4B5DE16F21B9DF3900BF8844 /* Products */ = {
78+
isa = PBXGroup;
79+
children = (
80+
4B5DE17421B9DF3900BF8844 /* Analytics.framework */,
81+
4B5DE17621B9DF3900BF8844 /* AnalyticsTests.xctest */,
82+
);
83+
name = Products;
84+
sourceTree = "<group>";
85+
};
86+
4B5DE17921B9DF4B00BF8844 /* Frameworks */ = {
87+
isa = PBXGroup;
88+
children = (
89+
);
90+
name = Frameworks;
91+
sourceTree = "<group>";
92+
};
5093
58B511D21A9E6C8500147676 = {
5194
isa = PBXGroup;
5295
children = (
53-
B3E7B5881CC2AC0600A0062D /* RNAnalytics.h */,
54-
B3E7B5891CC2AC0600A0062D /* RNAnalytics.m */,
96+
4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */,
97+
B3E7B5881CC2AC0600A0062D /* RNAnalytics/RNAnalytics.h */,
98+
B3E7B5891CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m */,
5599
134814211AA4EA7D00B7C361 /* Products */,
100+
4B5DE17921B9DF4B00BF8844 /* Frameworks */,
56101
);
57102
sourceTree = "<group>";
58103
};
@@ -70,6 +115,7 @@
70115
buildRules = (
71116
);
72117
dependencies = (
118+
4B5DE17821B9DF4700BF8844 /* PBXTargetDependency */,
73119
);
74120
name = RNAnalytics;
75121
productName = RCTDataManager;
@@ -100,24 +146,55 @@
100146
mainGroup = 58B511D21A9E6C8500147676;
101147
productRefGroup = 58B511D21A9E6C8500147676;
102148
projectDirPath = "";
149+
projectReferences = (
150+
{
151+
ProductGroup = 4B5DE16F21B9DF3900BF8844 /* Products */;
152+
ProjectRef = 4B5DE16E21B9DF3900BF8844 /* Analytics.xcodeproj */;
153+
},
154+
);
103155
projectRoot = "";
104156
targets = (
105157
58B511DA1A9E6C8500147676 /* RNAnalytics */,
106158
);
107159
};
108160
/* End PBXProject section */
109161

162+
/* Begin PBXReferenceProxy section */
163+
4B5DE17421B9DF3900BF8844 /* Analytics.framework */ = {
164+
isa = PBXReferenceProxy;
165+
fileType = wrapper.framework;
166+
path = Analytics.framework;
167+
remoteRef = 4B5DE17321B9DF3900BF8844 /* PBXContainerItemProxy */;
168+
sourceTree = BUILT_PRODUCTS_DIR;
169+
};
170+
4B5DE17621B9DF3900BF8844 /* AnalyticsTests.xctest */ = {
171+
isa = PBXReferenceProxy;
172+
fileType = wrapper.cfbundle;
173+
path = AnalyticsTests.xctest;
174+
remoteRef = 4B5DE17521B9DF3900BF8844 /* PBXContainerItemProxy */;
175+
sourceTree = BUILT_PRODUCTS_DIR;
176+
};
177+
/* End PBXReferenceProxy section */
178+
110179
/* Begin PBXSourcesBuildPhase section */
111180
58B511D71A9E6C8500147676 /* Sources */ = {
112181
isa = PBXSourcesBuildPhase;
113182
buildActionMask = 2147483647;
114183
files = (
115-
B3E7B58A1CC2AC0600A0062D /* RNAnalytics.m in Sources */,
184+
B3E7B58A1CC2AC0600A0062D /* RNAnalytics/RNAnalytics.m in Sources */,
116185
);
117186
runOnlyForDeploymentPostprocessing = 0;
118187
};
119188
/* End PBXSourcesBuildPhase section */
120189

190+
/* Begin PBXTargetDependency section */
191+
4B5DE17821B9DF4700BF8844 /* PBXTargetDependency */ = {
192+
isa = PBXTargetDependency;
193+
name = Analytics;
194+
targetProxy = 4B5DE17721B9DF4700BF8844 /* PBXContainerItemProxy */;
195+
};
196+
/* End PBXTargetDependency section */
197+
121198
/* Begin XCBuildConfiguration section */
122199
58B511ED1A9E6C8500147676 /* Debug */ = {
123200
isa = XCBuildConfiguration;
@@ -204,7 +281,7 @@
204281
isa = XCBuildConfiguration;
205282
buildSettings = {
206283
HEADER_SEARCH_PATHS = (
207-
"$(inherited)",
284+
"$(inherited)",
208285
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
209286
"$(SRCROOT)/../../../React/**",
210287
"$(SRCROOT)/../../react-native/React/**",

packages/test-app/generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ for integration in `cd $build_dir && echo @segment/*`; do
2727
integrations_require+="SEGMENT_INTEGRATIONS.push(integration_$counter);"
2828
done
2929

30-
echo -e $integrations_require >> App.tsx
30+
echo -e $integrations_require >> requires.js
3131

3232
yarn add $install_command @babel/runtime
3333
yarn add typescript react-native-typescript-transformer @types/{react,react-native} --dev

packages/test-app/package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
"private": true,
55
"scripts": {
66
"build": "./generate.sh",
7-
"test:ios": "./test_ios.sh",
7+
"test:ios:cocoapods": "COCOAPODS=yes ./test_ios.sh",
8+
"test:ios:vanilla": "COCOAPODS=no ./test_ios.sh",
89
"test:android": "./test_android.sh",
910
"test": "run-s test:{ios,android}"
1011
},
1112
"devDependencies": {
1213
"react-native-cli": "^2.0.1"
1314
},
1415
"dependencies": {
15-
"detox": "^8.1.4",
16+
"detox": "^9",
1617
"isomorphic-fetch": "^2.2.1",
1718
"mocha": "^5.2.0"
1819
},
@@ -21,7 +22,13 @@
2122
"specs": "e2e",
2223
"runner-config": "e2e/mocha.opts",
2324
"configurations": {
24-
"ios": {
25+
"ios-vanilla": {
26+
"binaryPath": "project/ios/build/Build/Products/Release-iphonesimulator/project.app",
27+
"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",
28+
"type": "ios.simulator",
29+
"name": "iPhone 7"
30+
},
31+
"ios-cocoapods": {
2532
"binaryPath": "project/ios/build/Build/Products/Release-iphonesimulator/project.app",
2633
"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",
2734
"type": "ios.simulator",
File renamed without changes.

0 commit comments

Comments
 (0)