Skip to content

Commit

Permalink
docs: add docs on how to add sample apps to code base (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed Mar 30, 2023
1 parent f9146ee commit 303ef55
Show file tree
Hide file tree
Showing 17 changed files with 603 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Build app via Fastlane
uses: maierj/fastlane-action@v3.0.0
with:
lane: "ios build_app"
lane: "build"
subdirectory: "Apps/${{ matrix.sample-app }}"


396 changes: 396 additions & 0 deletions Apps/APN-UIKit/APN UIKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
5 changes: 5 additions & 0 deletions Apps/APN-UIKit/APN UIKit/APN_UIKit.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Apps/APN-UIKit/APN UIKit/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
12 changes: 12 additions & 0 deletions Apps/APN-UIKit/APN UIKit/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import CioTracking
import Foundation
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CustomerIO.initialize(siteId: "", apiKey: "", region: .US, configure: nil)

return true
}
}
5 changes: 3 additions & 2 deletions Apps/CocoaPods-FCM/fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app_identifier(["io.customer.ios-sample.cocoapods-fcm", "io.customer.ios-sample.cocoapods-fcm.richpush"])
team_id "2YC97BQN3N"
# Include all of the bundle identifiers for your iOS app and for your rich push target.
# You find the bundle identifier of each app inside of Xcode - https://stackoverflow.com/a/59131511
app_identifier(["io.customer.ios-sample.cocoapods-fcm", "io.customer.ios-sample.cocoapods-fcm.richpush"])
23 changes: 1 addition & 22 deletions Apps/CocoaPods-FCM/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
platform :ios do

before_all do |lane, options|
setup_ci
end

# Note: I was experiencing issues getting adhoc code signing working for the cocoapods FCM sample app.
# For now, we just need to test the app compiles so development code signing is good enough for now until we fix the issue.
# For now, do code signing and app compiling using development type.
lane :build_app do |arguments|
sync_code_signing(
type: "development"
)

build_ios_app(
export_method: "development",
configuration: "Debug",
xcodebuild_formatter: "xcbeautify"
)
end

end
import "../../fastlane/Fastfile" # imports shared Fastfile from "Apps/fastlane/Fastfile"
7 changes: 6 additions & 1 deletion Apps/CocoaPods-FCM/fastlane/Gymfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Scheme of your app inside of Xcode.
# Make sure the scheme is Shared - https://stackoverflow.com/a/8425495
# https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project/
scheme "test cocoapods"
# If your iOS app uses CocoaPods, you will want to specify the path to the xcworkspace for the app.
workspace "test cocoapods.xcworkspace"
export_method 'ad-hoc'
# If your project uses Swift Package Manager instead of CocoaPods, use:
# project "test cocoapods.xcodeproj"
5 changes: 0 additions & 5 deletions Apps/CocoaPods-FCM/fastlane/Matchfile

This file was deleted.

40 changes: 40 additions & 0 deletions Apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Sample apps

# Create a new sample app

* In Xcode, create a new iOS app. Put the iOS app in a new directory inside of `Apps/` directory of this repository. There are examples in this repository that you can reference.

* [Setup code signing for this new iOS app](https://github.com/customerio/apple-code-signing#creating-a-new-ios-app).

* Copy the directory: `Apps/CocoaPods-FCM/fastlane/` into your new iOS sample app's directory. These files are required in order for the CI server to compile the sample app. Go through each of the files and edit them to values that are correct for your new iOS app.

* Time to install the Customer.io SDK into the Xcode project. All sample apps are meant to install the *local copy on the file system* of the SDK instead of a version of the SDK in production.

Note: It's preferred to use Swift Package Manager instead of CocoaPods but some sample apps need to use CocoaPods so we can test that environment customers may have.

**If your new sample app uses CocoaPods**, then copy the `Podfile` from `../Apps/CocoaPods-FCM/Podfile`. That file is designed to always install the SDK from the local copy of the SDK which is what all of our sample apps should be doing.

**If your new sample app uses Swift Package Manager**, you need to [follow these steps](https://developer.apple.com/documentation/xcode/editing-a-package-dependency-as-a-local-package#Overview). By following those steps, you will (1) install the CIO SDK inside of Xcode as you normally would. Installing a production version of the SDK. Then, you will drag+drop the CIO SDK directory on your computer into Xcode which then *overrides* the production version of the SDK. This means that Xcode will now compile the iOS app using the *local* copy of the SDK instead of production copy. After you are done, this is what Xcode should look like:

![customer.io ios sdk source code directory should be added to project explorer](../docs/img/xcode_view_spm_localsdk.png)

* Open `../.github/workflows/build-sample-apps.yml`. In this file, you will see code that looks like this:

```yml
...
matrix: # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
sample-app:
- "Foo"
```

Add a new entry to this list. The value will be the new directory that you created inside of `Apps/`. For example, if the new iOS app you made is inside of: `Apps/CocoaPods-FCM/`, then add this entry to this file:

```yml
...
matrix: # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
sample-app:
- "CocoaPods-FCM"
```

When you make a pull request for the new sample app that you created, you should see this app get compiled by the CI server.

38 changes: 38 additions & 0 deletions Apps/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Fastfile that is meant to be used by all iOS apps in the organization.
# This file is meant to be imported into another `Fastfile` so the functions in this file are usable.
#
# Import this file in 2 ways:
# 1. Locally (for all Fastfile files in this repository)
# Use "import" from these docs: https://docs.fastlane.tools/advanced/Fastfile/#importing-another-fastfile
#
# 2. Remotely (for all Fastfile files in a git repository not this one)
# Add this to your Fastfile:
# ```
# import_from_git(
# url: "git@github.com:customerio/customerio-ios.git", # The URL of the repository to import the Fastfile from.
# branch: "main", # The branch to checkout on the repository.
# path: "Apps/fastlane/Fastfile" # The path of the Fastfile in the repository.
# )
# ```

before_all do |lane, options|
setup_ci
end

# Note: I was experiencing issues getting adhoc code signing working for the cocoapods FCM sample app.
# For now, we just need to test the app compiles so development code signing is good enough for now until we fix the issue.
# For now, do code signing and app compiling using development type.
lane :build do |arguments|
sync_code_signing(
type: "development",
readonly: true,
storage_mode: "google_cloud",
google_cloud_bucket_name: "remote-habits-ios-signing"
)

build_ios_app(
export_method: "development",
configuration: "Debug",
xcodebuild_formatter: "xcbeautify"
)
end
Binary file added docs/img/xcode_view_spm_localsdk.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 303ef55

Please sign in to comment.