Skip to content

Commit

Permalink
Merge pull request #645 from OneSignal/fix/iosBitcode
Browse files Browse the repository at this point in the history
[Fix] iOS bitcode build error
  • Loading branch information
shepherd-l authored and jinliu9508 committed Mar 4, 2024
2 parents e9d41d5 + 53c7890 commit 0f75f8b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
13 changes: 11 additions & 2 deletions MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ The debug namespace is accessible via `OneSignal.Debug` and provides access to d
- We will be introducing JWT in a follow up release

# Troubleshooting

## Android
```
Assets/OneSignal/Example/OneSignalExampleBehaviou.cs: error CS0246: The type or namespace name '...' could not be found (are you missing a using directive or an assembly reference?)
```
Expand Down Expand Up @@ -283,4 +283,13 @@ Execution failed for task ':launcher:mergeReleaseJavaResource'.
1. Go to **Player Settings** and click the Android Tab. Under **Publishing Settings**, enable the following:
- Custom Main Gradle Template
- Custom Gradle Properties Template
2. Resolve Android dependencies with EDM4U at **Assets > External Dependency Manager > Android Resolver > Force Resolve**
2. Resolve Android dependencies with EDM4U at **Assets > External Dependency Manager > Android Resolver > Force Resolve**

## iOS
**Build error**
```
'/Users/.../Library/Developer/Xcode/DerivedData/Unity-iPhone-.../Build/Products/ReleaseForRunning-iphoneos/XCFrameworkIntermediates/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework/OneSignalCore' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/.../Library/Developer/Xcode/DerivedData/Unity-iPhone-.../Build/Products/ReleaseForRunning-iphoneos/XCFrameworkIntermediates/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework/OneSignalCore' for architecture arm64
```

1. For each target, select the **Build Settings** tab
2. Set **Enable Bitcode** to **No**
1 change: 1 addition & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Sending VSAttribution data from the editor
- iOS notifications clicked event firing if the app was cold started from clicking a notification
- ClassNotFoundException: com.onesignal.OneSignal for Android builds with minify enabled. You must run the "Copy Android plugin to Assets" step in **Window > OneSignal SDK Setup**.
- Disabled bitcode to avoid iOS build error

## [5.0.2]
### Fixed
Expand Down
13 changes: 11 additions & 2 deletions OneSignalExample/Assets/OneSignal/MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ The debug namespace is accessible via `OneSignal.Debug` and provides access to d
- We will be introducing JWT in a follow up release

# Troubleshooting

## Android
```
Assets/OneSignal/Example/OneSignalExampleBehaviou.cs: error CS0246: The type or namespace name '...' could not be found (are you missing a using directive or an assembly reference?)
```
Expand Down Expand Up @@ -283,4 +283,13 @@ Execution failed for task ':launcher:mergeReleaseJavaResource'.
1. Go to **Player Settings** and click the Android Tab. Under **Publishing Settings**, enable the following:
- Custom Main Gradle Template
- Custom Gradle Properties Template
2. Resolve Android dependencies with EDM4U at **Assets > External Dependency Manager > Android Resolver > Force Resolve**
2. Resolve Android dependencies with EDM4U at **Assets > External Dependency Manager > Android Resolver > Force Resolve**

## iOS
**Build error**
```
'/Users/.../Library/Developer/Xcode/DerivedData/Unity-iPhone-.../Build/Products/ReleaseForRunning-iphoneos/XCFrameworkIntermediates/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework/OneSignalCore' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/.../Library/Developer/Xcode/DerivedData/Unity-iPhone-.../Build/Products/ReleaseForRunning-iphoneos/XCFrameworkIntermediates/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework/OneSignalCore' for architecture arm64
```

1. For each target, select the **Build Settings** tab
2. Set **Enable Bitcode** to **No**
2 changes: 2 additions & 0 deletions OneSignalExample/Assets/OneSignal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ After building in Unity and exporting the XCode project follow these steps:
6. **App Groups** should now be provisioned for you going forward for your iOS bundle id, even on clean builds.
7. Make sure all **Targets** have **Enable Bitcode** set to **No** in **Build Settings**.
### Android
Most of the Android setup was already handled during installation!
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ After building in Unity and exporting the XCode project follow these steps:
6. **App Groups** should now be provisioned for you going forward for your iOS bundle id, even on clean builds.
7. Make sure all **Targets** have **Enable Bitcode** set to **No** in **Build Settings**.
### Android
In the Unity editor:
Expand Down
17 changes: 17 additions & 0 deletions com.onesignal.unity.ios/Editor/BuildPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public void OnPostprocessBuild(BuildReport report) {
// Add the service extension
AddNotificationServiceExtension();

DisableBitcode();

// Save the project back out
File.WriteAllText(_projectPath, _project.WriteToString());
}
Expand Down Expand Up @@ -191,6 +193,7 @@ private void AddNotificationServiceExtension() {
_project.SetBuildProperty(extensionGuid, "SWIFT_VERSION", "5.0");
_project.SetBuildProperty(extensionGuid, "ARCHS", "arm64");
_project.SetBuildProperty(extensionGuid, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);
_project.SetBuildProperty(extensionGuid, "ENABLE_BITCODE", "NO");

_project.AddBuildProperty(extensionGuid, "LIBRARY_SEARCH_PATHS",
$"$(PROJECT_DIR)/Libraries/{PluginLibrariesPath.Replace("\\", "/")}");
Expand Down Expand Up @@ -282,6 +285,20 @@ private void ExtensionAddPodsToTarget() {

File.WriteAllText(podfilePath, podfile);
}

private void DisableBitcode() {
// Main
var targetGuid = _project.GetMainTargetGuid();
_project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

// Unity Tests
var unityTests = _project.TargetGuidByName(PBXProject.GetUnityTestTargetName());
_project.SetBuildProperty(unityTests, "ENABLE_BITCODE", "NO");

// Unity Framework
var unityFramework = _project.GetUnityFrameworkTargetGuid();
_project.SetBuildProperty(unityFramework, "ENABLE_BITCODE", "NO");
}
}
}
#endif

0 comments on commit 0f75f8b

Please sign in to comment.